@Test void count() { // GIVEN LongIterator items = PrimitiveLongCollections.iterator( 1, 2, 3 ); // WHEN int count = PrimitiveLongCollections.count( items ); // THEN assertEquals( 3, count ); }
@Test public void shouldHandleLargeAmountsOfDuplicateNodeIds() { // GIVEN IdMapper mapper = mapper( new LongEncoder(), Radix.LONG, NO_MONITOR ); long nodeId = 0; int high = 10; // a list of input ids List<Object> ids = new ArrayList<>(); for ( int run = 0; run < 2; run++ ) { for ( long i = 0; i < high / 2; i++ ) { ids.add( high - (i + 1) ); ids.add( i ); } } // fed to the IdMapper for ( Object inputId : ids ) { mapper.put( inputId, nodeId++, GLOBAL ); } // WHEN Collector collector = mock( Collector.class ); mapper.prepare( values( ids.toArray() ), collector, NONE ); // THEN verify( collector, times( high ) ).collectDuplicateNode( any( Object.class ), anyLong(), anyString() ); assertEquals( high, count( mapper.leftOverDuplicateNodesIds() ) ); }
private void assertNoContentInNativeLabelScanStore( DatabaseLayout databaseLayout ) { try ( Lifespan lifespan = new Lifespan() ) { NativeLabelScanStore nativeLabelScanStore = getNativeLabelScanStore( databaseLayout, true ); lifespan.add( nativeLabelScanStore ); try ( LabelScanReader labelScanReader = nativeLabelScanStore.newReader() ) { int count = PrimitiveLongCollections.count( labelScanReader.nodesWithLabel( 1 ) ); assertEquals( 0, count ); } } }
@Test public void populateNativeLabelScanIndexDuringMigration() throws IOException { prepare34DatabaseWithNodes(); indexMigrator.migrate( databaseLayout, migrationLayout, progressReporter, StandardV3_4.STORE_VERSION, StandardV3_4.STORE_VERSION ); indexMigrator.moveMigratedFiles( migrationLayout, databaseLayout, StandardV2_3.STORE_VERSION, StandardV3_2.STORE_VERSION ); try ( Lifespan lifespan = new Lifespan() ) { NativeLabelScanStore labelScanStore = getNativeLabelScanStore( databaseLayout, true ); lifespan.add( labelScanStore ); for ( int labelId = 0; labelId < 10; labelId++ ) { try ( LabelScanReader labelScanReader = labelScanStore.newReader() ) { int nodeCount = PrimitiveLongCollections.count( labelScanReader.nodesWithLabel( labelId ) ); assertEquals( format( "Expected to see only one node for label %d but was %d.", labelId, nodeCount ), 1, nodeCount ); } } } }