use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0_2 method readRelationshipTypeTokenRecord.
private RelationshipTypeTokenRecord readRelationshipTypeTokenRecord(int id, ReadableChannel channel) throws IOException {
// in_use(byte)+type_blockId(int)+nr_type_records(int)
byte inUseFlag = channel.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(id);
record.setInUse(inUse);
record.setNameId(channel.getInt());
int nrTypeRecords = channel.getInt();
for (int i = 0; i < nrTypeRecords; i++) {
DynamicRecord dr = readDynamicRecord(channel);
if (dr == null) {
return null;
}
record.addNameRecord(dr);
}
return record;
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_2_4 method visitRelationshipTypeTokenCommand.
private Command visitRelationshipTypeTokenCommand(ReadableChannel channel) throws IOException {
// id+in_use(byte)+type_blockId(int)+nr_type_records(int)
int id = channel.getInt();
byte inUseFlag = channel.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(id);
record.setInUse(inUse);
record.setNameId(channel.getInt());
int nrTypeRecords = channel.getInt();
for (int i = 0; i < nrTypeRecords; i++) {
DynamicRecord dr = readDynamicRecord(channel);
if (dr == null) {
return null;
}
record.addNameRecord(dr);
}
return new Command.RelationshipTypeTokenCommand(null, record);
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_0 method visitRelationshipTypeTokenCommand.
private Command visitRelationshipTypeTokenCommand(ReadableChannel channel) throws IOException {
// id+in_use(byte)+type_blockId(int)+nr_type_records(int)
int id = channel.getInt();
byte inUseFlag = channel.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(id);
record.setInUse(inUse);
record.setNameId(channel.getInt());
int nrTypeRecords = channel.getInt();
for (int i = 0; i < nrTypeRecords; i++) {
DynamicRecord dr = readDynamicRecord(channel);
if (dr == null) {
return null;
}
record.addNameRecord(dr);
}
return new Command.RelationshipTypeTokenCommand(null, record);
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyRelationshipTypeTokenCommandToTheStore.
// RELATIONSHIP TYPE TOKEN COMMAND
@Test
public void shouldApplyRelationshipTypeTokenCommandToTheStore() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(false);
final RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord(42);
final RelationshipTypeTokenRecord after = new RelationshipTypeTokenRecord(42);
after.setInUse(true);
after.setNameId(323);
final Command command = new RelationshipTypeTokenCommand(before, after);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(relationshipTypeTokenStore, times(1)).updateRecord(after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord 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);
}
Aggregations