use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class TokenHolderTest method assertTokens.
private void assertTokens(Iterable<Token> allTokens, Token... expectedTokens) {
Map<String, Token> existing = new HashMap<>();
for (Token token : allTokens) {
existing.put(token.name(), token);
}
Map<String, Token> expected = new HashMap<>();
for (Token token : expectedTokens) {
expected.put(token.name(), token);
}
assertEquals(expected, existing);
}
use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class NeoStoresTest method validateRelTypes.
private void validateRelTypes(int relType1, int relType2) throws IOException {
Token data = rtStore.getToken(relType1);
assertEquals(relType1, data.id());
assertEquals("relationshiptype1", data.name());
data = rtStore.getToken(relType2);
assertEquals(relType2, data.id());
assertEquals("relationshiptype2", data.name());
List<RelationshipTypeToken> allData = rtStore.getTokens(Integer.MAX_VALUE);
assertEquals(2, allData.size());
for (int i = 0; i < 2; i++) {
if (allData.get(i).id() == relType1) {
assertEquals(relType1, allData.get(i).id());
assertEquals("relationshiptype1", allData.get(i).name());
} else if (allData.get(i).id() == relType2) {
assertEquals(relType2, allData.get(i).id());
assertEquals("relationshiptype2", allData.get(i).name());
} else {
throw new IOException();
}
}
}
use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class NonIndexedConflictResolverTest method shouldReuseExistingPropertyKeyTokensWhenThatHaveAlreadyCreatedOnPreviousNodes.
@Test
public void shouldReuseExistingPropertyKeyTokensWhenThatHaveAlreadyCreatedOnPreviousNodes() throws IOException {
// Given
NonIndexedConflictResolver resolver = new NonIndexedConflictResolver(propertyKeyTokenStore, propertyStore);
List<DuplicateCluster> clusterListA = new ArrayList<>();
long propertyIdA = addDuplicateCluster(nodeIdA, clusterListA);
List<DuplicateCluster> clusterListB = new ArrayList<>();
long propertyIdB = addDuplicateCluster(nodeIdB, clusterListB);
// When
resolver.visited(0, clusterListA);
resolver.visited(0, clusterListB);
// Then
Token duplicateTokenA = findTokenFor(propertyKeyTokenStore, "__DUPLICATE_keyA_1");
assertNotNull(duplicateTokenA);
Set<Integer> propertyKeyIdsA = collectPropertyKeyIds(propertyIdA);
assertThat(propertyKeyIdsA, contains(tokenA.id(), duplicateTokenA.id()));
Set<Integer> propertyKeyIdsB = collectPropertyKeyIds(propertyIdB);
assertThat(propertyKeyIdsB, contains(tokenA.id(), duplicateTokenA.id()));
}
use of org.neo4j.storageengine.api.Token in project neo4j by neo4j.
the class NonIndexedConflictResolverTest method setUp.
@Before
public void setUp() {
api = dbRule.getGraphDatabaseAPI();
String propKeyA = "keyA";
String propKeyB = "keyB";
String propKeyC = "keyC";
String propKeyD = "keyD";
String propKeyE = "keyE";
try (Transaction transaction = api.beginTx()) {
Node nodeA = api.createNode();
nodeA.setProperty(propKeyA, "value");
nodeA.setProperty(propKeyB, "value");
nodeIdA = nodeA.getId();
Node nodeB = api.createNode();
nodeB.setProperty(propKeyA, "value");
nodeB.setProperty(propKeyB, "value");
nodeIdB = nodeB.getId();
Node nodeC = api.createNode();
nodeC.setProperty(propKeyA, "longer val");
nodeC.setProperty(propKeyB, "longer val");
nodeC.setProperty(propKeyC, "longer val");
nodeC.setProperty(propKeyD, "longer val");
nodeC.setProperty(propKeyE, "longer val");
nodeIdC = nodeC.getId();
transaction.success();
}
DependencyResolver resolver = api.getDependencyResolver();
NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
nodeStore = neoStores.getNodeStore();
propertyStore = neoStores.getPropertyStore();
propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
tokenA = findTokenFor(propertyKeyTokenStore, propKeyA);
Token tokenB = findTokenFor(propertyKeyTokenStore, propKeyB);
Token tokenC = findTokenFor(propertyKeyTokenStore, propKeyC);
Token tokenD = findTokenFor(propertyKeyTokenStore, propKeyD);
Token tokenE = findTokenFor(propertyKeyTokenStore, propKeyE);
replacePropertyKey(propertyStore, nodeStore.getRecord(nodeIdA, nodeStore.newRecord(), FORCE), tokenB, tokenA);
replacePropertyKey(propertyStore, nodeStore.getRecord(nodeIdB, nodeStore.newRecord(), FORCE), tokenB, tokenA);
NodeRecord nodeRecordC = nodeStore.getRecord(nodeIdC, nodeStore.newRecord(), FORCE);
replacePropertyKey(propertyStore, nodeRecordC, tokenB, tokenA);
replacePropertyKey(propertyStore, nodeRecordC, tokenC, tokenA);
replacePropertyKey(propertyStore, nodeRecordC, tokenD, tokenA);
replacePropertyKey(propertyStore, nodeRecordC, tokenE, tokenA);
}
Aggregations