@Override public void query( IndexProgressor.NodeValueClient client, IndexOrder indexOrder, boolean needsValues, IndexQuery... query ) throws IndexNotApplicableKernelException { delegate.query( client, indexOrder, needsValues, query ); }
private PrimitiveLongResourceIterator innerQuery( IndexReader reader, IndexQuery[] predicates ) { try { return reader.query( predicates ); } catch ( IndexNotApplicableKernelException e ) { throw new InnerException( e ); } }
@Override public PrimitiveLongResourceIterator query( IndexQuery... predicates ) throws IndexNotApplicableKernelException { return delegate.query( predicates ); }
@Override public PrimitiveLongResourceIterator query( IndexQuery... predicates ) throws IndexNotApplicableKernelException { IndexSlot slot = slotSelector.selectSlot( predicates, IndexQuery::valueGroup ); return slot != null ? instanceSelector.select( slot ).query( predicates ) : concat( instanceSelector.transform( reader -> reader.query( predicates ) ) ); }
@Override // UniqueNodeIndexSeeker public void nodeIndexSeekWithFreshIndexReader( DefaultNodeValueIndexCursor cursor, IndexReader indexReader, IndexQuery.ExactPredicate... query ) throws IndexNotApplicableKernelException { cursor.setRead( this ); IndexProgressor.NodeValueClient target = injectFullValuePrecision( cursor, query, indexReader ); // we never need values for exact predicates indexReader.query( target, IndexOrder.NONE, false, query ); }
protected AutoCloseable query( SimpleNodeValueClient client, IndexOrder order, IndexQuery... predicates ) throws Exception { IndexReader reader = accessor.newReader(); reader.query( client, order, false, predicates ); return reader; }
private LongIterator query( IndexReader reader, IndexQuery query ) throws IndexNotApplicableKernelException { NodeValueIterator client = new NodeValueIterator(); reader.query( client, IndexOrder.NONE, false, query ); return client; }
@Test void stringRangeSeekQueryReachSearcher() throws Exception { IndexReader simpleIndexReader = getUniqueSimpleReader(); simpleIndexReader.query( range( 1, "a", false, "b", true ) ); verify( indexSearcher ).search( any( TermRangeQuery.class ), any( DocValuesCollector.class ) ); }
@Test void scanQueryReachSearcher() throws Exception { IndexReader simpleIndexReader = getUniqueSimpleReader(); simpleIndexReader.query( IndexQuery.exists( 1 ) ); verify( indexSearcher ).search( any( MatchAllDocsQuery.class ), any( DocValuesCollector.class ) ); }
@Test void seekQueryReachSearcher() throws Exception { IndexReader simpleIndexReader = getUniqueSimpleReader(); simpleIndexReader.query( IndexQuery.exact( 1, "test" ) ); verify( indexSearcher ).search( any( BooleanQuery.class ), any( DocValuesCollector.class ) ); }
@Test void numberRangeSeekQueryReachSearcher() throws Exception { IndexReader simpleIndexReader = getUniqueSimpleReader(); simpleIndexReader.query( range( 1, 7, true, 8, true ) ); verify( indexSearcher ).search( any( NumericRangeQuery.class ), any( DocValuesCollector.class ) ); }
@Test void prefixRangeSeekQueryReachSearcher() throws Exception { IndexReader simpleIndexReader = getUniqueSimpleReader(); simpleIndexReader.query( IndexQuery.stringPrefix( 1, stringValue( "bb" ) ) ); verify( indexSearcher ).search( any( MultiTermQuery.class ), any( DocValuesCollector.class ) ); }
@Test void defaultQueryImplementationMustThrowForUnsupportedIndexOrder() { // Given IndexReader indexReader = stubIndexReader(); // Then String expectedMessage = String.format( "This reader only have support for index order %s. Provided index order was %s.", IndexOrder.NONE, IndexOrder.ASCENDING ); UnsupportedOperationException operationException = assertThrows( UnsupportedOperationException.class, () -> indexReader.query( new SimpleNodeValueClient(), IndexOrder.ASCENDING, false, IndexQuery.exists( 1 ) ) ); assertEquals( expectedMessage, operationException.getMessage() ); }
@Test public void canChangeExistingData() throws Exception { // GIVEN updateAndCommit( asList( add( nodeId, value ) ) ); // WHEN updateAndCommit( asList( change( nodeId, value, value2 ) ) ); IndexReader reader = accessor.newReader(); // THEN assertEquals( asSet( nodeId ), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value2 ) ) ) ); assertEquals( emptySet(), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value ) ) ) ); reader.close(); }
@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(); }
@Test public void canRemoveExistingData() throws Exception { // GIVEN updateAndCommit( asList( add( nodeId, value ), add( nodeId2, value2 ) ) ); // WHEN updateAndCommit( asList( remove( nodeId, value ) ) ); IndexReader reader = accessor.newReader(); // THEN assertEquals( asSet( nodeId2 ), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value2 ) ) ) ); assertEquals( asSet(), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value ) ) ) ); reader.close(); }
@Test public void indexReaderShouldSupportScan() throws Exception { // GIVEN updateAndCommit( asList( add( nodeId, value ), add( nodeId2, value2 ) ) ); IndexReader reader = accessor.newReader(); // WHEN LongIterator results = reader.query( IndexQuery.exists( PROP_ID ) ); // THEN assertEquals( asSet( nodeId, nodeId2 ), PrimitiveLongCollections.toSet( results ) ); assertEquals( asSet( nodeId ), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value ) ) ) ); reader.close(); }
@Test public void canAddNewData() throws Exception { // WHEN updateAndCommit( asList( add( nodeId, value ), add( nodeId2, value2 ) ) ); IndexReader reader = accessor.newReader(); // THEN assertEquals( asSet( nodeId ), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value ) ) ) ); reader.close(); }
@Test public void indexReaderShouldSupportScan() throws Exception { // GIVEN updateAndCommit( asList( add( nodeId, values ), add( nodeId2, values2 ) ) ); IndexReader reader = accessor.newReader(); // WHEN LongIterator results = reader.query( IndexQuery.exists( PROP_ID1 ), IndexQuery.exists( PROP_ID2 ) ); // THEN assertEquals( asSet( nodeId, nodeId2 ), PrimitiveLongCollections.toSet( results ) ); assertEquals( asSet( nodeId ), PrimitiveLongCollections.toSet( reader .query( exact( PROP_ID1, values[0] ), exact( PROP_ID2, values[1] ) ) ) ); reader.close(); }
@Test public void canAddNewData() throws Exception { // WHEN updateAndCommit( asList( add( nodeId, values ), add( nodeId2, values2 ) ) ); IndexReader reader = accessor.newReader(); // THEN assertEquals( asSet( nodeId ), PrimitiveLongCollections.toSet( reader .query( exact( PROP_ID1, values[0] ), exact( PROP_ID2, values[1] ) ) ) ); reader.close(); }