use of org.neo4j.kernel.impl.core.RelationshipTypeToken in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyRelationshipTypeTokenCommandToTheStoreInRecovery.
@Test
public void shouldApplyRelationshipTypeTokenCommandToTheStoreInRecovery() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(true);
final RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord(42);
final RelationshipTypeTokenRecord after = new RelationshipTypeTokenRecord(42);
after.setInUse(true);
after.setNameId(323);
final Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(before, after);
final RelationshipTypeToken token = new RelationshipTypeToken("token", 21);
when(relationshipTypeTokenStore.getToken((int) command.getKey())).thenReturn(token);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(relationshipTypeTokenStore, times(1)).setHighestPossibleIdInUse(after.getId());
verify(relationshipTypeTokenStore, times(1)).updateRecord(after);
verify(cacheAccess, times(1)).addRelationshipTypeToken(token);
}
use of org.neo4j.kernel.impl.core.RelationshipTypeToken in project neo4j by neo4j.
the class BatchInserterImpl method createNewRelationshipType.
private int createNewRelationshipType(String name) {
int id = (int) relationshipTypeTokenStore.nextId();
RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(id);
record.setInUse(true);
record.setCreated();
Collection<DynamicRecord> nameRecords = relationshipTypeTokenStore.allocateNameRecords(encodeString(name));
record.setNameId((int) Iterables.first(nameRecords).getId());
record.addNameRecords(nameRecords);
relationshipTypeTokenStore.updateRecord(record);
relationshipTypeTokens.addToken(new RelationshipTypeToken(name, id));
return id;
}
use of org.neo4j.kernel.impl.core.RelationshipTypeToken in project neo4j by neo4j.
the class CacheInvalidationTransactionApplier method visitRelationshipTypeTokenCommand.
@Override
public boolean visitRelationshipTypeTokenCommand(RelationshipTypeTokenCommand command) throws IOException {
RelationshipTypeToken type = relationshipTypeTokenStore.getToken((int) command.getKey());
cacheAccess.addRelationshipTypeToken(type);
return false;
}
use of org.neo4j.kernel.impl.core.RelationshipTypeToken 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();
}
}
}
Aggregations