Skip to content

Commit

Permalink
remove unused limit parameter from IndexSearcher::search
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed Dec 11, 2024
1 parent 6c9a0e6 commit e107fcc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ protected IndexSearcher(PrimaryKeyMap.Factory primaryKeyMapFactory,
* @param keyRange key range specific in read command, used by ANN index
* @param queryContext to track per sstable cache and per query metrics
* @param defer create the iterator in a deferred state
* @param limit the initial num of rows to returned, used by ANN index. More rows may be requested if filtering throws away more than expected!
* @return {@link KeyRangeIterator} that matches given expression
*/
public abstract KeyRangeIterator search(Expression expression, AbstractBounds<PartitionPosition> keyRange, QueryContext queryContext, boolean defer, int limit) throws IOException;
public abstract KeyRangeIterator search(Expression expression, AbstractBounds<PartitionPosition> keyRange, QueryContext queryContext, boolean defer) throws IOException;

/**
* Order the rows by the given Orderer. Used for ORDER BY clause when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public long indexFileCacheSize()
}

@SuppressWarnings("resource")
public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context, boolean defer, int limit) throws IOException
public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context, boolean defer) throws IOException
{
PostingList postingList = searchPosting(exp, context);
return toPrimaryKeyIterator(postingList, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public long indexFileCacheSize()
}

@Override
public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context, boolean defer, int limit) throws IOException
public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context, boolean defer) throws IOException
{
PostingList postingList = searchPosting(exp, context);
return toPrimaryKeyIterator(postingList, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public long indexFileCacheSize()
*/
public KeyRangeIterator search(Expression expression, AbstractBounds<PartitionPosition> keyRange, QueryContext context, boolean defer, int limit) throws IOException
{
return index.search(expression, keyRange, context, defer, limit);
return index.search(expression, keyRange, context, defer);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ public ProductQuantization getPQ()
}

@Override
public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context, boolean defer, int limit) throws IOException
public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context, boolean defer) throws IOException
{
PostingList results = searchPosting(context, exp, keyRange, limit);
PostingList results = searchPosting(context, exp, keyRange);
return toPrimaryKeyIterator(results, context);
}

private PostingList searchPosting(QueryContext context, Expression exp, AbstractBounds<PartitionPosition> keyRange, int limit) throws IOException
private PostingList searchPosting(QueryContext context, Expression exp, AbstractBounds<PartitionPosition> keyRange) throws IOException
{
if (logger.isTraceEnabled())
logger.trace(indexContext.logMessage("Searching on expression '{}'..."), exp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void doTestEqQueriesAgainstStringIndex(Version version) throws Exception
for (int t = 0; t < numTerms; ++t)
{
try (KeyRangeIterator results = searcher.search(new Expression(indexContext)
.add(Operator.EQ, termsEnum.get(t).originalTermBytes), null, new QueryContext(), false, LIMIT))
.add(Operator.EQ, termsEnum.get(t).originalTermBytes), null, new QueryContext(), false))
{
assertTrue(results.hasNext());

Expand All @@ -121,7 +121,7 @@ private void doTestEqQueriesAgainstStringIndex(Version version) throws Exception
}

try (KeyRangeIterator results = searcher.search(new Expression(indexContext)
.add(Operator.EQ, termsEnum.get(t).originalTermBytes), null, new QueryContext(), false, LIMIT))
.add(Operator.EQ, termsEnum.get(t).originalTermBytes), null, new QueryContext(), false))
{
assertTrue(results.hasNext());

Expand All @@ -143,12 +143,12 @@ private void doTestEqQueriesAgainstStringIndex(Version version) throws Exception
// try searching for terms that weren't indexed
final String tooLongTerm = randomSimpleString(10, 12);
KeyRangeIterator results = searcher.search(new Expression(indexContext)
.add(Operator.EQ, UTF8Type.instance.decompose(tooLongTerm)), null, new QueryContext(), false, LIMIT);
.add(Operator.EQ, UTF8Type.instance.decompose(tooLongTerm)), null, new QueryContext(), false);
assertFalse(results.hasNext());

