Skip to content

Commit a30f222

Browse files
Register new rel properties when added
1 parent 43f99f4 commit a30f222

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

cypher/api/storage-engine-adapter/src/main/java/org/neo4j/gds/compat/TokenManager.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ public void nodePropertyRemoved(String propertyKey) {
6161

6262
@Override
6363
public void nodePropertyAdded(String propertyKey) {
64-
try {
65-
tokenHolders.propertyKeyTokens().getOrCreateId(propertyKey);
66-
} catch (KernelException e) {
67-
throw new RuntimeException(e);
68-
}
64+
getOrCreatePropertyToken(propertyKey);
6965
}
7066

7167
@Override
@@ -86,6 +82,19 @@ public void relationshipTypeAdded(String relationshipType) {
8682
}
8783
}
8884

85+
@Override
86+
public void relationshipPropertyAdded(String relationshipProperty) {
87+
getOrCreatePropertyToken(relationshipProperty);
88+
}
89+
90+
private void getOrCreatePropertyToken(String propertyKey) {
91+
try {
92+
tokenHolders.propertyKeyTokens().getOrCreateId(propertyKey);
93+
} catch (KernelException e) {
94+
throw new RuntimeException(e);
95+
}
96+
}
97+
8998
public TokenHolders tokenHolders() {
9099
return this.tokenHolders;
91100
}

cypher/api/storage-engine-adapter/src/main/java/org/neo4j/gds/storageengine/InMemoryRelationshipCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private void newRelationshipIdContextAdded(RelationshipIds.RelationshipIdContext
161161
.map(AdjacencyProperties::rawPropertyCursor)
162162
.toArray(PropertyCursor[]::new)
163163
);
164-
var newSize = this.propertyCursorCache.size() + relationshipIdContext.adjacencyProperties().length;
164+
var newSize = this.propertyCursorCache.stream().mapToInt(cursor -> cursor.length).max().orElse(0);
165165
this.propertyValuesCache = new DoubleArrayList(new double[newSize]);
166166
}
167167

cypher/cypher-core/src/main/java/org/neo4j/gds/core/cypher/CypherGraphStore.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ public void addRelationshipType(
9393
Relationships relationships
9494
) {
9595
super.addRelationshipType(relationshipType, relationshipPropertyKey, relationshipPropertyType, relationships);
96+
relationshipPropertyKey.ifPresent(
97+
propertyKey -> stateVisitors.forEach(stateVisitor -> stateVisitor.relationshipPropertyAdded(propertyKey))
98+
);
9699
stateVisitors.forEach(stateVisitor -> stateVisitor.relationshipTypeAdded(relationshipType.name()));
97100
}
98101

@@ -109,6 +112,8 @@ public interface StateVisitor {
109112

110113
void relationshipTypeAdded(String relationshipType);
111114

115+
void relationshipPropertyAdded(String relationshipProperty);
116+
112117
class Adapter implements StateVisitor {
113118
@Override
114119
public void nodePropertyRemoved(String propertyKey) {
@@ -129,6 +134,11 @@ public void nodeLabelAdded(String nodeLabel) {
129134
public void relationshipTypeAdded(String relationshipType) {
130135

131136
}
137+
138+
@Override
139+
public void relationshipPropertyAdded(String relationshipProperty) {
140+
141+
}
132142
}
133143
}
134144
}

0 commit comments

Comments
 (0)