Search in sources :

Example 11 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0Test method readRelationshipCommandWithSecondaryUnit.

@Test
public void readRelationshipCommandWithSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    RelationshipRecord before = new RelationshipRecord(42, true, 1, 2, 3, 4, 5, 6, 7, true, true);
    before.setRequiresSecondaryUnit(true);
    before.setSecondaryUnitId(47);
    RelationshipRecord after = new RelationshipRecord(42, true, 1, 8, 3, 4, 5, 6, 7, true, true);
    new Command.RelationshipCommand(before, after).serialize(channel);
    PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
    Command command = reader.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());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.Test)

Example 12 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel 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 13 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0Test method shouldReadNeoStoreCommand.

@Test
public void shouldReadNeoStoreCommand() throws Throwable {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    NeoStoreRecord before = new NeoStoreRecord();
    NeoStoreRecord after = new NeoStoreRecord();
    after.setNextProp(42);
    new Command.NeoStoreCommand(before, after).serialize(channel);
    // When
    PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
    Command command = reader.read(channel);
    assertTrue(command instanceof Command.NeoStoreCommand);
    Command.NeoStoreCommand neoStoreCommand = (Command.NeoStoreCommand) command;
    // Then
    assertEquals(before.getNextProp(), neoStoreCommand.getBefore().getNextProp());
    assertEquals(after.getNextProp(), neoStoreCommand.getAfter().getNextProp());
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 14 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0Test method readPropertyCommandWithSecondaryUnit.

@Test
public void readPropertyCommandWithSecondaryUnit() throws IOException {
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyRecord before = new PropertyRecord(1);
    PropertyRecord after = new PropertyRecord(2);
    after.setRequiresSecondaryUnit(true);
    after.setSecondaryUnitId(78);
    new Command.PropertyCommand(before, after).serialize(channel);
    PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0();
    Command command = reader.read(channel);
    assertTrue(command instanceof Command.PropertyCommand);
    Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command;
    // Then
    assertEquals(before.getNextProp(), neoStoreCommand.getBefore().getNextProp());
    assertEquals(after.getNextProp(), neoStoreCommand.getAfter().getNextProp());
    verifySecondaryUnit(after, neoStoreCommand.getAfter());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Example 15 with InMemoryClosableChannel

use of org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel 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());
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.Test)

Aggregations

InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)66 Test (org.junit.Test)63 Command (org.neo4j.kernel.impl.transaction.command.Command)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)5 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)4 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)3 CommandReader (org.neo4j.storageengine.api.CommandReader)3 Before (org.junit.Before)2 AddRelationshipCommand (org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand)2 CountsKey (org.neo4j.kernel.impl.store.counts.keys.CountsKey)2 SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)2 SchemaRuleCommand (org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand)2 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)1 EndOfStreamException (org.neo4j.causalclustering.messaging.EndOfStreamException)1