int afterLength = update.getLabelsAfter().length; long[] after = update.getLabelsAfter(); for ( int bi = 0, ai = 0; bi < beforeLength || ai < afterLength; ) update.getLabelsAfter()[ac++] = afterId; ai++; afterId = ai < afterLength ? after[ai] : -1; terminateWithMinusOneIfNeeded( update.getLabelsAfter(), ac );
/** * Queues a {@link NodeLabelUpdate} to this writer for applying when batch gets full, * or when {@link #close() closing}. */ @Override public void write( NodeLabelUpdate update ) throws IOException { if ( pendingUpdatesCursor == pendingUpdates.length ) { flushPendingChanges(); } pendingUpdates[pendingUpdatesCursor++] = update; PhysicalToLogicalLabelChanges.convertToAdditionsAndRemovals( update ); checkNextLabelId( update.getLabelsBefore() ); checkNextLabelId( update.getLabelsAfter() ); }
private void flushPendingChanges() throws IOException { Arrays.sort( pendingUpdates, 0, pendingUpdatesCursor, UPDATE_SORTER ); monitor.flushPendingUpdates(); long currentLabelId = lowestLabelId; value.clear(); key.clear(); while ( currentLabelId != Long.MAX_VALUE ) { long nextLabelId = Long.MAX_VALUE; for ( int i = 0; i < pendingUpdatesCursor; i++ ) { NodeLabelUpdate update = pendingUpdates[i]; long nodeId = update.getNodeId(); nextLabelId = extractChange( update.getLabelsAfter(), currentLabelId, nodeId, nextLabelId, true, update.getTxId() ); nextLabelId = extractChange( update.getLabelsBefore(), currentLabelId, nodeId, nextLabelId, false, update.getTxId() ); } currentLabelId = nextLabelId; } flushPendingRange(); pendingUpdatesCursor = 0; }
private void convertAndAssert( long[] before, long[] after, long[] expectedRemoved, long[] expectedAdded ) { NodeLabelUpdate update = NodeLabelUpdate.labelChanges( 0, before, after ); PhysicalToLogicalLabelChanges.convertToAdditionsAndRemovals( update ); assertArrayEquals( terminate( update.getLabelsBefore() ), expectedRemoved ); assertArrayEquals( terminate( update.getLabelsAfter() ), expectedAdded ); }
int afterLength = update.getLabelsAfter().length; long[] after = update.getLabelsAfter(); for ( int bi = 0, ai = 0; bi < beforeLength || ai < afterLength; ) update.getLabelsAfter()[ac++] = afterId; ai++; afterId = ai < afterLength ? after[ai] : -1; terminateWithMinusOneIfNeeded( update.getLabelsAfter(), ac );
/** * Queues a {@link NodeLabelUpdate} to this writer for applying when batch gets full, * or when {@link #close() closing}. */ @Override public void write( NodeLabelUpdate update ) throws IOException { if ( pendingUpdatesCursor == pendingUpdates.length ) { flushPendingChanges(); } pendingUpdates[pendingUpdatesCursor++] = update; PhysicalToLogicalLabelChanges.convertToAdditionsAndRemovals( update ); checkNextLabelId( update.getLabelsBefore() ); checkNextLabelId( update.getLabelsAfter() ); }
private void flushPendingChanges() throws IOException { Arrays.sort( pendingUpdates, 0, pendingUpdatesCursor, UPDATE_SORTER ); monitor.flushPendingUpdates(); long currentLabelId = lowestLabelId; value.clear(); key.clear(); while ( currentLabelId != Long.MAX_VALUE ) { long nextLabelId = Long.MAX_VALUE; for ( int i = 0; i < pendingUpdatesCursor; i++ ) { NodeLabelUpdate update = pendingUpdates[i]; long nodeId = update.getNodeId(); nextLabelId = extractChange( update.getLabelsAfter(), currentLabelId, nodeId, nextLabelId, true, update.getTxId() ); nextLabelId = extractChange( update.getLabelsBefore(), currentLabelId, nodeId, nextLabelId, false, update.getTxId() ); } currentLabelId = nextLabelId; } flushPendingRange(); pendingUpdatesCursor = 0; }