File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
core/src/main/java/org/neo4j/gds Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 1919 */
2020package org .neo4j .gds .api ;
2121
22- import org .immutables .value .Value ;
2322import org .neo4j .gds .annotation .ValueClass ;
2423
2524import java .util .Collection ;
@@ -32,6 +31,10 @@ public interface RelationshipPropertyStore {
3231
3332 Map <String , RelationshipProperty > relationshipProperties ();
3433
34+ default boolean isEmpty () {
35+ return relationshipProperties ().isEmpty ();
36+ }
37+
3538 default RelationshipProperty get (String propertyKey ) {
3639 return relationshipProperties ().get (propertyKey );
3740 }
@@ -48,13 +51,6 @@ default boolean containsKey(String propertyKey) {
4851 return relationshipProperties ().containsKey (propertyKey );
4952 }
5053
51- @ Value .Check
52- default void validate () {
53- if (relationshipProperties ().isEmpty ()) {
54- throw new IllegalStateException ("Relationship property store must not be empty." );
55- }
56- }
57-
5854 static Builder builder () {
5955 // need to initialize with empty map due to `deferCollectionAllocation = true`
6056 return new Builder ().relationshipProperties (Collections .emptyMap ());
Original file line number Diff line number Diff line change 1919 */
2020package org .neo4j .gds .core .loading ;
2121
22+ import org .immutables .value .Value ;
2223import org .neo4j .gds .annotation .ValueClass ;
2324import org .neo4j .gds .api .RelationshipPropertyStore ;
2425import org .neo4j .gds .api .Relationships ;
@@ -42,6 +43,17 @@ public interface SingleTypeRelationshipImportResult {
4243
4344 Optional <RelationshipPropertyStore > inverseProperties ();
4445
46+ @ Value .Check
47+ default SingleTypeRelationshipImportResult normalize () {
48+ if (properties ().map (RelationshipPropertyStore ::isEmpty ).orElse (false )) {
49+ return builder ().from (this ).properties (Optional .empty ()).build ();
50+ }
51+ if (inverseProperties ().map (RelationshipPropertyStore ::isEmpty ).orElse (false )) {
52+ return builder ().from (this ).inverseProperties (Optional .empty ()).build ();
53+ }
54+ return this ;
55+ }
56+
4557 static ImmutableSingleTypeRelationshipImportResult .Builder builder () {
4658 return ImmutableSingleTypeRelationshipImportResult .builder ();
4759 }
You can’t perform that action at this time.
0 commit comments