use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method shouldReadRelationshipGroupCommand.
@Test
public void shouldReadRelationshipGroupCommand() throws Throwable {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipGroupRecord before = new RelationshipGroupRecord(42, 3);
RelationshipGroupRecord after = new RelationshipGroupRecord(42, 3, 4, 5, 6, 7, 8, true);
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());
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyRelationshipGroupCommandToTheStore.
// RELATIONSHIP GROUP COMMAND
@Test
public void shouldApplyRelationshipGroupCommandToTheStore() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(false);
// 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);
final boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(relationshipGroupStore, times(1)).updateRecord(after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class TransactionRecordStateTest method assertRelationshipGroupsInOrder.
private void assertRelationshipGroupsInOrder(NeoStores neoStores, long nodeId, int... types) {
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), NORMAL);
assertTrue("Node should be dense, is " + node, node.isDense());
long groupId = node.getNextRel();
int cursor = 0;
List<RelationshipGroupRecord> seen = new ArrayList<>();
while (groupId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
RelationshipGroupRecord group = relationshipGroupStore.getRecord(groupId, relationshipGroupStore.newRecord(), NORMAL);
seen.add(group);
assertEquals("Invalid type, seen groups so far " + seen, types[cursor++], group.getType());
groupId = group.getNext();
}
assertEquals("Not enough relationship group records found in chain for " + node, types.length, cursor);
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class TransactionRecordStateTest method getRelationshipGroup.
private static RecordProxy<Long, RelationshipGroupRecord, Integer> getRelationshipGroup(RecordChangeSet recordChangeSet, NodeRecord node, int type) {
long groupId = node.getNextRel();
long previousGroupId = Record.NO_NEXT_RELATIONSHIP.intValue();
while (groupId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
RecordProxy<Long, RelationshipGroupRecord, Integer> change = recordChangeSet.getRelGroupRecords().getOrLoad(groupId, type);
RelationshipGroupRecord record = change.forReadingData();
// not persistent so not a "change"
record.setPrev(previousGroupId);
if (record.getType() == type) {
return change;
}
previousGroupId = groupId;
groupId = record.getNext();
}
return null;
}
use of org.neo4j.kernel.impl.store.record.RelationshipGroupRecord in project neo4j by neo4j.
the class RelationshipGroupCommandV2_2Test method shouldSerializeCreatedRecord.
@Test
public void shouldSerializeCreatedRecord() throws Exception {
// Given
RelationshipGroupRecord before = new RelationshipGroupRecord(10, 12);
before.setInUse(false);
RelationshipGroupRecord after = new RelationshipGroupRecord(10, 12, 13, 14, 15, 16, 17, true);
after.setCreated();
// When
assertSerializationWorksFor(new Command.RelationshipGroupCommand(before, after));
}
Aggregations