private long nodeHighMark() { return read.getHighestPossibleIdInUse(); }
private boolean hasNotEmptyNodesOrRelationshipsStores() { return (nodes.getHighestPossibleIdInUse() != -1) || (relationships.getHighestPossibleIdInUse() != -1); }
@Override public void initialize( CountsAccessor.Updater countsUpdater ) { if ( hasNotEmptyNodesOrRelationshipsStores() ) { progressMonitor.start( nodes.getHighestPossibleIdInUse() + relationships.getHighestPossibleIdInUse() ); populateCountStore( countsUpdater ); } progressMonitor.completed(); }
@Test public void shouldBeAbleToForceStoreScan() throws Exception { when( labelScanStore.newReader() ).thenThrow( new RuntimeException( "Should not be used" ) ); when( nodeStore.getHighestPossibleIdInUse() ).thenReturn( 200L ); when( nodeStore.getHighId() ).thenReturn( 20L ); when( nodeStore.openPageCursorForReading( anyLong() ) ).thenReturn( mock( PageCursor.class ) ); mockLabelNodeCount( countStore, 2 ); mockLabelNodeCount( countStore, 6 ); DynamicIndexStoreView storeView = dynamicIndexStoreView(); StoreScan<Exception> storeScan = storeView .visitNodes( new int[]{2, 6}, propertyKeyIdFilter, propertyUpdateVisitor, labelUpdateVisitor, true ); storeScan.run(); Mockito.verify( nodeStore, times( 1 ) ) .getRecordByCursor( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) ); Mockito.verify( nodeStore, times( 200 ) ) .nextRecordByCursor( any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) ); }
@Test public void visitOnlyLabeledNodes() throws Exception { LabelScanReader labelScanReader = mock( LabelScanReader.class ); when( labelScanStore.newReader() ).thenReturn( labelScanReader ); when( nodeLabelRanges.maxCount() ).thenReturn( 1L ); PrimitiveLongResourceIterator labeledNodesIterator = PrimitiveLongResourceCollections.iterator( null, 1, 2, 3, 4, 5, 6, 7, 8 ); when( nodeStore.getHighestPossibleIdInUse() ).thenReturn( 200L ); when( nodeStore.getHighId() ).thenReturn( 20L ); when( labelScanReader.nodesWithAnyOfLabels( new int[] {2, 6} ) ).thenReturn( labeledNodesIterator ); when( nodeStore.openPageCursorForReading( anyLong() ) ).thenReturn( mock( PageCursor.class ) ); mockLabelNodeCount( countStore, 2 ); mockLabelNodeCount( countStore, 6 ); DynamicIndexStoreView storeView = dynamicIndexStoreView(); StoreScan<Exception> storeScan = storeView .visitNodes( new int[]{2, 6}, propertyKeyIdFilter, propertyUpdateVisitor, labelUpdateVisitor, false ); storeScan.run(); Mockito.verify( nodeStore, times( 8 ) ) .getRecordByCursor( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) ); }
private long nodeHighMark() { return read.getHighestPossibleIdInUse(); }
private boolean hasNotEmptyNodesOrRelationshipsStores() { return (nodes.getHighestPossibleIdInUse() != -1) || (relationships.getHighestPossibleIdInUse() != -1); }
private long nextId(GraphDatabaseService database) { long highestId = ((GraphDatabaseAPI) database).getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores().getNodeStore().getHighestPossibleIdInUse(); long nextId = lastId.incrementAndGet(); if (nextId > highestId) { lastId.set(-1); nextId = lastId.incrementAndGet(); } return nextId; } }
@Override public void initialize( CountsAccessor.Updater countsUpdater ) { if ( hasNotEmptyNodesOrRelationshipsStores() ) { progressMonitor.start( nodes.getHighestPossibleIdInUse() + relationships.getHighestPossibleIdInUse() ); populateCountStore( countsUpdater ); } progressMonitor.completed(); }
/** * Get a random node in O(1), try only 10 attempts. * * @param database in which to find a random node. * @return random node, null if not successful. */ private Node randomNodeO1(GraphDatabaseService database) { long highestId = ((GraphDatabaseAPI) database).getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores().getNodeStore().getHighestPossibleIdInUse(); if (highestId <= 0) { return null; } for (int i = 0; i < MAX_EFFICIENT_ATTEMPTS; i++) { long randomId = random.nextLong(0, highestId); try { Node node = database.getNodeById(randomId); if (inclusionPolicy.include(node)) { return node; } } catch (NotFoundException e) { //ok, try again } } return null; }