3434import org .neo4j .gds .api .properties .nodes .NodePropertyValues ;
3535import org .neo4j .gds .api .schema .Direction ;
3636import org .neo4j .gds .api .schema .GraphSchema ;
37- import org .neo4j .gds .api .schema .NodeSchema ;
38- import org .neo4j .gds .api .schema .PropertySchema ;
3937import org .neo4j .gds .api .schema .RelationshipSchema ;
4038import org .neo4j .gds .core .GraphDimensions ;
4139import org .neo4j .gds .core .ImmutableGraphDimensions ;
4947import org .neo4j .gds .core .loading .construction .GraphFactory ;
5048import org .neo4j .gds .core .loading .construction .ImmutablePropertyConfig ;
5149import org .neo4j .gds .core .loading .construction .NodeLabelTokens ;
50+ import org .neo4j .gds .core .loading .construction .PropertyValues ;
5251import org .neo4j .gds .core .loading .construction .RelationshipsBuilder ;
5352import org .neo4j .gds .core .loading .nodeproperties .NodePropertiesFromStoreBuilder ;
5453import org .neo4j .gds .core .utils .mem .MemoryEstimation ;
5554import org .neo4j .gds .core .utils .mem .MemoryEstimations ;
5655import org .neo4j .gds .core .utils .progress .tasks .ProgressTracker ;
5756import org .neo4j .gds .extension .GdlSupportPerMethodExtension ;
57+ import org .neo4j .values .storable .Value ;
5858import org .neo4j .values .storable .Values ;
5959import org .s1ck .gdl .GDLHandler ;
6060import org .s1ck .gdl .model .Element ;
@@ -165,33 +165,33 @@ protected ProgressTracker initProgressTracker() {
165165
166166 @ Override
167167 protected GraphSchema computeGraphSchema (Nodes nodes , RelationshipImportResult relationshipImportResult ) {
168- var nodeProperties = nodes .properties ();
169- var nodeSchema = NodeSchema .empty ();
170- gdlHandler
171- .getVertices ()
172- .forEach (vertex -> {
173- var labels = vertex .getLabels ().stream ().map (NodeLabel ::of ).collect (Collectors .toList ());
174- if (labels .isEmpty ()) {
175- labels = List .of (NodeLabel .ALL_NODES );
176- }
177-
178- labels .forEach (label -> vertex
179- .getProperties ()
180- .forEach ((propertyKey , propertyValue ) -> nodeSchema
181- .getOrCreateLabel (label )
182- .addProperty (
183- propertyKey ,
184- PropertySchema .of (
185- propertyKey ,
186- nodeProperties .get (propertyKey ).valueType (),
187- nodeProperties .get (propertyKey ).defaultValue (),
188- nodeProperties .get (propertyKey ).propertyState ()
189- )
190- )
191- ));
192- });
193- // in case there were no properties add all labels
194- nodes .idMap ().availableNodeLabels ().forEach (nodeSchema ::getOrCreateLabel );
168+ // var nodeProperties = nodes.properties();
169+ // var nodeSchema = NodeSchema.empty();
170+ // gdlHandler
171+ // .getVertices()
172+ // .forEach(vertex -> {
173+ // var labels = vertex.getLabels().stream().map(NodeLabel::of).collect(Collectors.toList());
174+ // if (labels.isEmpty()) {
175+ // labels = List.of(NodeLabel.ALL_NODES);
176+ // }
177+ //
178+ // labels.forEach(label -> vertex
179+ // .getProperties()
180+ // .forEach((propertyKey, propertyValue) -> nodeSchema
181+ // .getOrCreateLabel(label)
182+ // .addProperty(
183+ // propertyKey,
184+ // PropertySchema.of(
185+ // propertyKey,
186+ // nodeProperties.get(propertyKey).valueType(),
187+ // nodeProperties.get(propertyKey).defaultValue(),
188+ // nodeProperties.get(propertyKey).propertyState()
189+ // )
190+ // )
191+ // ));
192+ // });
193+ // // in case there were no properties add all labels
194+ // nodes.idMap().availableNodeLabels().forEach(nodeSchema::getOrCreateLabel);
195195
196196 var relationshipSchema = relationshipImportResult .importResults ().entrySet ().stream ().reduce (
197197 RelationshipSchema .empty (),
@@ -204,7 +204,7 @@ protected GraphSchema computeGraphSchema(Nodes nodes, RelationshipImportResult r
204204 );
205205
206206 return GraphSchema .of (
207- nodeSchema ,
207+ nodes . schema () ,
208208 relationshipSchema ,
209209 Map .of ()
210210 );
@@ -230,7 +230,9 @@ private Nodes loadNodes() {
230230 var nodesBuilder = GraphFactory .initNodesBuilder ()
231231 .maxOriginalId (dimensions .highestPossibleNodeCount () - 1 )
232232 .hasLabelInformation (true )
233+ .hasProperties (true )
233234 .concurrency (1 )
235+ .propertyState (graphProjectConfig .propertyState ())
234236 .build ();
235237
236238 gdlHandler .getVertices ().forEach (vertex -> {
@@ -241,15 +243,24 @@ private Nodes loadNodes() {
241243 .filter (label -> !NodeLabel .ALL_NODES .name ().equals (label ))
242244 .collect (Collectors .toList ());
243245 }
246+
247+ Map <String , Value > propertyValues = new HashMap <>();
248+ vertex .getProperties ().forEach ((propertyKey , propertyValue ) -> {
249+ if (propertyValue instanceof List ) {
250+ propertyValue = convertListProperty ((List <?>) propertyValue );
251+ }
252+ propertyValues .put (propertyKey , Values .of (propertyValue ));
253+ });
254+
244255 nodesBuilder .addNode (
245256 vertex .getId (),
246- NodeLabelTokens .of (labels )
257+ NodeLabelTokens .of (labels ),
258+ PropertyValues .of (propertyValues )
247259 );
248260 });
249261
250- var idMap = nodesBuilder .build ().idMap ();
251-
252- return Nodes .of (idMap , loadNodeProperties (idMap ), graphProjectConfig .propertyState ());
262+ var nodes = nodesBuilder .build ();
263+ return Nodes .of (nodes .schema (), nodes .idMap (), loadNodeProperties (nodes .idMap ()), graphProjectConfig .propertyState ());
253264 }
254265
255266 private Map <PropertyMapping , NodePropertyValues > loadNodeProperties (IdMap idMap ) {
0 commit comments