private IndexDefineCommand definitions() { if ( defineCommand == null ) { defineCommand = new IndexDefineCommand(); } return defineCommand; }
private static IndexDefineCommand definitions( MutableObjectIntMap<String> names, MutableObjectIntMap<String> keys ) { IndexDefineCommand definitions = new IndexDefineCommand(); definitions.init( names, keys ); return definitions; }
private static IndexDefineCommand definitions( MutableObjectIntMap<String> names, MutableObjectIntMap<String> keys ) { IndexDefineCommand definitions = new IndexDefineCommand(); definitions.init( names, keys ); return definitions; } }
private Command visitIndexDefineCommand( ReadableChannel channel ) throws IOException { readIndexCommandHeader( channel ); MutableObjectIntMap<String> indexNames = readMap( channel ); MutableObjectIntMap<String> keys = readMap( channel ); IndexDefineCommand command = new IndexDefineCommand(); command.init( indexNames, keys ); return command; }
private Command visitIndexDefineCommand( ReadableChannel channel ) throws IOException { readIndexCommandHeader( channel ); MutableObjectIntMap<String> indexNames = readMap( channel ); MutableObjectIntMap<String> keys = readMap( channel ); IndexDefineCommand command = new IndexDefineCommand(); command.init( indexNames, keys ); return command; }
private Command visitIndexDefineCommand( ReadableChannel channel ) throws IOException { readIndexCommandHeader( channel ); MutableObjectIntMap<String> indexNames = readMap( channel ); MutableObjectIntMap<String> keys = readMap( channel ); IndexDefineCommand command = new IndexDefineCommand(); command.init( indexNames, keys ); return command; }
private Command visitIndexDefineCommand( ReadableChannel channel ) throws IOException { readIndexCommandHeader( channel ); MutableObjectIntMap<String> indexNames = readMap( channel ); MutableObjectIntMap<String> keys = readMap( channel ); IndexDefineCommand command = new IndexDefineCommand(); command.init( indexNames, keys ); return command; }
private IndexDefineCommand initIndexDefineCommand( int nbrOfEntries ) { IndexDefineCommand command = new IndexDefineCommand(); MutableObjectIntMap<String> indexNames = initMap( nbrOfEntries ); MutableObjectIntMap<String> keys = initMap( nbrOfEntries ); command.init( indexNames, keys ); return command; }
@Test public void shouldFailToWriteIndexDefineCommandIfMapIsLargerThanShort() throws IOException { // GIVEN InMemoryClosableChannel channel = new InMemoryClosableChannel( 1000 ); IndexDefineCommand command = new IndexDefineCommand(); MutableObjectIntMap<String> largeMap = initMap( 0xFFFF + 1 ); command.init( largeMap, largeMap ); // WHEN assertTrue( serialize( channel, command ) ); }
@Test public void nodeIndexDeletionRemovesCommands() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); state.addNode( "index", 1, "key", "value1" ); state.addNode( "index", 2, "key", "value2" ); state.removeNode( "index", 3, "key", "value3" ); state.deleteIndex( IndexEntityType.Node, "index" ); IndexDefineCommand indexDefinedCommand = new IndexDefineCommand(); indexDefinedCommand.getOrAssignIndexNameId( "index" ); indexDefinedCommand.getOrAssignKeyId( "key" ); IndexCommand.DeleteCommand delete = new IndexCommand.DeleteCommand(); delete.init( 1, IndexEntityType.Node.id() ); Set<Command> expectedCommands = new HashSet<>( Arrays.asList( indexDefinedCommand, delete ) ); assertEquals( expectedCommands, extractCommands( state ) ); }
@Test public void relationshipIndexDeletionRemovesCommands() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); state.removeRelationship( "index", 1, "key", "value1" ); state.addRelationship( "index", 2, "key", "value2", 11, 11 ); state.addRelationship( "index", 3, "key", "value3", 22, 22 ); 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 ) ); assertEquals( expectedCommands, extractCommands( state ) ); }
@Test public void removalOfRelationshipIndexDoesNotClearNodeCommandsForNodeIndexWithSameName() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); 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 ) ); }
@Test public void removalOfNodeIndexDoesNotClearRelationshipCommandsForRelationshipIndexWithSameName() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); state.addNode( "index", 1, "key", "value" ); state.addRelationship( "index", 1, "key", "value", 11, 11 ); state.deleteIndex( IndexEntityType.Node, "index" ); IndexDefineCommand indexDefinedCommand = new IndexDefineCommand(); indexDefinedCommand.getOrAssignIndexNameId( "index" ); indexDefinedCommand.getOrAssignKeyId( "key" ); IndexCommand.DeleteCommand delete = new IndexCommand.DeleteCommand(); delete.init( 1, IndexEntityType.Node.id() ); Set<Command> expectedCommands = new HashSet<>( Arrays.asList( indexDefinedCommand, delete, addRelationship( 1, 1, 1, "value", 11, 11 ) ) ); assertEquals( expectedCommands, extractCommands( state ) ); }
IndexDefineCommand idc = new IndexDefineCommand(); int count = IndexDefineCommand.HIGHEST_POSSIBLE_ID;
@Test public void tracksRelationshipCommands() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); state.removeRelationship( "index1", 1, "key1", "value1" ); state.addRelationship( "index1", 1, "key2", "value2", 11, 11 ); state.removeRelationship( "index1", 2, "key1", "value3" ); state.addRelationship( "index1", 3, "key2", "value4", 22, 22 ); state.addRelationship( "index2", 4, "key1", "value5", 33, 33 ); IndexDefineCommand indexDefinedCommand = new IndexDefineCommand(); indexDefinedCommand.getOrAssignIndexNameId( "index1" ); indexDefinedCommand.getOrAssignIndexNameId( "index2" ); indexDefinedCommand.getOrAssignKeyId( "key1" ); indexDefinedCommand.getOrAssignKeyId( "key2" ); Set<Command> expectedCommands = new HashSet<>( Arrays.asList( indexDefinedCommand, removeRelationship( 1, 1, 1, "value1" ), addRelationship( 1, 1, 2, "value2", 11, 11 ), removeRelationship( 1, 2, 1, "value3" ), addRelationship( 1, 3, 2, "value4", 22, 22 ), addRelationship( 2, 4, 1, "value5", 33, 33 ) ) ); assertEquals( expectedCommands, extractCommands( state ) ); }
@Test public void tracksNodeCommands() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); state.addNode( "index1", 1, "key1", "value1" ); state.removeNode( "index1", 1, "key2", "value2" ); state.addNode( "index1", 2, "key1", "value3" ); state.addNode( "index1", 3, "key2", "value4" ); state.removeNode( "index2", 4, "key1", "value5" ); IndexDefineCommand indexDefinedCommand = new IndexDefineCommand(); indexDefinedCommand.getOrAssignIndexNameId( "index1" ); indexDefinedCommand.getOrAssignIndexNameId( "index2" ); indexDefinedCommand.getOrAssignKeyId( "key1" ); indexDefinedCommand.getOrAssignKeyId( "key2" ); Set<Command> expectedCommands = new HashSet<>( Arrays.asList( indexDefinedCommand, addNode( 1, 1, 1, "value1" ), removeNode( 1, 1, 2, "value2" ), addNode( 1, 2, 1, "value3" ), addNode( 1, 3, 2, "value4" ), removeNode( 2, 4, 1, "value5" ) ) ); assertEquals( expectedCommands, extractCommands( state ) ); }
@Test public void shouldReadNoKeyIdAsMinusOne() throws Exception { // GIVEN InMemoryClosableChannel channel = new InMemoryClosableChannel(); IndexDefineCommand definitions = new IndexDefineCommand(); int indexNameId = 10; definitions.init( ObjectIntHashMap.newWithKeysValues( "myindex", indexNameId ), new ObjectIntHashMap<>() ); 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() ); } }
private IndexDefineCommand definitions() { if ( defineCommand == null ) { defineCommand = new IndexDefineCommand(); } return defineCommand; }
private Command visitIndexDefineCommand( ReadableChannel channel ) throws IOException { readIndexCommandHeader( channel ); MutableObjectIntMap<String> indexNames = readMap( channel ); MutableObjectIntMap<String> keys = readMap( channel ); IndexDefineCommand command = new IndexDefineCommand(); command.init( indexNames, keys ); return command; }
private Command visitIndexDefineCommand( ReadableChannel channel ) throws IOException { readIndexCommandHeader( channel ); MutableObjectIntMap<String> indexNames = readMap( channel ); MutableObjectIntMap<String> keys = readMap( channel ); IndexDefineCommand command = new IndexDefineCommand(); command.init( indexNames, keys ); return command; }