Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-6789 - Variant query fails with large skip values #2498

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ public boolean doIntersectWithSearch(Query query, QueryOptions options) {
intersect = true;
} else {
if (options.getBoolean(QueryOptions.COUNT)) {
// The SearchIndex is better than anyone in terms of counting
intersect = true;
} else if (options.getInt(QueryOptions.SKIP, 0) > 500) {
// Large "skip" queries should use SearchIndex when possible
intersect = true;
} else {
// TODO: Improve this heuristic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

import com.google.common.base.Throwables;
import org.junit.ClassRule;
import org.junit.Test;
import org.opencb.biodata.models.variant.Variant;
import org.opencb.commons.datastore.core.DataResult;
import org.opencb.commons.datastore.core.Query;
import org.opencb.commons.datastore.core.QueryOptions;
import org.opencb.opencga.storage.core.variant.query.VariantQueryResult;
import org.opencb.opencga.storage.core.variant.VariantStorageEngine;
import org.opencb.opencga.storage.core.variant.adaptors.iterators.VariantDBIterator;
import org.opencb.opencga.storage.core.variant.query.VariantQueryResult;
import org.opencb.opencga.storage.core.variant.search.solr.VariantSearchManager;
import org.opencb.opencga.storage.core.variant.solr.VariantSolrExternalResource;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.opencb.opencga.storage.core.variant.search.solr.VariantSearchManager.SEARCH_ENGINE_ID;

/**
* Created on 22/12/17.
*
Expand Down Expand Up @@ -87,4 +93,32 @@ public DataResult rank(int limit, Query query, String field, boolean asc) {
throw Throwables.propagate(e);
}
}

@Test
public void testQueryExecutor() {
assertThat(variantStorageEngine.get(new VariantQuery(), new QueryOptions()
.append(QueryOptions.LIMIT, 10)
.append(QueryOptions.COUNT, false)
.append(QueryOptions.SKIP, 0)).getSource(),
not(containsString(SEARCH_ENGINE_ID)));

assertThat(variantStorageEngine.get(new VariantQuery(), new QueryOptions()
.append(QueryOptions.LIMIT, 10)
.append(QueryOptions.COUNT, true)
.append(QueryOptions.SKIP, 0)).getSource(),
containsString(SEARCH_ENGINE_ID));

assertThat(variantStorageEngine.get(new VariantQuery(), new QueryOptions()
.append(QueryOptions.LIMIT, 10)
.append(QueryOptions.COUNT, false)
.append(QueryOptions.SKIP, 100)).getSource(),
not(containsString(SEARCH_ENGINE_ID)));

assertThat(variantStorageEngine.get(new VariantQuery(), new QueryOptions()
.append(QueryOptions.LIMIT, 10)
.append(QueryOptions.COUNT, false)
.append(QueryOptions.SKIP, 1000)).getSource(),
containsString(SEARCH_ENGINE_ID));

}
}
Loading