Skip to content

Commit

Permalink
Merge pull request #8593 from soerenreichardt/fix-tokenholder-dev-issue
Browse files Browse the repository at this point in the history
Fix tokens not being registered
  • Loading branch information
soerenreichardt authored Jan 16, 2024
2 parents cafdb61 + 3cf25d4 commit e277f21
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.neo4j.storageengine.api.StorageProperty;
import org.neo4j.storageengine.api.txstate.TxStateVisitor;
import org.neo4j.token.TokenHolders;
import org.neo4j.token.api.NamedToken;
import org.neo4j.token.api.TokenNotFoundException;
import org.neo4j.values.storable.Value;

Expand All @@ -47,14 +48,24 @@ public class InMemoryTransactionStateVisitor extends TxStateVisitor.Adapter {

private final CypherGraphStore graphStore;
private final TokenHolders tokenHolders;
private final boolean doRegisterNewTokens;
private final IntObjectMap<UpdatableNodeProperty> 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<>();
}

Expand Down Expand Up @@ -111,7 +122,24 @@ public void visitNodeLabelChanges(

@Override
public void visitCreatedLabelToken(long id, String name, boolean 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) {
if (doRegisterNewTokens) {
tokenHolders.propertyKeyTokens().addToken(new NamedToken(name, (int) id, internal));
}
}

@Override
public void visitCreatedRelationshipTypeToken(long id, String name, boolean internal) {
if (doRegisterNewTokens) {
tokenHolders.relationshipTypeTokens().addToken(new NamedToken(name, (int) id, internal));
}
}

private void visitAddedOrChangedNodeProperties(long nodeId, Iterator<StorageProperty> added, Iterator<StorageProperty> changed) {
Expand Down

0 comments on commit e277f21

Please sign in to comment.