private void send() { totalProcessingTime.add( nanoTime() - time ); sendDownstream( iterator( batch ) ); time = nanoTime(); assertHealthy(); highId = batch[cursor - 1]; }
public static PrimitiveLongResourceIterator iterator( Resource resource, final long... items ) { return resourceIterator( PrimitiveLongCollections.iterator( items ), resource ); }
@Override public Iterable<Label> getNodeLabels( final long node ) { return () -> { NodeRecord record = getNodeRecord( node ).forReadingData(); long[] labels = parseLabelsField( record ).get( nodeStore ); return map( labelIdToLabelFunction, PrimitiveLongCollections.iterator( labels ) ); }; }
@Test void arrayOfItemsAsIterator() { // GIVEN long[] items = new long[] { 2, 5, 234 }; // WHEN LongIterator iterator = PrimitiveLongCollections.iterator( items ); // THEN assertItems( iterator, items ); }
@Test void asArray() { // GIVEN LongIterator items = PrimitiveLongCollections.iterator( 1, 2, 3 ); // WHEN long[] array = PrimitiveLongCollections.asArray( items ); // THEN assertTrue( Arrays.equals( new long[] { 1, 2, 3 }, array ) ); }
@Test void filter() { // GIVEN LongIterator items = PrimitiveLongCollections.iterator( 1, 2, 3 ); // WHEN LongIterator filtered = PrimitiveLongCollections.filter( items, item -> item != 2 ); // THEN assertItems( filtered, 1, 3 ); }
@Test void count() { // GIVEN LongIterator items = PrimitiveLongCollections.iterator( 1, 2, 3 ); // WHEN int count = PrimitiveLongCollections.count( items ); // THEN assertEquals( 3, count ); }
@Test void indexOf() { // GIVEN Supplier<LongIterator> items = () -> PrimitiveLongCollections.iterator( 10, 20, 30 ); // THEN assertEquals( -1, PrimitiveLongCollections.indexOf( items.get(), 55 ) ); assertEquals( 0, PrimitiveLongCollections.indexOf( items.get(), 10 ) ); assertEquals( 1, PrimitiveLongCollections.indexOf( items.get(), 20 ) ); assertEquals( 2, PrimitiveLongCollections.indexOf( items.get(), 30 ) ); }
@Test public void appendSourceElementsDuringIteration() { LongIterator source = iterator( 4L, 5L ); LongSet added = LongHashSet.newSetWith( 1L, 2L ); LongSet removed = LongHashSet.newSetWith( 3L ); LongIterator iterator = DiffApplyingPrimitiveLongIterator.augment( source, added, removed ); Set<Long> resultSet = toSet( iterator ); assertThat( resultSet, containsInAnyOrder(1L, 2L, 4L, 5L) ); }
@Test public void doNotIterateOverDeletedElement() { LongIterator source = iterator( 3L, 5L ); LongSet added = LongHashSet.newSetWith( 1L ); LongSet removed = LongHashSet.newSetWith( 3L ); LongIterator iterator = DiffApplyingPrimitiveLongIterator.augment( source, added, removed ); Set<Long> resultSet = toSet( iterator ); assertThat( resultSet, containsInAnyOrder(1L, 5L) ); }
@Test public void shouldThrowOnIndexEntryConflict() throws Exception { // given IndexUpdater actual = mock( IndexUpdater.class ); IndexReader reader = mock( IndexReader.class ); when( reader.query( anyVararg() ) ).thenAnswer( invocation -> iterator( 101, 202 ) ); DeferredConflictCheckingIndexUpdater updater = new DeferredConflictCheckingIndexUpdater( actual, () -> reader, descriptor ); // when updater.process( add( 0, descriptor, tuple( 10, 11 ) ) ); try { updater.close(); fail( "Should have failed" ); } catch ( IndexEntryConflictException e ) { // then good assertThat( e.getMessage(), containsString( "101" ) ); assertThat( e.getMessage(), containsString( "202" ) ); } }
when( reader.query( anyVararg() ) ).thenAnswer( invocation -> iterator( 0 ) ); long nodeId = 0; List<IndexEntryUpdate<IndexDescriptor>> updates = new ArrayList<>();
@Test public void augmentDiffSetWithExternalElements() { MutableLongDiffSets diffSet = createDiffSet(); diffSet.addAll( newSetWith( 9L, 10L, 11L ) ); diffSet.removeAll( newSetWith( 1L, 2L ) ); LongIterator augmentedIterator = diffSet.augment( iterator( 5L, 6L ) ); assertEquals( asSet( 5L, 6L, 9L, 10L, 11L ), toSet( augmentedIterator ) ); }
@Test public void doNotIterateTwiceOverSameElementsWhenItsPartOfSourceAndAdded() { LongIterator source = iterator( 4L, 5L ); LongSet added = LongHashSet.newSetWith( 1L, 4L ); LongSet removed = LongHashSet.newSetWith( 3L ); LongIterator iterator = DiffApplyingPrimitiveLongIterator.augment( source, added, removed ); Long[] values = ArrayUtils.toObject( asArray( iterator ) ); assertThat( values, arrayContainingInAnyOrder( 1L, 4L, 5L ) ); assertThat( values, arrayWithSize( 3 ) ); }
SimpleStageControl control = new SimpleStageControl(); try ( DeleteDuplicateNodesStep step = new DeleteDuplicateNodesStep( control, Configuration.DEFAULT, PrimitiveLongCollections.iterator( duplicateNodeIds ), neoStores.getNodeStore(), neoStores.getPropertyStore(), monitor ) )
private void send() { totalProcessingTime.add( nanoTime() - time ); sendDownstream( iterator( batch ) ); time = nanoTime(); assertHealthy(); highId = batch[cursor - 1]; }
public static PrimitiveLongResourceIterator iterator( Resource resource, final long... items ) { return resourceIterator( PrimitiveLongCollections.iterator( items ), resource ); }
@Override public Iterable<Label> getNodeLabels( final long node ) { return () -> { NodeRecord record = getNodeRecord( node ).forReadingData(); long[] labels = parseLabelsField( record ).get( nodeStore ); return map( labelIdToLabelFunction, PrimitiveLongCollections.iterator( labels ) ); }; }