use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method shouldStopSamplingWhenIndexIsDropped.
@Test
public void shouldStopSamplingWhenIndexIsDropped() throws Exception {
// given
updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2)));
// when
// needs to be acquired before drop() is called
IndexReader indexReader = accessor.newReader();
IndexSampler indexSampler = indexReader.createSampler();
Future<Void> drop = threading.executeAndAwait((IOFunction<Void, Void>) nothing -> {
accessor.drop();
return nothing;
}, null, waitingWhileIn(TaskCoordinator.class, "awaitCompletion"), 3, SECONDS);
try (IndexReader reader = indexReader) /* do not inline! */
{
indexSampler.sampleIndex();
fail("expected exception");
} catch (IndexNotFoundKernelException e) {
assertEquals("Index dropped while sampling.", e.getMessage());
} finally {
drop.get();
}
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method indexReaderShouldHonorRepeatableReads.
@Test
public void indexReaderShouldHonorRepeatableReads() throws Exception {
// GIVEN
updateAndCommit(asList(add(nodeId, value)));
IndexReader reader = accessor.newReader();
// WHEN
updateAndCommit(asList(remove(nodeId, value)));
// THEN
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(reader.query(exact(PROP_ID, value))));
reader.close();
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class SimpleIndexReaderTest method stringRangeSeekQueryReachSearcher.
@Test
public void stringRangeSeekQueryReachSearcher() throws Exception {
IndexReader simpleIndexReader = getUniqueSimpleReader();
simpleIndexReader.query(range(1, "a", false, "b", true));
verify(indexSearcher).search(any(TermQuery.class), any(DocValuesCollector.class));
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class SimpleIndexReaderTest method numberRangeSeekQueryReachSearcher.
@Test
public void numberRangeSeekQueryReachSearcher() throws Exception {
IndexReader simpleIndexReader = getUniqueSimpleReader();
simpleIndexReader.query(range(1, 7, true, 8, true));
verify(indexSearcher).search(any(NumericRangeQuery.class), any(DocValuesCollector.class));
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class SimpleIndexReaderTest method releaseSearcherOnClose.
@Test
public void releaseSearcherOnClose() throws IOException {
IndexReader simpleIndexReader = getUniqueSimpleReader();
simpleIndexReader.close();
verify(partitionSearcher).close();
}
Aggregations