use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class ApplyRecoveredTransactionsTest method shouldSetCorrectHighIdWhenApplyingExternalTransactions.
@Test
void shouldSetCorrectHighIdWhenApplyingExternalTransactions() throws Exception {
// WHEN recovering a transaction that creates some data
long nodeId = neoStores.getNodeStore().nextId(NULL);
long relationshipId = neoStores.getRelationshipStore().nextId(NULL);
int type = 1;
applyExternalTransaction(1, new NodeCommand(new NodeRecord(nodeId), inUse(created(new NodeRecord(nodeId)))), new RelationshipCommand(null, inUse(created(with(new RelationshipRecord(relationshipId), nodeId, nodeId, type)))));
// and when, later on, recovering a transaction deleting some of those
applyExternalTransaction(2, new NodeCommand(inUse(created(new NodeRecord(nodeId))), new NodeRecord(nodeId)), new RelationshipCommand(null, new RelationshipRecord(relationshipId)));
// THEN that should be possible and the high ids should be correct, i.e. highest applied + 1
assertEquals(nodeId + 1, neoStores.getNodeStore().getHighId());
assertEquals(relationshipId + 1, neoStores.getRelationshipStore().getHighId());
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class Commands method createRelationship.
public static RelationshipCommand createRelationship(long id, long startNode, long endNode, int type) {
RelationshipRecord before = new RelationshipRecord(id);
before.setInUse(false);
RelationshipRecord after = new RelationshipRecord(id);
after.setLinks(startNode, endNode, type);
after.setInUse(true);
after.setCreated();
return new RelationshipCommand(before, after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class LogCommandSerializationV3_0_10Test method readRelationshipCommandWithSecondaryUnit.
@Test
void readRelationshipCommandWithSecondaryUnit() throws IOException {
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipRecord before = new RelationshipRecord(42);
before.initialize(true, 0, 1, 2, 3, 4, 5, 6, 7, true, true);
before.setSecondaryUnitIdOnLoad(47);
RelationshipRecord after = new RelationshipRecord(42);
after.initialize(true, 0, 1, 8, 3, 4, 5, 6, 7, true, true);
new Command.RelationshipCommand(writer(), before, after).serialize(channel);
Command command = INSTANCE.read(channel);
assertTrue(command instanceof Command.RelationshipCommand);
Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
assertEquals(before, relationshipCommand.getBefore());
verifySecondaryUnit(before, relationshipCommand.getBefore());
assertEquals(after, relationshipCommand.getAfter());
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class LogCommandSerializationV3_0_10Test method readRelationshipCommandWithNonRequiredSecondaryUnit.
@Test
void readRelationshipCommandWithNonRequiredSecondaryUnit() throws IOException {
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipRecord before = new RelationshipRecord(42);
before.initialize(true, 0, 1, 2, 3, 4, 5, 6, 7, true, true);
before.setSecondaryUnitIdOnLoad(52);
RelationshipRecord after = new RelationshipRecord(42);
after.initialize(true, 0, 1, 8, 3, 4, 5, 6, 7, true, true);
new Command.RelationshipCommand(writer(), before, after).serialize(channel);
Command command = INSTANCE.read(channel);
assertTrue(command instanceof Command.RelationshipCommand);
Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
assertEquals(before, relationshipCommand.getBefore());
verifySecondaryUnit(before, relationshipCommand.getBefore());
assertEquals(after, relationshipCommand.getAfter());
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class LogCommandSerializationV3_0_10Test method shouldReadRelationshipCommand.
@Test
void shouldReadRelationshipCommand() throws Throwable {
// Given
InMemoryClosableChannel channel = new InMemoryClosableChannel();
RelationshipRecord before = new RelationshipRecord(42);
before.setLinks(-1, -1, -1);
RelationshipRecord after = new RelationshipRecord(42);
after.initialize(true, 0, 1, 2, 3, 4, 5, 6, 7, true, true);
new Command.RelationshipCommand(writer(), before, after).serialize(channel);
// When
Command command = INSTANCE.read(channel);
assertTrue(command instanceof Command.RelationshipCommand);
Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command;
// Then
assertEquals(before, relationshipCommand.getBefore());
assertEquals(after, relationshipCommand.getAfter());
}
Aggregations