use of org.neo4j.storageengine.api.CommandReader in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0Test method shouldReadSomeCommands.
@Test
public void shouldReadSomeCommands() throws Exception {
// GIVEN
InMemoryClosableChannel channel = new InMemoryClosableChannel();
Commands.createNode(0).serialize(channel);
Commands.createNode(1).serialize(channel);
Commands.createRelationshipTypeToken(0, 0).serialize(channel);
Commands.createRelationship(0, 0, 1, 0).serialize(channel);
Commands.createPropertyKeyToken(0, 0).serialize(channel);
Commands.createProperty(0, PropertyType.SHORT_STRING, 0).serialize(channel);
CommandReader reader = new PhysicalLogCommandReaderV3_0();
// THEN
assertTrue(reader.read(channel) instanceof Command.NodeCommand);
assertTrue(reader.read(channel) instanceof Command.NodeCommand);
assertTrue(reader.read(channel) instanceof Command.RelationshipTypeTokenCommand);
assertTrue(reader.read(channel) instanceof Command.RelationshipCommand);
assertTrue(reader.read(channel) instanceof Command.PropertyKeyTokenCommand);
assertTrue(reader.read(channel) instanceof Command.PropertyCommand);
}
use of org.neo4j.storageengine.api.CommandReader in project neo4j by neo4j.
the class IndexDefineCommandTest method shouldWriteIndexDefineCommandIfMapWithinShortRange.
@Test
public void shouldWriteIndexDefineCommandIfMapWithinShortRange() throws IOException {
// GIVEN
InMemoryClosableChannel channel = new InMemoryClosableChannel(10_000);
IndexDefineCommand command = initIndexDefineCommand(300);
// WHEN
command.serialize(channel);
// THEN
CommandReader commandReader = new RecordStorageCommandReaderFactory().byVersion(LogEntryVersion.CURRENT.byteCode());
IndexDefineCommand read = (IndexDefineCommand) commandReader.read(channel);
assertEquals(command.getIndexNameIdRange(), read.getIndexNameIdRange());
assertEquals(command.getKeyIdRange(), read.getKeyIdRange());
}
use of org.neo4j.storageengine.api.CommandReader in project neo4j by neo4j.
the class RelationshipGroupCommandV2_2Test method assertSerializationWorksFor.
private void assertSerializationWorksFor(Command.RelationshipGroupCommand cmd) throws IOException {
InMemoryClosableChannel channel = new InMemoryClosableChannel();
cmd.serialize(channel);
CommandReader commandReader = new PhysicalLogCommandReaderV2_2();
Command.RelationshipGroupCommand result = (Command.RelationshipGroupCommand) commandReader.read(channel);
RelationshipGroupRecord recordBefore = cmd.getBefore();
RelationshipGroupRecord recordAfter = result.getAfter();
// Then
assertThat(recordBefore.getFirstIn(), equalTo(recordAfter.getFirstIn()));
assertThat(recordBefore.getFirstOut(), equalTo(recordAfter.getFirstOut()));
assertThat(recordBefore.getFirstLoop(), equalTo(recordAfter.getFirstLoop()));
assertThat(recordBefore.getNext(), equalTo(recordAfter.getNext()));
assertThat(recordBefore.getOwningNode(), equalTo(recordAfter.getOwningNode()));
assertThat(recordBefore.getPrev(), equalTo(recordAfter.getPrev()));
assertThat(recordBefore.getType(), equalTo(recordAfter.getType()));
}
Aggregations