use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0_2 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;
}
use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.
the class LegacyIndexTransactionStateImpl method addRelationship.
@Override
public void addRelationship(String indexName, long id, String key, Object value, long startNode, long endNode) {
AddRelationshipCommand command = new AddRelationshipCommand();
command.init(definitions().getOrAssignIndexNameId(indexName), id, definitions().getOrAssignKeyId(key), value, startNode, endNode);
addCommand(indexName, command);
}
use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.
the class PhysicalLogNeoCommandReaderV2Test method shouldProperlyMaskIndexIdFieldInIndexHeader.
@Test
public void shouldProperlyMaskIndexIdFieldInIndexHeader() throws Exception {
/* This is how the index command header is laid out
* [x , ] start node needs long
* [ x , ] end node needs long
* [ xx,xxxx] index name id
* This means that the index name id can be in the range of 0 to 63. This test verifies that
* this constraint is actually respected
*/
// GIVEN
PhysicalLogCommandReaderV2_2_4 reader = new PhysicalLogCommandReaderV2_2_4();
InMemoryClosableChannel data = new InMemoryClosableChannel();
// Here we take advantage of the fact that all index commands have the same header written out
AddRelationshipCommand command = new AddRelationshipCommand();
long entityId = 123;
byte keyId = (byte) 1;
Object value = "test value";
long startNode = 14;
long endNode = 15;
for (byte indexByteId = 0; indexByteId < 63; indexByteId++) {
// WHEN
command.init(indexByteId, entityId, keyId, value, startNode, endNode);
command.serialize(data);
// THEN
AddRelationshipCommand readCommand = (AddRelationshipCommand) reader.read(data);
assertEquals(indexByteId, readCommand.getIndexNameId());
assertEquals(entityId, readCommand.getEntityId());
assertEquals(keyId, readCommand.getKeyId());
assertEquals(value, readCommand.getValue());
assertEquals(startNode, readCommand.getStartNode());
assertEquals(endNode, readCommand.getEndNode());
data.reset();
}
}
use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_2_4 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;
}
use of org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_2 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;
}
Aggregations