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));
}
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));
}
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));
}
}
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"));
}
}
}
use of org.neo4j.storageengine.api.schema.IndexReader in project neo4j by neo4j.
the class IndexQueryTransactionStateTest method before.
@Before
public void before() throws Exception {
TransactionState txState = new TxState();
state = StatementOperationsTestHelper.mockedState(txState);
store = mock(StoreReadLayer.class);
when(store.indexGetState(newIndexDescriptor)).thenReturn(InternalIndexState.ONLINE);
when(store.indexesGetForLabel(labelId)).then(answerAsIteratorFrom(indexes));
when(store.indexesGetAll()).then(answerAsIteratorFrom(indexes));
when(store.constraintsGetForLabel(labelId)).thenReturn(Collections.emptyIterator());
when(store.indexGetForLabelAndPropertyKey(newIndexDescriptor.schema())).thenReturn(newIndexDescriptor);
statement = mock(StoreStatement.class);
when(state.getStoreStatement()).thenReturn(statement);
indexReader = mock(IndexReader.class);
when(statement.getIndexReader(newIndexDescriptor)).thenReturn(indexReader);
when(statement.getFreshIndexReader(newIndexDescriptor)).thenReturn(indexReader);
StateHandlingStatementOperations stateHandlingOperations = new StateHandlingStatementOperations(store, new InternalAutoIndexing(Config.empty(), null), mock(ConstraintIndexCreator.class), mock(LegacyIndexStore.class));
txContext = new ConstraintEnforcingEntityOperations(new StandardConstraintSemantics(), stateHandlingOperations, stateHandlingOperations, stateHandlingOperations, stateHandlingOperations);
}
Aggregations