Search in sources :

Example 6 with IndexDefineCommand

use of org.neo4j.kernel.impl.index.IndexDefineCommand in project neo4j by neo4j.

the class LegacyIndexTransactionStateImplTest method removalOfRelationshipIndexDoesNotClearNodeCommandsForNodeIndexWithSameName.

@Test
public void removalOfRelationshipIndexDoesNotClearNodeCommandsForNodeIndexWithSameName() {
    LegacyIndexTransactionStateImpl state = newLegacyIndexTxState();
    state.addNode("index", 1, "key", "value");
    state.addRelationship("index", 1, "key", "value", 11, 11);
    state.deleteIndex(IndexEntityType.Relationship, "index");
    IndexDefineCommand indexDefinedCommand = new IndexDefineCommand();
    indexDefinedCommand.getOrAssignIndexNameId("index");
    indexDefinedCommand.getOrAssignKeyId("key");
    IndexCommand.DeleteCommand delete = new IndexCommand.DeleteCommand();
    delete.init(1, IndexEntityType.Relationship.id());
    Set<Command> expectedCommands = new HashSet<>(Arrays.asList(indexDefinedCommand, delete, addNode(1, 1, 1, "value")));
    assertEquals(expectedCommands, extractCommands(state));
}
Also used : IndexCommand(org.neo4j.kernel.impl.index.IndexCommand) IndexDefineCommand(org.neo4j.kernel.impl.index.IndexDefineCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) Command(org.neo4j.kernel.impl.transaction.command.Command) IndexCommand(org.neo4j.kernel.impl.index.IndexCommand) IndexDefineCommand(org.neo4j.kernel.impl.index.IndexDefineCommand) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with IndexDefineCommand

use of org.neo4j.kernel.impl.index.IndexDefineCommand 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 8 with IndexDefineCommand

use of org.neo4j.kernel.impl.index.IndexDefineCommand in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0_2 method visitIndexDefineCommand.

private Command visitIndexDefineCommand(ReadableChannel channel) throws IOException {
    readIndexCommandHeader(channel);
    Map<String, Integer> indexNames = readMap(channel);
    Map<String, Integer> keys = readMap(channel);
    IndexDefineCommand command = new IndexDefineCommand();
    command.init(indexNames, keys);
    return command;
}
Also used : IndexDefineCommand(org.neo4j.kernel.impl.index.IndexDefineCommand) IoPrimitiveUtils.read3bLengthAndString(org.neo4j.kernel.impl.util.IoPrimitiveUtils.read3bLengthAndString) IoPrimitiveUtils.read2bLengthAndString(org.neo4j.kernel.impl.util.IoPrimitiveUtils.read2bLengthAndString)

Example 9 with IndexDefineCommand

use of org.neo4j.kernel.impl.index.IndexDefineCommand in project neo4j by neo4j.

the class PhysicalLogCommandReaderV2_2 method visitIndexDefineCommand.

private Command visitIndexDefineCommand(ReadableChannel channel) throws IOException {
    readIndexCommandHeader(channel);
    Map<String, Integer> indexNames = readMap(channel);
    Map<String, Integer> keys = readMap(channel);
    IndexDefineCommand command = new IndexDefineCommand();
    command.init(indexNames, keys);
    return command;
}
Also used : IndexDefineCommand(org.neo4j.kernel.impl.index.IndexDefineCommand) IoPrimitiveUtils.read3bLengthAndString(org.neo4j.kernel.impl.util.IoPrimitiveUtils.read3bLengthAndString) IoPrimitiveUtils.read2bLengthAndString(org.neo4j.kernel.impl.util.IoPrimitiveUtils.read2bLengthAndString)

Example 10 with IndexDefineCommand

use of org.neo4j.kernel.impl.index.IndexDefineCommand in project neo4j by neo4j.

the class PhysicalLogCommandReaderV2_2_10 method visitIndexDefineCommand.

private Command visitIndexDefineCommand(ReadableChannel channel) throws IOException {
    readIndexCommandHeader(channel);
    Map<String, Integer> indexNames = readMap(channel);
    Map<String, Integer> keys = readMap(channel);
    IndexDefineCommand command = new IndexDefineCommand();
    command.init(indexNames, keys);
    return command;
}
Also used : IndexDefineCommand(org.neo4j.kernel.impl.index.IndexDefineCommand) IoPrimitiveUtils.read3bLengthAndString(org.neo4j.kernel.impl.util.IoPrimitiveUtils.read3bLengthAndString) IoPrimitiveUtils.read2bLengthAndString(org.neo4j.kernel.impl.util.IoPrimitiveUtils.read2bLengthAndString)

Aggregations

IndexDefineCommand (org.neo4j.kernel.impl.index.IndexDefineCommand)18 Test (org.junit.Test)11 StorageCommand (org.neo4j.storageengine.api.StorageCommand)7 HashSet (java.util.HashSet)6 IndexCommand (org.neo4j.kernel.impl.index.IndexCommand)6 Command (org.neo4j.kernel.impl.transaction.command.Command)6 IoPrimitiveUtils.read2bLengthAndString (org.neo4j.kernel.impl.util.IoPrimitiveUtils.read2bLengthAndString)5 IoPrimitiveUtils.read3bLengthAndString (org.neo4j.kernel.impl.util.IoPrimitiveUtils.read3bLengthAndString)5 IndexConfigStore (org.neo4j.kernel.impl.index.IndexConfigStore)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors.newCachedThreadPool (java.util.concurrent.Executors.newCachedThreadPool)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 After (org.junit.After)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1