public static TransactionRepresentation transactionRepresentation( Command... commands ) { return transactionRepresentation( Arrays.asList( commands ) ); }
private TransactionRepresentation sillyTransaction( int size ) { Collection<StorageCommand> commands = new ArrayList<>( size ); for ( int i = 0; i < size; i++ ) { // The actual data isn't super important commands.add( createNode( i ) ); commands.add( createProperty( i, PropertyType.INT, 0 ) ); } PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation( commands ); tx.setHeader( new byte[0], 0, 0, 0, 0, 0, 0 ); return tx; }
tracker.visitNodeCommand( Commands.createNode( 10, 2, 3 ) ); tracker.visitNodeCommand( Commands.createNode( 20, 4, 5 ) ); tracker.visitRelationshipCommand( Commands.createRelationship( 4, 10, 20, 0 ) ); tracker.visitRelationshipCommand( Commands.createRelationship( 45, 10, 20, 1 ) ); tracker.visitLabelTokenCommand( Commands.createLabelToken( 3, 0 ) ); tracker.visitLabelTokenCommand( Commands.createLabelToken( 5, 1 ) ); tracker.visitPropertyKeyTokenCommand( Commands.createPropertyKeyToken( 3, 0 ) ); tracker.visitPropertyKeyTokenCommand( Commands.createPropertyKeyToken( 5, 1 ) ); tracker.visitRelationshipTypeTokenCommand( Commands.createRelationshipTypeToken( 3, 0 ) ); tracker.visitRelationshipTypeTokenCommand( Commands.createRelationshipTypeToken( 5, 1 ) ); tracker.visitRelationshipGroupCommand( Commands.createRelationshipGroup( 10, 1 ) ); tracker.visitRelationshipGroupCommand( Commands.createRelationshipGroup( 20, 2 ) ); tracker.visitSchemaRuleCommand( Commands.createIndexRule( EMPTY.getProviderDescriptor(), 10, SchemaDescriptorFactory.forLabel( 0, 1 ) ) ); tracker.visitSchemaRuleCommand( Commands.createIndexRule( EMPTY.getProviderDescriptor(), 20, SchemaDescriptorFactory.forLabel( 1, 2 ) ) ); tracker.visitPropertyCommand( Commands.createProperty( 10, PropertyType.STRING, 0, 6, 7 ) ); tracker.visitPropertyCommand( Commands.createProperty( 20, PropertyType.ARRAY, 1, 8, 9 ) );
@Test public void shouldReadSomeCommands() throws Exception { // GIVEN InMemoryClosableChannel channel = new InMemoryClosableChannel(); Commands.createNode( 0 ).serialize( channel ); Commands.createNode( 1 ).serialize( channel ); Commands.createRelationshipTypeToken( 0, 0 ).serialize( channel ); Commands.createRelationship( 0, 0, 1, 0 ).serialize( channel ); Commands.createPropertyKeyToken( 0, 0 ).serialize( channel ); Commands.createProperty( 0, PropertyType.SHORT_STRING, 0 ).serialize( channel ); CommandReader reader = new PhysicalLogCommandReaderV3_0(); // THEN assertTrue( reader.read( channel ) instanceof Command.NodeCommand ); assertTrue( reader.read( channel ) instanceof Command.NodeCommand ); assertTrue( reader.read( channel ) instanceof Command.RelationshipTypeTokenCommand ); assertTrue( reader.read( channel ) instanceof Command.RelationshipCommand ); assertTrue( reader.read( channel ) instanceof Command.PropertyKeyTokenCommand ); assertTrue( reader.read( channel ) instanceof Command.PropertyCommand ); }
.indexProvider( indexProvider ) .build(); storageEngine.apply( tx( singletonList( createIndexRule( DESCRIPTOR, 1, descriptor ) ) ), TransactionApplicationMode.EXTERNAL ); Dependencies dependencies = new Dependencies(); storageEngine.satisfyDependencies( dependencies );
public static NodeCommand createNode( long id, long... dynamicLabelRecordIds ) { NodeRecord record = new NodeRecord( id ); record.setInUse( true ); record.setCreated(); if ( dynamicLabelRecordIds.length > 0 ) { Collection<DynamicRecord> dynamicRecords = dynamicRecords( dynamicLabelRecordIds ); record.setLabelField( DynamicNodeLabels.dynamicPointer( dynamicRecords ), dynamicRecords ); } return new NodeCommand( new NodeRecord( id ), record ); }
public static PropertyCommand createProperty( long id, PropertyType type, int key, long... valueRecordIds ) { PropertyRecord record = new PropertyRecord( id ); record.setInUse( true ); record.setCreated(); PropertyBlock block = new PropertyBlock(); if ( valueRecordIds.length == 0 ) { PropertyStore.encodeValue( block, key, Values.of( 123 ), null, null, true ); } else { PropertyStore.setSingleBlockValue( block, key, type, valueRecordIds[0] ); block.setValueRecords( dynamicRecords( valueRecordIds ) ); } record.addPropertyBlock( block ); return new PropertyCommand( new PropertyRecord( id ), record ); }
private static TransactionToApply tx( Collection<StorageCommand> commands ) { TransactionToApply tx = new TransactionToApply( transactionRepresentation( commands ) ); tx.commitment( NO_COMMITMENT, 0 ); return tx; }