Skip to content

Commit

Permalink
Fixes #49 #111 #465 ENG-2836 ENG-3102 Efficiently support IN conditio…
Browse files Browse the repository at this point in the history
…ns for clustering columns

Summary:
When analyzing the condition to construct the scan specification, doc_ql_scanspec will now detect if all
conditions on clustering columns are '=' or 'IN' conditions (and hash columns are all set) and then aggregate
the set of options for each clustering column.

Then, the DocDB iterator will iterate (seek) only through those options, and skip the values in between.
Therefore, the results require no additional filtering for the conditions on the clustering columns (only for any additional
conditions in the where clause, e.g. on value columns).

Additionally fix a bug with static columns not being added correctly when using reverse iterators (i.e. SELECT with ORDER BY clause in reverse order).

Test Plan: jenkins, TestSelect

Reviewers: robert, mikhail

Reviewed By: robert, mikhail

Subscribers: bogdan, bharat, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D4426
  • Loading branch information
m-iancu committed Sep 17, 2018
1 parent 1536c5e commit 068f64f
Show file tree
Hide file tree
Showing 21 changed files with 910 additions and 301 deletions.
32 changes: 30 additions & 2 deletions java/yb-cql/src/test/java/org/yb/cql/BaseCQLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.slf4j.LoggerFactory;

import org.yb.client.YBClient;
import org.yb.master.Master;
import org.yb.minicluster.BaseMiniClusterTest;
import org.yb.minicluster.IOMetrics;
import org.yb.minicluster.Metrics;
Expand All @@ -53,6 +52,7 @@
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -494,13 +494,41 @@ protected void assertQuery(String stmt, Set<String> expectedRows) {

protected void assertQuery(Statement stmt, Set<String> expectedRows) {
ResultSet rs = session.execute(stmt);
HashSet<String> actualRows = new HashSet<>();
Set<String> actualRows = new HashSet<>();
for (Row row : rs) {
actualRows.add(row.toString());
}
assertEquals(expectedRows, actualRows);
}

/**
* Assert the result of a query when the order of the rows is not enforced.
* To be used, for instance, when querying over multiple hashes where the order is defined by the
* hash function not just the values.
*
* @param stmt The (select) query to be executed
* @param expectedRows the expected rows in no particular order
*/
protected void assertQueryRowsUnordered(String stmt, String... expectedRows) {
assertQuery(stmt, Arrays.stream(expectedRows).collect(Collectors.toSet()));
}

/**
* Assert the result of a query when the order of the rows is enforced.
* To be used, for instance, for queries where (range) column ordering (ASC/DESC) is being tested.
*
* @param stmt The (select) query to be executed
* @param expectedRows the rows in the expected order
*/
protected void assertQueryRowsOrdered(String stmt, String... expectedRows) {
ResultSet rs = session.execute(stmt);
List<String> actualRows = new ArrayList<String>();
for (Row row : rs) {
actualRows.add(row.toString());
}
assertEquals(Arrays.stream(expectedRows).collect(Collectors.toList()), actualRows);
}

// blob type utils
protected String makeBlobString(ByteBuffer buf) {
StringBuilder sb = new StringBuilder();
Expand Down
Loading

0 comments on commit 068f64f

Please sign in to comment.