Search in sources :

Example 1 with RemoveCommand

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

the class PhysicalLogCommandReaderV2_2_4Test method shouldReadNoKeyIdAsMinusOne.

@Test
public void shouldReadNoKeyIdAsMinusOne() throws Exception {
    // GIVEN
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    IndexDefineCommand definitions = new IndexDefineCommand();
    int indexNameId = 10;
    definitions.init(MapUtil.<String, Integer>genericMap("myindex", indexNameId), MapUtil.<String, Integer>genericMap());
    definitions.serialize(channel);
    RemoveCommand removeCommand = new IndexCommand.RemoveCommand();
    removeCommand.init(indexNameId, IndexEntityType.Node.id(), 1234, -1, null);
    removeCommand.serialize(channel);
    // WHEN
    PhysicalLogCommandReaderV2_2_4 reader = new PhysicalLogCommandReaderV2_2_4();
    assertTrue(reader.read(channel) instanceof IndexDefineCommand);
    RemoveCommand readRemoveCommand = (RemoveCommand) reader.read(channel);
    // THEN
    assertEquals(removeCommand.getIndexNameId(), readRemoveCommand.getIndexNameId());
    assertEquals(removeCommand.getEntityType(), readRemoveCommand.getEntityType());
    assertEquals(removeCommand.getEntityId(), readRemoveCommand.getEntityId());
    assertEquals(removeCommand.getKeyId(), readRemoveCommand.getKeyId());
    assertNull(removeCommand.getValue());
}
Also used : RemoveCommand(org.neo4j.kernel.impl.index.IndexCommand.RemoveCommand) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) IndexDefineCommand(org.neo4j.kernel.impl.index.IndexDefineCommand) Test(org.junit.Test)

Example 2 with RemoveCommand

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

the class PhysicalLogCommandReaderV2_2 method visitIndexRemoveCommand.

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

Example 3 with RemoveCommand

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

the class PhysicalLogCommandReaderV2_2_4 method visitIndexRemoveCommand.

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

Example 4 with RemoveCommand

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

the class LegacyIndexTransactionStateImpl method removeNode.

@Override
public void removeNode(String indexName, long id, String keyOrNull, Object valueOrNull) {
    RemoveCommand command = new RemoveCommand();
    command.init(definitions().getOrAssignIndexNameId(indexName), IndexEntityType.Node.id(), id, definitions().getOrAssignKeyId(keyOrNull), valueOrNull);
    addCommand(indexName, command);
}
Also used : RemoveCommand(org.neo4j.kernel.impl.index.IndexCommand.RemoveCommand)

Example 5 with RemoveCommand

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

the class LegacyIndexTransactionStateImpl method removeRelationship.

@Override
public void removeRelationship(String indexName, long id, String keyOrNull, Object valueOrNull) {
    RemoveCommand command = new RemoveCommand();
    command.init(definitions().getOrAssignIndexNameId(indexName), IndexEntityType.Relationship.id(), id, definitions().getOrAssignKeyId(keyOrNull), valueOrNull);
    addCommand(indexName, command);
}
Also used : RemoveCommand(org.neo4j.kernel.impl.index.IndexCommand.RemoveCommand)

Aggregations

RemoveCommand (org.neo4j.kernel.impl.index.IndexCommand.RemoveCommand)8 Test (org.junit.Test)1 IndexDefineCommand (org.neo4j.kernel.impl.index.IndexDefineCommand)1 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)1