@Override public boolean visit( NodeLabelUpdate update ) throws IOException { writer.write( update ); count++; return false; } }
@Override public void close() throws Exception { super.close(); writer.close(); } }
static FullStoreChangeStream asStream( final List<NodeLabelUpdate> existingData ) { return writer -> { long count = 0; for ( NodeLabelUpdate update : existingData ) { writer.write( update ); count++; } return count; }; } }
@Override public void close() throws Exception { super.close(); writer.close(); } }
@Override public void apply( Supplier<LabelScanWriter> labelScanStore ) { labelUpdates.sort( SORT_BY_NODE_ID ); try ( LabelScanWriter writer = labelScanStore.get() ) { for ( NodeLabelUpdate update : labelUpdates ) { writer.write( update ); } } catch ( Exception e ) { throw new UnderlyingStorageException( e ); } } }
private void write( Iterator<NodeLabelUpdate> iterator ) throws IOException { try ( LabelScanWriter writer = store.newWriter() ) { while ( iterator.hasNext() ) { writer.write( iterator.next() ); } } }
private void write( LabelScanStore labelScanStore, Iterable<NodeLabelUpdate> nodeLabelUpdates ) throws IOException { try ( LabelScanWriter writer = labelScanStore.newWriter() ) { for ( NodeLabelUpdate update : nodeLabelUpdates ) { writer.write( update ); } } }
@Override protected void process( NodeRecord[] batch, BatchSender sender ) throws Throwable { for ( NodeRecord node : batch ) { if ( node.inUse() ) { writer.write( labelChanges( node.getId(), EMPTY_LONG_ARRAY, get( node, nodeStore ) ) ); } } sender.send( batch ); }
private void prepareIndex() throws IOException { start(); try ( LabelScanWriter labelScanWriter = store.newWriter() ) { labelScanWriter.write( NodeLabelUpdate.labelChanges( 1, new long[]{}, new long[]{1} ) ); } store.shutdown(); }
private void randomModifications( long[] expected, int count ) throws IOException { BitSet editedNodes = new BitSet(); try ( LabelScanWriter writer = store.newWriter() ) { for ( int i = 0; i < count; i++ ) { int nodeId = random.nextInt( NODE_COUNT ); if ( editedNodes.get( nodeId ) ) { i--; continue; } int changeSize = random.nextInt( 3 ) + 1; long labels = expected[nodeId]; long[] labelsBefore = getLabels( labels ); for ( int j = 0; j < changeSize; j++ ) { labels = flipRandom( labels, LABEL_COUNT, random.random() ); } long[] labelsAfter = getLabels( labels ); editedNodes.set( nodeId ); NodeLabelUpdate labelChanges = labelChanges( nodeId, labelsBefore, labelsAfter ); writer.write( labelChanges ); expected[nodeId] = labels; } } }
private void initializeNativeLabelScanStoreWithContent( DatabaseLayout databaseLayout ) throws IOException { try ( Lifespan lifespan = new Lifespan() ) { NativeLabelScanStore nativeLabelScanStore = getNativeLabelScanStore( databaseLayout, false ); lifespan.add( nativeLabelScanStore ); try ( LabelScanWriter labelScanWriter = nativeLabelScanStore.newWriter() ) { labelScanWriter.write( NodeLabelUpdate.labelChanges( 1, new long[0], new long[]{1} ) ); } nativeLabelScanStore.force( IOLimiter.UNLIMITED ); } }
private static void checkLabelScanStoreAccessible( LabelScanStore labelScanStore ) throws IOException { int labelId = 1; try ( LabelScanWriter labelScanWriter = labelScanStore.newWriter() ) { labelScanWriter.write( NodeLabelUpdate.labelChanges( 1, new long[]{}, new long[]{labelId} ) ); } try ( LabelScanReader labelScanReader = labelScanStore.newReader() ) { assertEquals( 1, labelScanReader.nodesWithLabel( labelId ).next() ); } } }
@Override public boolean visit( NodeLabelUpdate update ) throws IOException { writer.write( update ); count++; return false; } }
static FullStoreChangeStream asStream( final List<NodeLabelUpdate> existingData ) { return writer -> { long count = 0; for ( NodeLabelUpdate update : existingData ) { writer.write( update ); count++; } return count; }; } }
@Override public void apply( Supplier<LabelScanWriter> labelScanStore ) { labelUpdates.sort( SORT_BY_NODE_ID ); try ( LabelScanWriter writer = labelScanStore.get() ) { for ( NodeLabelUpdate update : labelUpdates ) { writer.write( update ); } } catch ( Exception e ) { throw new UnderlyingStorageException( e ); } } }
@Override protected void process( NodeRecord[] batch, BatchSender sender ) throws Throwable { for ( NodeRecord node : batch ) { if ( node.inUse() ) { writer.write( labelChanges( node.getId(), EMPTY_LONG_ARRAY, get( node, nodeStore ) ) ); } } sender.send( batch ); }