Class PossibleMappingsCalculator
We do this to make SchemaDiffings better understandable, but also to improve the overall runtime of the algorithm. By restricting the possible mappings the Schema diffing algo is actually able to finish in a reasonable time for real life inputs.
We restrict the algo by calculating which mappings are possible for given vertex. This is later used in
DiffImpl.calcLowerBoundMappingCost(graphql.schema.diffing.Vertex, graphql.schema.diffing.Vertex, graphql.schema.diffing.Mapping, java.util.Map<graphql.schema.diffing.Vertex, java.lang.Double>, java.util.Map<graphql.schema.diffing.Vertex, graphql.schema.diffing.Vertex>)
.
While doing this we need to also ensure that there are the same amount of vertices in the same "context":
for example if the source graph has 3 Objects, the target graph needs to have 3 Objects. We achieve this by
adding "isolated vertices" as needed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
static class
-
Constructor Summary
ConstructorsConstructorDescriptionPossibleMappingsCalculator
(SchemaGraph sourceGraph, SchemaGraph targetGraph, graphql.schema.diffing.SchemaDiffingRunningCheck runningCheck) -
Method Summary
Modifier and TypeMethodDescriptionvoid
calcPossibleMappings
(List<PossibleMappingsCalculator.VertexContextSegment> contexts, String typeNameForDebug) getFixedParentRestrictionsInverse
(Map<Vertex, Vertex> fixedOneToOneMappingsInverted) getNonFixedParentRestrictions
(SchemaGraph sourceGraph, SchemaGraph targetGraph, Mapping mapping) This computes the initial set of parent restrictions based on the given non-fixed mapping.static boolean
hasChildrenRestrictions
(Vertex vertex) static boolean
hasParentRestrictions
(Vertex vertex)
-
Constructor Details
-
PossibleMappingsCalculator
public PossibleMappingsCalculator(SchemaGraph sourceGraph, SchemaGraph targetGraph, graphql.schema.diffing.SchemaDiffingRunningCheck runningCheck)
-
-
Method Details
-
calculate
-
calcPossibleMappings
public void calcPossibleMappings(List<PossibleMappingsCalculator.VertexContextSegment> contexts, String typeNameForDebug) -
getFixedParentRestrictions
-
getFixedParentRestrictionsInverse
-
getNonFixedParentRestrictions
public Map<Vertex,Vertex> getNonFixedParentRestrictions(SchemaGraph sourceGraph, SchemaGraph targetGraph, Mapping mapping) This computes the initial set of parent restrictions based on the given non-fixed mapping.i.e. this introduces restrictions as the
Mapping
is being built, as decisions can have knock on effects on other vertices' possible mappings.See
Mapping
for definition of fixed vs non-fixed.If a
Vertex
is present in the outputMap
then the value is the parent the vertex MUST map to.e.g. for an output {collar: Dog} then the collar vertex must be a child of Dog in the mapping.
- Parameters:
sourceGraph
- the source graphtargetGraph
- the target graphmapping
- the mapping to get non-fixed parent restrictions for- Returns:
- Map where key is any vertex, and the value is the parent that vertex must map to
-
hasParentRestrictions
-
hasChildrenRestrictions
-