recordChangeSet.getPropertyRecords().changes() ) propCommands[i++] = new Command.PropertyCommand( change.getBefore(), prepared( change, propertyStore ) );
@Test public void shouldCreateProperBeforeAndAfterPropertyCommandsWhenAddingProperty() throws Exception { // GIVEN NeoStores neoStores = neoStoresRule.builder().build(); TransactionRecordState recordState = newTransactionRecordState( neoStores ); int nodeId = 1; recordState.nodeCreate( nodeId ); // WHEN recordState.nodeAddProperty( nodeId, propertyId1, value1 ); Collection<StorageCommand> commands = new ArrayList<>(); recordState.extractCommands( commands ); PropertyCommand propertyCommand = singlePropertyCommand( commands ); // THEN PropertyRecord before = propertyCommand.getBefore(); assertFalse( before.inUse() ); assertFalse( before.iterator().hasNext() ); PropertyRecord after = propertyCommand.getAfter(); assertTrue( after.inUse() ); assertEquals( 1, count( after ) ); }
@Test public void testVisitPropertyCommand() throws Exception { Command.PropertyCommand cmd = mock( Command.PropertyCommand.class ); when( cmd.handle( any( CommandVisitor.class ) ) ).thenCallRealMethod(); // WHEN boolean result = facade.visitPropertyCommand( cmd ); // THEN InOrder inOrder = inOrder( txApplier1, txApplier2, txApplier3 ); inOrder.verify( txApplier1 ).visitPropertyCommand( cmd ); inOrder.verify( txApplier2 ).visitPropertyCommand( cmd ); inOrder.verify( txApplier3 ).visitPropertyCommand( cmd ); inOrder.verifyNoMoreInteractions(); assertFalse( result ); }
recordChangeSet.getPropertyRecords().changes() ) propCommands[i++] = new Command.PropertyCommand( change.getBefore(), prepared( change, propertyStore ) );
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
@Override public boolean visitPropertyCommand( PropertyCommand command ) { PropertyStore propertyStore = neoStores.getPropertyStore(); track( propertyStore, command ); for ( PropertyBlock block : command.getAfter() ) { switch ( block.getType() ) { case STRING: track( propertyStore.getStringStore(), block.getValueRecords() ); break; case ARRAY: track( propertyStore.getArrayStore(), block.getValueRecords() ); break; default: // Not needed, no dynamic records then break; } } return false; }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
@Override public boolean visitPropertyCommand( Command.PropertyCommand command ) { // acquire lock if ( command.getNodeId() != -1 ) { lockGroup.add( lockService.acquireNodeLock( command.getNodeId(), LockService.LockType.WRITE_LOCK ) ); } else if ( command.getRelId() != -1 ) { lockGroup.add( lockService.acquireRelationshipLock( command.getRelId(), LockService.LockType.WRITE_LOCK ) ); } updateStore( neoStores.getPropertyStore(), command ); return false; }
@Override public boolean visitPropertyCommand( PropertyCommand command ) { if ( command.getAfter().isNodeSet() ) { createOrAddToGroup( command, command.getAfter().getNodeId(), propertyCommandsByNodeIds ); } else if ( command.getAfter().isRelSet() ) { createOrAddToGroup( command, command.getAfter().getRelId(), propertyCommandsByRelationshipIds ); } return false; }
public void add( PropertyRecord before, PropertyRecord property ) { Command.PropertyCommand command = new Command.PropertyCommand(); command.init( before, property ); addCommand( command ); }
nodePropertyBlocks.setNodeId( nodeId ); Command.PropertyCommand nodePropertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( nodePropertyId ).forReadingData(), nodePropertyBlocks ); relationshipPropertyBlocks.setRelId( relId ); Command.PropertyCommand relationshipPropertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), relationshipPropertyBlocks );
PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setRelId( relId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); Command.PropertyCommand propertyCommand2 = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId2 ).forReadingData(), propertyBlocks2 );
@Test public void shouldContainFedRelationshipUpdate() throws Exception { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( nodeStore, relationshipStore, indexingService, propertyPhysicalToLogicalConverter ); long relId = 0; RelationshipRecord inUse = getRelationship( relId, true, ENTITY_TOKEN ); Value propertyValue = Values.of( "hej" ); long propertyId = createRelationshipProperty( inUse, propertyValue, 1 ); RelationshipRecord notInUse = getRelationship( relId, false, ENTITY_TOKEN ); relationshipStore.updateRecord( inUse ); Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand( inUse, notInUse ); PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setRelId( relId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); StoreIndexDescriptor indexDescriptor = forSchema( multiToken( ENTITY_TOKENS, RELATIONSHIP, 1, 4, 6 ), EMPTY.getProviderDescriptor() ).withId( 0 ); indexingService.createIndexes( indexDescriptor ); indexingService.getIndexProxy( indexDescriptor.schema() ).awaitStoreScanCompleted(); onlineIndexUpdates.feed( LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, singletonList( propertyCommand ) ), LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, relationshipCommand ) ); assertTrue( onlineIndexUpdates.hasUpdates() ); Iterator<IndexEntryUpdate<SchemaDescriptor>> iterator = onlineIndexUpdates.iterator(); assertEquals( iterator.next(), IndexEntryUpdate.remove( relId, indexDescriptor, propertyValue, null, null ) ); assertFalse( iterator.hasNext() ); }
@Test public void shouldContainFedNodeUpdate() throws Exception { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( nodeStore, relationshipStore, indexingService, propertyPhysicalToLogicalConverter ); int nodeId = 0; NodeRecord inUse = getNode( nodeId, true ); Value propertyValue = Values.of( "hej" ); long propertyId = createNodeProperty( inUse, propertyValue, 1 ); NodeRecord notInUse = getNode( nodeId, false ); nodeStore.updateRecord( inUse ); Command.NodeCommand nodeCommand = new Command.NodeCommand( inUse, notInUse ); PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setNodeId( nodeId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); StoreIndexDescriptor indexDescriptor = forSchema( multiToken( ENTITY_TOKENS, NODE, 1, 4, 6 ), EMPTY.getProviderDescriptor() ).withId( 0 ); indexingService.createIndexes( indexDescriptor ); indexingService.getIndexProxy( indexDescriptor.schema() ).awaitStoreScanCompleted(); onlineIndexUpdates.feed( LongObjectMaps.immutable.of( nodeId, singletonList( propertyCommand ) ), LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( nodeId, nodeCommand ), LongObjectMaps.immutable.empty() ); assertTrue( onlineIndexUpdates.hasUpdates() ); Iterator<IndexEntryUpdate<SchemaDescriptor>> iterator = onlineIndexUpdates.iterator(); assertEquals( iterator.next(), IndexEntryUpdate.remove( nodeId, indexDescriptor, propertyValue, null, null ) ); assertFalse( iterator.hasNext() ); }
@Override public boolean visitPropertyCommand( PropertyCommand command ) { PropertyStore propertyStore = neoStores.getPropertyStore(); track( propertyStore, command ); for ( PropertyBlock block : command.getAfter() ) { switch ( block.getType() ) { case STRING: track( propertyStore.getStringStore(), block.getValueRecords() ); break; case ARRAY: track( propertyStore.getArrayStore(), block.getValueRecords() ); break; default: // Not needed, no dynamic records then break; } } return false; }
@Test public void readPropertyCommandWithFixedReferenceFormat302() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); assertTrue( neoStoreCommand.getBefore().isUseFixedReferences() ); assertTrue( neoStoreCommand.getAfter().isUseFixedReferences() ); }
@Test public void readPropertyCommandWithFixedReferenceFormat300() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); assertTrue( neoStoreCommand.getBefore().isUseFixedReferences() ); assertTrue( neoStoreCommand.getAfter().isUseFixedReferences() ); }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }