Search in sources :

Example 46 with IndexReader

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();
}
Also used : IndexReader(org.neo4j.storageengine.api.schema.IndexReader) Test(org.junit.Test)

Example 47 with IndexReader

use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.

the class SimpleIndexReaderTest method seekQueryReachSearcher.

@Test
public void seekQueryReachSearcher() throws Exception {
    IndexReader simpleIndexReader = getUniqueSimpleReader();
    simpleIndexReader.query(IndexQuery.exact(1, "test"));
    verify(indexSearcher).search(any(TermQuery.class), any(DocValuesCollector.class));
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) DocValuesCollector(org.neo4j.kernel.api.impl.index.collector.DocValuesCollector) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) Test(org.junit.Test)

Example 48 with IndexReader

use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.

the class SimpleIndexReaderTest method countIndexedNodesReachSearcher.

@Test
public void countIndexedNodesReachSearcher() throws IOException {
    IndexReader simpleIndexReader = getUniqueSimpleReader();
    simpleIndexReader.countIndexedNodes(2, "testValue");
    verify(indexSearcher).search(any(BooleanQuery.class), any(DocValuesCollector.class));
}
Also used : BooleanQuery(org.apache.lucene.search.BooleanQuery) DocValuesCollector(org.neo4j.kernel.api.impl.index.collector.DocValuesCollector) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) Test(org.junit.Test)

Example 49 with IndexReader

use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.

the class NonUniqueDatabaseIndexPopulatorTest method addUpdates.

@Test
public void addUpdates() throws Exception {
    populator = newPopulator();
    List<IndexEntryUpdate> updates = Arrays.asList(IndexEntryUpdate.add(1, labelSchemaDescriptor, "foo"), IndexEntryUpdate.add(2, labelSchemaDescriptor, "bar"), IndexEntryUpdate.add(42, labelSchemaDescriptor, "bar"));
    populator.add(updates);
    index.maybeRefreshBlocking();
    try (IndexReader reader = index.getIndexReader()) {
        int propertyKeyId = labelSchemaDescriptor.getPropertyId();
        PrimitiveLongIterator allEntities = reader.query(IndexQuery.exists(propertyKeyId));
        assertArrayEquals(new long[] { 1, 2, 42 }, PrimitiveLongCollections.asArray(allEntities));
    }
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) IndexEntryUpdate(org.neo4j.kernel.api.index.IndexEntryUpdate) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) Test(org.junit.Test)

Example 50 with IndexReader

use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method applyConcurrentDeletesToPopulatedIndex.

@Test
public void applyConcurrentDeletesToPopulatedIndex() throws Throwable {
    List<NodeUpdates> updates = new ArrayList<>(2);
    updates.add(NodeUpdates.forNode(0, id(COUNTRY_LABEL)).removed(propertyId, "Sweden").build());
    updates.add(NodeUpdates.forNode(3, id(COLOR_LABEL)).removed(propertyId, "green").build());
    launchCustomIndexPopulation(labelsNameIdMap, propertyId, updates);
    waitAndActivateIndexes(labelsNameIdMap, propertyId);
    try (Transaction ignored = embeddedDatabase.beginTx()) {
        Integer countryLabelId = labelsNameIdMap.get(COUNTRY_LABEL);
        Integer colorLabelId = labelsNameIdMap.get(COLOR_LABEL);
        try (IndexReader indexReader = getIndexReader(propertyId, countryLabelId)) {
            assertEquals("Should be removed by concurrent remove.", 0, indexReader.countIndexedNodes(0, "Sweden"));
        }
        try (IndexReader indexReader = getIndexReader(propertyId, colorLabelId)) {
            assertEquals("Should be removed by concurrent remove.", 0, indexReader.countIndexedNodes(3, "green"));
        }
    }
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) Transaction(org.neo4j.graphdb.Transaction) ArrayList(java.util.ArrayList) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) Test(org.junit.Test)

Aggregations

IndexReader (org.neo4j.storageengine.api.schema.IndexReader)50 Test (org.junit.Test)38 PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)19 IndexQuery (org.neo4j.kernel.api.schema_new.IndexQuery)11 StateHandlingStatementOperations (org.neo4j.kernel.impl.api.StateHandlingStatementOperations)10 StoreReadLayer (org.neo4j.storageengine.api.StoreReadLayer)10 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)9 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)9 DocValuesCollector (org.neo4j.kernel.api.impl.index.collector.DocValuesCollector)6 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)5 IndexSampler (org.neo4j.storageengine.api.schema.IndexSampler)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 TermQuery (org.apache.lucene.search.TermQuery)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.fail (org.junit.Assert.fail)2 Before (org.junit.Before)2