use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class CacheInvalidationTransactionApplier method visitLabelTokenCommand.
@Override
public boolean visitLabelTokenCommand(LabelTokenCommand command) throws IOException {
Token labelId = labelTokenStore.getToken((int) command.getKey());
cacheAccess.addLabelToken(labelId);
return false;
}
use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class LabelIT method shouldListAllLabels.
@Test
public void shouldListAllLabels() throws Exception {
// given
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
int label1Id = statement.tokenWriteOperations().labelGetOrCreateForName("label1");
int label2Id = statement.tokenWriteOperations().labelGetOrCreateForName("label2");
// when
Iterator<Token> labelIdsBeforeCommit = statement.readOperations().labelsGetAllTokens();
// then
assertThat(asCollection(labelIdsBeforeCommit), hasItems(new Token("label1", label1Id), new Token("label2", label2Id)));
// when
commit();
ReadOperations readOperations = readOperationsInNewTransaction();
Iterator<Token> labelIdsAfterCommit = readOperations.labelsGetAllTokens();
// then
assertThat(asCollection(labelIdsAfterCommit), hasItems(new Token("label1", label1Id), new Token("label2", label2Id)));
}
use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class PropertyIT method shouldListAllPropertyKeys.
@Test
public void shouldListAllPropertyKeys() throws Exception {
// given
dbWithNoCache();
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
int prop1 = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("prop1");
int prop2 = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("prop2");
// when
Iterator<Token> propIdsBeforeCommit = statement.readOperations().propertyKeyGetAllTokens();
// then
assertThat(asCollection(propIdsBeforeCommit), hasItems(new Token("prop1", prop1), new Token("prop2", prop2)));
// when
commit();
ReadOperations readOperations = readOperationsInNewTransaction();
Iterator<Token> propIdsAfterCommit = readOperations.propertyKeyGetAllTokens();
// then
assertThat(asCollection(propIdsAfterCommit), hasItems(new Token("prop1", prop1), new Token("prop2", prop2)));
}
use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class NonIndexedConflictResolverTest method shouldCreateNewPropertyKeyTokenWhenItIsNotCreatedOnPreviousNodes.
@Test
public void shouldCreateNewPropertyKeyTokenWhenItIsNotCreatedOnPreviousNodes() throws IOException {
// Given
NonIndexedConflictResolver resolver = new NonIndexedConflictResolver(propertyKeyTokenStore, propertyStore);
List<DuplicateCluster> clusterListA = new ArrayList<>();
long propertyIdA = addDuplicateCluster(nodeIdA, clusterListA);
List<DuplicateCluster> clusterListC = new ArrayList<>();
long propertyIdC = addDuplicateCluster(nodeIdC, clusterListC);
// When
resolver.visited(0, clusterListA);
resolver.visited(0, clusterListC);
// Then
Token duplicateTokenA1 = findTokenFor(propertyKeyTokenStore, "__DUPLICATE_keyA_1");
Token duplicateTokenA2 = findTokenFor(propertyKeyTokenStore, "__DUPLICATE_keyA_2");
Token duplicateTokenA3 = findTokenFor(propertyKeyTokenStore, "__DUPLICATE_keyA_3");
Token duplicateTokenA4 = findTokenFor(propertyKeyTokenStore, "__DUPLICATE_keyA_4");
assertNotNull(duplicateTokenA1);
assertNotNull(duplicateTokenA2);
assertNotNull(duplicateTokenA3);
assertNotNull(duplicateTokenA4);
Set<Integer> propertyKeyIdsA = collectPropertyKeyIds(propertyIdA);
assertThat(propertyKeyIdsA, contains(tokenA.id(), duplicateTokenA1.id()));
Set<Integer> propertyKeyIdsC = collectPropertyKeyIds(propertyIdC);
assertThat(propertyKeyIdsC, contains(tokenA.id(), duplicateTokenA1.id(), duplicateTokenA2.id(), duplicateTokenA3.id(), duplicateTokenA4.id()));
}
use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class NonIndexedConflictResolverTest method shouldRenameDuplicatedPropertyKeysOnANode.
@Test
public void shouldRenameDuplicatedPropertyKeysOnANode() throws Exception {
// Given
NonIndexedConflictResolver resolver = new NonIndexedConflictResolver(propertyKeyTokenStore, propertyStore);
List<DuplicateCluster> clusters = new ArrayList<>();
long propertyId = addDuplicateCluster(nodeIdA, clusters);
// When
resolver.visited(0, clusters);
// Then
Token duplicateTokenA = findTokenFor(propertyKeyTokenStore, "__DUPLICATE_keyA_1");
assertNotNull(duplicateTokenA);
Set<Integer> propertyKeyIdsA = collectPropertyKeyIds(propertyId);
assertThat(propertyKeyIdsA, contains(tokenA.id(), duplicateTokenA.id()));
}
Aggregations