use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method readRelationshipGroupCommandWithNonRequiredSecondaryUnit.
@Test
public void readRelationshipGroupCommandWithNonRequiredSecondaryUnit() throws IOException {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipGroupRecord before = new RelationshipGroupRecord(42, 3);
RelationshipGroupRecord after = new RelationshipGroupRecord(42, 3, 4, 5, 6, 7, 8, true);
after.setRequiresSecondaryUnit(false);
after.setSecondaryUnitId(17);
after.setCreated();
new Command.RelationshipGroupCommand(before, after).serialize(channel);
// When
PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
Command command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipGroupCommand);
Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
// Then
assertEquals(before, relationshipGroupCommand.getBefore());
assertEquals(after, relationshipGroupCommand.getAfter());
verifySecondaryUnit(after, relationshipGroupCommand.getAfter());
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class PhysicalLogCommandReadersTest method assertValidRelGroupCommand.
private static void assertValidRelGroupCommand(StorageCommand command) {
assertThat(command, instanceOf(RelationshipGroupCommand.class));
RelationshipGroupCommand relGroupCommand = (RelationshipGroupCommand) command;
RelationshipGroupRecord record = relGroupCommand.getAfter();
assertEquals(ID, record.getId());
if (IN_USE_FLAG == Record.IN_USE.byteValue()) {
assertTrue(record.inUse());
} else if (IN_USE_FLAG == Record.NOT_IN_USE.byteValue()) {
assertFalse(record.inUse());
} else {
throw new IllegalStateException("Illegal inUse flag: " + IN_USE_FLAG);
}
assertEquals(TYPE_AS_INT, record.getType());
assertEquals(NEXT, record.getNext());
assertEquals(FIRST_OUT, record.getFirstOut());
assertEquals(FIRST_IN, record.getFirstIn());
assertEquals(FIRST_LOOP, record.getNext());
assertEquals(OWNING_NODE, record.getOwningNode());
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method readRelationshipGroupCommandWithSecondaryUnit.
@Test
public void readRelationshipGroupCommandWithSecondaryUnit() throws IOException {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipGroupRecord before = new RelationshipGroupRecord(42, 3);
RelationshipGroupRecord after = new RelationshipGroupRecord(42, 3, 4, 5, 6, 7, 8, true);
after.setRequiresSecondaryUnit(true);
after.setSecondaryUnitId(17);
after.setCreated();
new Command.RelationshipGroupCommand(before, after).serialize(channel);
// When
PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
Command command = reader.read(channel);
assertTrue(command instanceof Command.RelationshipGroupCommand);
Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command;
// Then
assertEquals(before, relationshipGroupCommand.getBefore());
assertEquals(after, relationshipGroupCommand.getAfter());
verifySecondaryUnit(after, relationshipGroupCommand.getAfter());
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyRelationshipGroupCommandToTheStoreInRecovery.
@Test
public void shouldApplyRelationshipGroupCommandToTheStoreInRecovery() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(true);
// when
final RelationshipGroupRecord before = new RelationshipGroupRecord(42, 1);
final RelationshipGroupRecord after = new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true);
final Command command = new Command.RelationshipGroupCommand(before, after);
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(relationshipGroupStore, times(1)).setHighestPossibleIdInUse(after.getId());
verify(relationshipGroupStore, times(1)).updateRecord(after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class RelationshipGroupRecordFormatTest method shouldReadUnsignedRelationshipTypeId.
@Test
public void shouldReadUnsignedRelationshipTypeId() throws Exception {
// GIVEN
try (PageCursor cursor = new StubPageCursor(1, recordSize * 10)) {
int offset = 10;
cursor.next();
RelationshipGroupRecord group = new RelationshipGroupRecord(2).initialize(true, Short.MAX_VALUE + offset, 1, 2, 3, 4, 5);
cursor.setOffset(offset);
format.write(group, cursor, recordSize);
// WHEN
RelationshipGroupRecord read = new RelationshipGroupRecord(group.getId());
cursor.setOffset(offset);
format.read(read, cursor, NORMAL, recordSize);
// THEN
assertEquals(group, read);
}
}
Aggregations