Search in sources :

Example 1 with CommandReader

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);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 2 with CommandReader

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());
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) RecordStorageCommandReaderFactory(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 3 with CommandReader

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()));
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Command(org.neo4j.kernel.impl.transaction.command.Command) PhysicalLogCommandReaderV2_2(org.neo4j.kernel.impl.transaction.command.PhysicalLogCommandReaderV2_2)

Aggregations

InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)3 CommandReader (org.neo4j.storageengine.api.CommandReader)3 Test (org.junit.Test)2 RecordStorageCommandReaderFactory (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageCommandReaderFactory)1 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)1 Command (org.neo4j.kernel.impl.transaction.command.Command)1 PhysicalLogCommandReaderV2_2 (org.neo4j.kernel.impl.transaction.command.PhysicalLogCommandReaderV2_2)1