Search in sources :

Example 6 with AddRelationshipCommand

use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.

the class PhysicalLogCommandReaderV2_2_10 method visitIndexAddRelationshipCommand.

private Command visitIndexAddRelationshipCommand(ReadableChannel channel) throws IOException {
    IndexCommandHeader header = readIndexCommandHeader(channel);
    Number entityId = header.entityIdNeedsLong ? channel.getLong() : channel.getInt();
    Object value = readIndexValue(header.valueType, channel);
    Number startNode = header.startNodeNeedsLong ? channel.getLong() : channel.getInt();
    Number endNode = header.endNodeNeedsLong ? channel.getLong() : channel.getInt();
    AddRelationshipCommand command = new AddRelationshipCommand();
    command.init(header.indexNameId, entityId.longValue(), header.keyId, value, startNode.longValue(), endNode.longValue());
    return command;
}
Also used : AddRelationshipCommand(org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand)

Example 7 with AddRelationshipCommand

use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0 method visitIndexAddRelationshipCommand.

private Command visitIndexAddRelationshipCommand(ReadableChannel channel) throws IOException {
    IndexCommandHeader header = readIndexCommandHeader(channel);
    Number entityId = header.entityIdNeedsLong ? channel.getLong() : channel.getInt();
    Object value = readIndexValue(header.valueType, channel);
    Number startNode = header.startNodeNeedsLong ? channel.getLong() : channel.getInt();
    Number endNode = header.endNodeNeedsLong ? channel.getLong() : channel.getInt();
    AddRelationshipCommand command = new AddRelationshipCommand();
    command.init(header.indexNameId, entityId.longValue(), header.keyId, value, startNode.longValue(), endNode.longValue());
    return command;
}
Also used : AddRelationshipCommand(org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand)

Example 8 with AddRelationshipCommand

use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.

the class PhysicalLogNeoCommandReaderV2Test method shouldReadIndexCommandHeaderCorrectly.

@Test
public void shouldReadIndexCommandHeaderCorrectly() throws Exception {
    // This bug manifested in header byte[1] {0,1,2}, which contains:
    // [x   ,    ] start node needs long
    // [ x  ,    ] end node needs long
    // [  xx,xxxx] index name id
    // would have the mask for reading "start node needs long" to 0x8, where it should have been 0x80.
    // So we need an index name id which has the 0x8 bit set to falsely read that value as "true".
    // Number 12 will do just fine.
    // GIVEN
    PhysicalLogCommandReaderV2_2_4 reader = new PhysicalLogCommandReaderV2_2_4();
    InMemoryClosableChannel data = new InMemoryClosableChannel();
    AddRelationshipCommand command = new AddRelationshipCommand();
    byte indexNameId = (byte) 12;
    long entityId = 123;
    byte keyId = (byte) 1;
    Object value = "test value";
    long startNode = 14;
    long endNode = 15;
    // WHEN
    command.init(indexNameId, entityId, keyId, value, startNode, endNode);
    command.serialize(data);
    // THEN
    AddRelationshipCommand readCommand = (AddRelationshipCommand) reader.read(data);
    assertEquals(indexNameId, readCommand.getIndexNameId());
    assertEquals(entityId, readCommand.getEntityId());
    assertEquals(keyId, readCommand.getKeyId());
    assertEquals(value, readCommand.getValue());
    assertEquals(startNode, readCommand.getStartNode());
    assertEquals(endNode, readCommand.getEndNode());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) AddRelationshipCommand(org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand) Test(org.junit.Test)

Example 9 with AddRelationshipCommand

use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.

the class LegacyBatchIndexApplierTest method addRelationshipToIndex.

private static AddRelationshipCommand addRelationshipToIndex(IndexDefineCommand definitions, String indexName) {
    AddRelationshipCommand command = new AddRelationshipCommand();
    command.init(definitions.getOrAssignIndexNameId(indexName), 0L, (byte) 0, null, 1, 2);
    return command;
}
Also used : AddRelationshipCommand(org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand)

Aggregations

AddRelationshipCommand (org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand)9 Test (org.junit.Test)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2