|
21 | 21 |
|
22 | 22 | import org.jetbrains.annotations.NotNull; |
23 | 23 | import org.jetbrains.annotations.Nullable; |
24 | | -import org.neo4j.gds.NodeLabel; |
25 | 24 | import org.neo4j.gds.RelationshipType; |
26 | 25 | import org.neo4j.gds.annotation.CustomProcedure; |
27 | 26 | import org.neo4j.gds.api.DatabaseId; |
28 | 27 | import org.neo4j.gds.api.DefaultValue; |
29 | | -import org.neo4j.gds.api.PropertyState; |
30 | 28 | import org.neo4j.gds.api.nodeproperties.ValueType; |
31 | | -import org.neo4j.gds.api.properties.nodes.NodePropertyValues; |
32 | 29 | import org.neo4j.gds.api.schema.ImmutableGraphSchema; |
33 | | -import org.neo4j.gds.api.schema.NodeSchema; |
34 | | -import org.neo4j.gds.api.schema.PropertySchema; |
35 | 30 | import org.neo4j.gds.api.schema.RelationshipPropertySchema; |
36 | 31 | import org.neo4j.gds.api.schema.RelationshipSchema; |
37 | 32 | import org.neo4j.gds.compat.CompatUserAggregator; |
38 | 33 | import org.neo4j.gds.core.Aggregation; |
39 | 34 | import org.neo4j.gds.core.ConfigKeyValidation; |
40 | 35 | import org.neo4j.gds.core.compress.AdjacencyCompressor; |
41 | | -import org.neo4j.gds.core.loading.CSRGraphStoreUtil; |
42 | 36 | import org.neo4j.gds.core.loading.GraphStoreBuilder; |
43 | 37 | import org.neo4j.gds.core.loading.GraphStoreCatalog; |
44 | 38 | import org.neo4j.gds.core.loading.ImmutableNodes; |
@@ -188,8 +182,7 @@ void projectNextRelationship( |
188 | 182 | targetNodePropertyValues, |
189 | 183 | sourceNodeLabels, |
190 | 184 | targetNodeLabels, |
191 | | - relationshipConfig, |
192 | | - this.configValidator |
| 185 | + relationshipConfig |
193 | 186 | ); |
194 | 187 | } |
195 | 188 |
|
@@ -334,7 +327,6 @@ void validateConfigs(AnyValue nodesConfig, AnyValue relationshipConfig) { |
334 | 327 | } |
335 | 328 |
|
336 | 329 | // Does the actual importing work once we can initialize it with the first row |
337 | | - @SuppressWarnings("CodeBlock2Expr") |
338 | 330 | private static final class GraphImporter { |
339 | 331 | private final String graphName; |
340 | 332 | private final GraphProjectFromCypherAggregationConfig config; |
@@ -464,8 +456,7 @@ void update( |
464 | 456 | @Nullable MapValue targetNodePropertyValues, |
465 | 457 | NodeLabelToken sourceNodeLabels, |
466 | 458 | NodeLabelToken targetNodeLabels, |
467 | | - AnyValue relationshipConfig, |
468 | | - ConfigValidator configValidator |
| 459 | + AnyValue relationshipConfig |
469 | 460 | ) { |
470 | 461 | MapValue relationshipProperties = null; |
471 | 462 | RelationshipType relationshipType = RelationshipType.ALL_RELATIONSHIPS; |
@@ -624,75 +615,27 @@ private static double[] loadMultipleRelationshipProperties( |
624 | 615 | } |
625 | 616 |
|
626 | 617 | private AdjacencyCompressor.ValueMapper buildNodesWithProperties(GraphStoreBuilder graphStoreBuilder) { |
627 | | - |
628 | 618 | var idMapAndProperties = this.idMapBuilder.build(); |
629 | | - var nodes = idMapAndProperties.idMap(); |
630 | | - |
631 | | - var maybeNodeProperties = idMapAndProperties.nodeProperties(); |
632 | | - |
633 | | - var nodesBuilder = ImmutableNodes.builder().idMap(nodes); |
634 | | - |
635 | | - var nodePropertySchema = maybeNodeProperties |
636 | | - .map(nodeProperties -> nodeSchemaWithProperties( |
637 | | - nodes.availableNodeLabels(), |
638 | | - nodeProperties |
639 | | - )) |
640 | | - .orElseGet(() -> nodeSchemaWithoutProperties(nodes.availableNodeLabels())) |
641 | | - .unionProperties(); |
642 | | - |
643 | | - NodeSchema nodeSchema = NodeSchema.empty(); |
644 | | - nodes.availableNodeLabels().forEach(nodeSchema::getOrCreateLabel); |
645 | | - nodePropertySchema.forEach((propertyKey, propertySchema) -> { |
646 | | - nodes.availableNodeLabels().forEach(label -> { |
647 | | - nodeSchema.getOrCreateLabel(label).addProperty(propertySchema.key(), propertySchema); |
648 | | - }); |
649 | | - }); |
| 619 | + |
| 620 | + var idMap = idMapAndProperties.idMap(); |
| 621 | + var nodeSchema = idMapAndProperties.schema(); |
650 | 622 |
|
651 | 623 | this.graphSchemaBuilder.nodeSchema(nodeSchema); |
652 | 624 |
|
653 | | - maybeNodeProperties.ifPresent(allNodeProperties -> { |
654 | | - CSRGraphStoreUtil.extractNodeProperties( |
655 | | - nodesBuilder, |
656 | | - nodePropertySchema::get, |
657 | | - allNodeProperties |
658 | | - ); |
659 | | - }); |
| 625 | + var nodes = ImmutableNodes |
| 626 | + .builder() |
| 627 | + .idMap(idMap) |
| 628 | + .schema(nodeSchema) |
| 629 | + .properties(idMapAndProperties.propertyStore()) |
| 630 | + .build(); |
660 | 631 |
|
661 | | - graphStoreBuilder.nodes(nodesBuilder.schema(nodeSchema).build()); |
| 632 | + // graphStoreBuilder.nodes(nodesBuilder.schema(nodeSchema).build()); |
| 633 | + graphStoreBuilder.nodes(nodes); |
662 | 634 |
|
663 | 635 | // Relationships are added using their intermediate node ids. |
664 | 636 | // In order to map to the final internal ids, we need to use |
665 | 637 | // the mapping function of the wrapped id map. |
666 | | - return nodes.rootIdMap()::toMappedNodeId; |
667 | | - } |
668 | | - |
669 | | - private static NodeSchema nodeSchemaWithProperties( |
670 | | - Iterable<NodeLabel> nodeLabels, |
671 | | - Map<String, NodePropertyValues> propertyMap |
672 | | - ) { |
673 | | - var nodeSchema = NodeSchema.empty(); |
674 | | - |
675 | | - nodeLabels.forEach((nodeLabel) -> { |
676 | | - propertyMap.forEach((propertyName, nodeProperties) -> { |
677 | | - nodeSchema.getOrCreateLabel(nodeLabel).addProperty( |
678 | | - propertyName, |
679 | | - PropertySchema.of( |
680 | | - propertyName, |
681 | | - nodeProperties.valueType(), |
682 | | - nodeProperties.valueType().fallbackValue(), |
683 | | - PropertyState.TRANSIENT |
684 | | - ) |
685 | | - ); |
686 | | - }); |
687 | | - }); |
688 | | - |
689 | | - return nodeSchema; |
690 | | - } |
691 | | - |
692 | | - private static NodeSchema nodeSchemaWithoutProperties(Iterable<NodeLabel> nodeLabels) { |
693 | | - var nodeSchema = NodeSchema.empty(); |
694 | | - nodeLabels.forEach(nodeSchema::getOrCreateLabel); |
695 | | - return nodeSchema; |
| 638 | + return idMap.rootIdMap()::toMappedNodeId; |
696 | 639 | } |
697 | 640 |
|
698 | 641 | private void buildRelationshipsWithProperties( |
|
0 commit comments