final String tooShortTerm = randomSimpleString(1, 2);
results = searcher.search(new Expression(indexContext)
.add(Operator.EQ, UTF8Type.instance.decompose(tooShortTerm)), null, new QueryContext(), false, LIMIT);
.add(Operator.EQ, UTF8Type.instance.decompose(tooShortTerm)), null, new QueryContext(), false);
assertFalse(results.hasNext());
}
}
Expand All @@ -162,7 +162,7 @@ public void testUnsupportedOperator() throws Exception
try (IndexSearcher searcher = buildIndexAndOpenSearcher(numTerms, numPostings, termsEnum))
{
searcher.search(new Expression(indexContext)
.add(Operator.NEQ, UTF8Type.instance.decompose("a")), null, new QueryContext(), false, LIMIT);
.add(Operator.NEQ, UTF8Type.instance.decompose("a")), null, new QueryContext(), false);

fail("Expect IllegalArgumentException thrown, but didn't");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void testUnsupportedOperator() throws Exception
{{
operation = Op.NOT_EQ;
lower = upper = new Bound(ShortType.instance.decompose((short) 0), Int32Type.instance, true);
}}, null, new QueryContext(), false, LIMIT);
}}, null, new QueryContext(), false);

fail("Expect IllegalArgumentException thrown, but didn't");
}
Expand All @@ -169,7 +169,7 @@ private <T extends Number> void testEqQueries(final IndexSearcher indexSearcher,
{{
operation = Op.EQ;
lower = upper = new Bound(rawType.decompose(rawValueProducer.apply(EQ_TEST_LOWER_BOUND_INCLUSIVE)), encodedType, true);
}}, null, new QueryContext(), false, LIMIT))
}}, null, new QueryContext(), false))
{
assertTrue(results.hasNext());

Expand All @@ -180,7 +180,7 @@ private <T extends Number> void testEqQueries(final IndexSearcher indexSearcher,
{{
operation = Op.EQ;
lower = upper = new Bound(rawType.decompose(rawValueProducer.apply(EQ_TEST_UPPER_BOUND_EXCLUSIVE)), encodedType, true);
}}, null, new QueryContext(), false, LIMIT))
}}, null, new QueryContext(), false))
{
assertFalse(results.hasNext());
indexSearcher.close();
Expand All @@ -206,7 +206,7 @@ private <T extends Number> void testRangeQueries(final IndexSearcher indexSearch

lower = new Bound(rawType.decompose(rawValueProducer.apply((short)2)), encodedType, false);
upper = new Bound(rawType.decompose(rawValueProducer.apply((short)7)), encodedType, true);
}}, null, new QueryContext(), false, LIMIT))
}}, null, new QueryContext(), false))
{
assertTrue(results.hasNext());

Expand All @@ -218,7 +218,7 @@ private <T extends Number> void testRangeQueries(final IndexSearcher indexSearch
{{
operation = Op.RANGE;
lower = new Bound(rawType.decompose(rawValueProducer.apply(RANGE_TEST_UPPER_BOUND_EXCLUSIVE)), encodedType, true);
}}, null, new QueryContext(), false, LIMIT))
}}, null, new QueryContext(), false))
{
assertFalse(results.hasNext());
}
Expand All @@ -227,7 +227,7 @@ private <T extends Number> void testRangeQueries(final IndexSearcher indexSearch
{{
operation = Op.RANGE;
upper = new Bound(rawType.decompose(rawValueProducer.apply(RANGE_TEST_LOWER_BOUND_INCLUSIVE)), encodedType, false);
}}, null, new QueryContext(), false, LIMIT))
}}, null, new QueryContext(), false))
{
assertFalse(results.hasNext());
indexSearcher.close();
Expand Down

0 comments on commit e107fcc

Please sign in to comment.