@Override public void close() { labelScanReader.close(); }
private void closeSchemaResources() { if ( indexReaderFactory != null ) { indexReaderFactory.close(); // we can actually keep this object around } if ( labelScanReader != null ) { labelScanReader.close(); labelScanReader = null; } }
@Test public void shouldCloseOpenedLabelScanReader() { // given Supplier<LabelScanReader> scanStore = mock( Supplier.class ); LabelScanReader scanReader = mock( LabelScanReader.class ); when( scanStore.get() ).thenReturn( scanReader ); RecordStorageReader statement = new RecordStorageReader( null, null, MockedNeoStores.basicMockedNeoStores(), null, null, mock( Supplier.class ), scanStore, mock( RecordStorageCommandCreationContext.class ) ); statement.acquire(); // when LabelScanReader actualReader = statement.getLabelScanReader(); // then assertEquals( scanReader, actualReader ); // when statement.close(); // then verify( scanStore ).get(); verifyNoMoreInteractions( scanStore ); verify( scanReader ).close(); verifyNoMoreInteractions( scanReader ); } }
@Test public void shouldFindDecentAmountOfNodesForALabel() throws Exception { // GIVEN // 16 is the magic number of the page iterator // 32 is the number of nodes in each lucene document final int labelId = 1; int nodeCount = 32 * 16 + 10; start(); write( new PrefetchingIterator<NodeLabelUpdate>() { private int i = -1; @Override protected NodeLabelUpdate fetchNextOrNull() { return ++i < nodeCount ? labelChanges( i, NO_LABELS, new long[]{labelId} ) : null; } } ); // WHEN Set<Long> nodeSet = new TreeSet<>(); LabelScanReader reader = store.newReader(); LongIterator nodes = reader.nodesWithLabel( labelId ); while ( nodes.hasNext() ) { nodeSet.add( nodes.next() ); } reader.close(); // THEN assertEquals( "Found gaps in node id range: " + gaps( nodeSet, nodeCount ), nodeCount, nodeSet.size() ); }
@Override public void close() { labelScanReader.close(); }
private void closeSchemaResources() { if ( indexReaderFactory != null ) { indexReaderFactory.close(); // we can actually keep this object around } if ( labelScanReader != null ) { labelScanReader.close(); labelScanReader = null; } }