use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class LogCommandSerializationV4_0Test method shouldReadInternalRelationshipTypeLabelCommand.
@Test
void shouldReadInternalRelationshipTypeLabelCommand() throws Exception {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord(42);
RelationshipTypeTokenRecord after = before.copy();
after.initialize(true, 13);
after.setCreated();
after.setInternal(true);
new Command.RelationshipTypeTokenCommand(writer(), before, after).serialize(channel);
// When
CommandReader reader = createReader();
StorageCommand command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipTypeTokenCommand);
Command.RelationshipTypeTokenCommand relationshipTypeTokenCommand = (Command.RelationshipTypeTokenCommand) command;
// Then
assertBeforeAndAfterEquals(relationshipTypeTokenCommand, before, after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class LogCommandSerializationV4_0Test method shouldReadRelationshipTypeCommand.
@Test
void shouldReadRelationshipTypeCommand() throws Exception {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord(42);
RelationshipTypeTokenRecord after = before.copy();
after.initialize(true, 13);
after.setCreated();
new Command.RelationshipTypeTokenCommand(writer(), before, after).serialize(channel);
// When
CommandReader reader = createReader();
StorageCommand command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipTypeTokenCommand);
Command.RelationshipTypeTokenCommand relationshipTypeTokenCommand = (Command.RelationshipTypeTokenCommand) command;
// Then
assertBeforeAndAfterEquals(relationshipTypeTokenCommand, before, after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class LogTruncationTest method createRelationshipTypeTokenRecord.
private static RelationshipTypeTokenRecord createRelationshipTypeTokenRecord(int id) {
RelationshipTypeTokenRecord relationshipTypeTokenRecord = new RelationshipTypeTokenRecord(id);
relationshipTypeTokenRecord.setInUse(true);
relationshipTypeTokenRecord.setNameId(333);
relationshipTypeTokenRecord.addNameRecord(new DynamicRecord(43));
return relationshipTypeTokenRecord;
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class BatchingTokenRepositoryTest method shouldRespectExistingTokens.
@Test
void shouldRespectExistingTokens() {
// given
TokenStore<RelationshipTypeTokenRecord> tokenStore = mock(TokenStore.class);
int previousHighId = 5;
when(tokenStore.getHighId()).thenReturn((long) previousHighId);
BatchingRelationshipTypeTokenRepository repo = new BatchingRelationshipTypeTokenRepository(tokenStore);
verify(tokenStore).getHighId();
// when
int tokenId = repo.getOrCreateId("NEW_ONE");
// then
assertEquals(previousHighId, tokenId);
}
use of org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_1 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);
}
Aggregations