diff --git a/compatibility/4.4/storage-engine-adapter/src/main/java/org/neo4j/gds/compat/_44/InMemoryStorageEngineImpl.java b/compatibility/4.4/storage-engine-adapter/src/main/java/org/neo4j/gds/compat/_44/InMemoryStorageEngineImpl.java index 66f118de22..af7dbf0a86 100644 --- a/compatibility/4.4/storage-engine-adapter/src/main/java/org/neo4j/gds/compat/_44/InMemoryStorageEngineImpl.java +++ b/compatibility/4.4/storage-engine-adapter/src/main/java/org/neo4j/gds/compat/_44/InMemoryStorageEngineImpl.java @@ -83,7 +83,7 @@ public final class InMemoryStorageEngineImpl implements StorageEngine { ) { this.databaseLayout = databaseLayout; this.graphStore = getGraphStoreFromCatalog(databaseLayout.getDatabaseName()); - this.txStateVisitor = new InMemoryTransactionStateVisitor(graphStore, tokenHolders); + this.txStateVisitor = new InMemoryTransactionStateVisitor(graphStore, tokenHolders, false); this.commandCreationContext = new InMemoryCommandCreationContextImpl(); this.tokenManager = new TokenManager( tokenHolders, diff --git a/compatibility/api/storage-engine-adapter/src/main/java/org/neo4j/gds/storageengine/InMemoryTransactionStateVisitor.java b/compatibility/api/storage-engine-adapter/src/main/java/org/neo4j/gds/storageengine/InMemoryTransactionStateVisitor.java index 90cf868249..c3fa810237 100644 --- a/compatibility/api/storage-engine-adapter/src/main/java/org/neo4j/gds/storageengine/InMemoryTransactionStateVisitor.java +++ b/compatibility/api/storage-engine-adapter/src/main/java/org/neo4j/gds/storageengine/InMemoryTransactionStateVisitor.java @@ -48,14 +48,24 @@ public class InMemoryTransactionStateVisitor extends TxStateVisitor.Adapter { private final CypherGraphStore graphStore; private final TokenHolders tokenHolders; + private final boolean doRegisterNewTokens; private final IntObjectMap nodePropertiesCache; public InMemoryTransactionStateVisitor( CypherGraphStore graphStore, TokenHolders tokenHolders + ) { + this(graphStore, tokenHolders, true); + } + + public InMemoryTransactionStateVisitor( + CypherGraphStore graphStore, + TokenHolders tokenHolders, + boolean doRegisterNewTokens ) { this.graphStore = graphStore; this.tokenHolders = tokenHolders; + this.doRegisterNewTokens = doRegisterNewTokens; this.nodePropertiesCache = new IntObjectHashMap<>(); } @@ -112,18 +122,24 @@ public void visitNodeLabelChanges( @Override public void visitCreatedLabelToken(long id, String name, boolean internal) { - tokenHolders.labelTokens().addToken(new NamedToken(name, (int) id, internal)); - graphStore.addNodeLabel(NodeLabel.of(name)); + if (doRegisterNewTokens) { + tokenHolders.labelTokens().addToken(new NamedToken(name, (int) id, internal)); + graphStore.addNodeLabel(NodeLabel.of(name)); + } } @Override public void visitCreatedPropertyKeyToken(long id, String name, boolean internal) { - tokenHolders.propertyKeyTokens().addToken(new NamedToken(name, (int) id, internal)); + if (doRegisterNewTokens) { + tokenHolders.propertyKeyTokens().addToken(new NamedToken(name, (int) id, internal)); + } } @Override public void visitCreatedRelationshipTypeToken(long id, String name, boolean internal) { - tokenHolders.relationshipTypeTokens().addToken(new NamedToken(name, (int) id, internal)); + if (doRegisterNewTokens) { + tokenHolders.relationshipTypeTokens().addToken(new NamedToken(name, (int) id, internal)); + } } private void visitAddedOrChangedNodeProperties(long nodeId, Iterator added, Iterator changed) {