You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2015/07/08 21:00:01 UTC
[1/2] phoenix git commit: PHOENIX-2096 Tweak criteria for when round
robin iterator is used
Repository: phoenix
Updated Branches:
refs/heads/master efb941aef -> 61f1900dd
PHOENIX-2096 Tweak criteria for when round robin iterator is used
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/61f1900d
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/61f1900d
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/61f1900d
Branch: refs/heads/master
Commit: 61f1900ddec5eb5c06245c999711e1fd0c67af53
Parents: 69e55df
Author: James Taylor <jt...@salesforce.com>
Authored: Thu Jul 2 09:48:42 2015 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed Jul 8 11:57:40 2015 -0700
----------------------------------------------------------------------
.../apache/phoenix/end2end/ReverseScanIT.java | 29 ++++++++++++++++----
.../org/apache/phoenix/execute/ScanPlan.java | 4 +--
.../java/org/apache/phoenix/util/ScanUtil.java | 7 ++---
3 files changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/61f1900d/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java
index 5481d80..eca183b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java
@@ -19,6 +19,9 @@ package org.apache.phoenix.end2end;
import static org.apache.phoenix.util.TestUtil.ROW2;
import static org.apache.phoenix.util.TestUtil.ROW3;
+import static org.apache.phoenix.util.TestUtil.ROW4;
+import static org.apache.phoenix.util.TestUtil.ROW5;
+import static org.apache.phoenix.util.TestUtil.ROW6;
import static org.apache.phoenix.util.TestUtil.ROW7;
import static org.apache.phoenix.util.TestUtil.ROW8;
import static org.apache.phoenix.util.TestUtil.ROW9;
@@ -31,6 +34,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.Statement;
import java.util.Map;
import java.util.Properties;
@@ -39,6 +43,7 @@ import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.QueryUtil;
import org.apache.phoenix.util.ReadOnlyProps;
import org.apache.phoenix.util.TestUtil;
import org.junit.BeforeClass;
@@ -81,11 +86,11 @@ public class ReverseScanIT extends BaseHBaseManagedTimeIT {
initATableValues(tenantId, getSplitsAtRowKeys(tenantId), getUrl());
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
- String query = "SELECT entity_id FROM aTable WHERE entity_id >= ? ORDER BY organization_id DESC, entity_id DESC";
+ String query = "SELECT entity_id FROM aTable WHERE entity_id >= '" + ROW3 + "' ORDER BY organization_id DESC, entity_id DESC";
try {
- PreparedStatement statement = conn.prepareStatement(query);
- statement.setString(1, ROW7);
- ResultSet rs = statement.executeQuery();
+ Statement stmt = conn.createStatement();
+ stmt.setFetchSize(2);
+ ResultSet rs = stmt.executeQuery(query);
assertTrue (rs.next());
assertEquals(ROW9,rs.getString(1));
@@ -93,10 +98,24 @@ public class ReverseScanIT extends BaseHBaseManagedTimeIT {
assertEquals(ROW8,rs.getString(1));
assertTrue (rs.next());
assertEquals(ROW7,rs.getString(1));
+ assertTrue (rs.next());
+ assertEquals(ROW6,rs.getString(1));
+ assertTrue (rs.next());
+ assertEquals(ROW5,rs.getString(1));
+ assertTrue (rs.next());
+ assertEquals(ROW4,rs.getString(1));
+ assertTrue (rs.next());
+ assertEquals(ROW3,rs.getString(1));
assertFalse(rs.next());
- statement = conn.prepareStatement("SELECT entity_id FROM aTable WHERE organization_id = ? AND entity_id >= ? ORDER BY organization_id DESC, entity_id DESC");
+ rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+ assertEquals(
+ "CLIENT PARALLEL 1-WAY REVERSE FULL SCAN OVER ATABLE\n" +
+ " SERVER FILTER BY FIRST KEY ONLY AND ENTITY_ID >= '00A323122312312'",
+ QueryUtil.getExplainPlan(rs));
+
+ PreparedStatement statement = conn.prepareStatement("SELECT entity_id FROM aTable WHERE organization_id = ? AND entity_id >= ? ORDER BY organization_id DESC, entity_id DESC");
statement.setString(1, tenantId);
statement.setString(2, ROW7);
rs = statement.executeQuery();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/61f1900d/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
index b9dd2f2..fd9f8ad 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
@@ -18,8 +18,6 @@
package org.apache.phoenix.execute;
-import static org.apache.phoenix.util.ScanUtil.shouldRowsBeInRowKeyOrder;
-
import java.sql.SQLException;
import java.util.List;
@@ -187,7 +185,7 @@ public class ScanPlan extends BaseQueryPlan {
if (isOrdered) {
scanner = new MergeSortTopNResultIterator(iterators, limit, orderBy.getOrderByExpressions());
} else {
- if ((isSalted || table.getIndexType() == IndexType.LOCAL) && shouldRowsBeInRowKeyOrder(orderBy, context)) {
+ if ((isSalted || table.getIndexType() == IndexType.LOCAL) && ScanUtil.forceRowKeyOrder(context)) {
scanner = new MergeSortRowKeyResultIterator(iterators, isSalted ? SaltingUtil.NUM_SALTING_BYTES : 0, orderBy == OrderBy.REV_ROW_KEY_ORDER_BY);
} else if (useRoundRobinIterator()) {
scanner = new RoundRobinResultIterator(iterators, this);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/61f1900d/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
index a1473ef..3dff972 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
@@ -672,12 +672,11 @@ public class ScanUtil {
* not even row key order. Also no point doing round robin of scanners if fetch size
* is 1.
*/
- return fetchSize > 1 && !shouldRowsBeInRowKeyOrder(orderBy, context) && orderBy.getOrderByExpressions().isEmpty();
+ return fetchSize > 1 && !forceRowKeyOrder(context) && (orderBy.getOrderByExpressions().isEmpty() && orderBy != FWD_ROW_KEY_ORDER_BY && orderBy != REV_ROW_KEY_ORDER_BY);
}
- public static boolean shouldRowsBeInRowKeyOrder(OrderBy orderBy, StatementContext context) {
- boolean forceRowKeyOrder = context.getConnection().getQueryServices().getProps()
+ public static boolean forceRowKeyOrder(StatementContext context) {
+ return context.getConnection().getQueryServices().getProps()
.getBoolean(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, QueryServicesOptions.DEFAULT_FORCE_ROW_KEY_ORDER);
- return forceRowKeyOrder || orderBy == FWD_ROW_KEY_ORDER_BY || orderBy == REV_ROW_KEY_ORDER_BY;
}
}
\ No newline at end of file
[2/2] phoenix git commit: PHOENIX-2097 Add new MD5 test for composite
PK
Posted by ja...@apache.org.
PHOENIX-2097 Add new MD5 test for composite PK
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/69e55df8
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/69e55df8
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/69e55df8
Branch: refs/heads/master
Commit: 69e55df8ff42aedf8c12da569dc5e85cc13eb95d
Parents: efb941a
Author: James Taylor <jt...@salesforce.com>
Authored: Thu Jul 2 10:03:55 2015 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed Jul 8 11:57:40 2015 -0700
----------------------------------------------------------------------
.../apache/phoenix/end2end/MD5FunctionIT.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/69e55df8/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java
index ff7ebdb..a6107df 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java
@@ -52,6 +52,25 @@ public class MD5FunctionIT extends BaseHBaseManagedTimeIT {
}
@Test
+ public void testRetrieveCompositeKey() throws Exception {
+ String testString = "FOOBAR";
+
+ Connection conn = DriverManager.getConnection(getUrl());
+ String ddl = "CREATE TABLE IF NOT EXISTS MD5_RETRIEVE_TEST (k1 CHAR(3) NOT NULL, k2 CHAR(3) NOT NULL, CONSTRAINT PK PRIMARY KEY (K1,K2))";
+ conn.createStatement().execute(ddl);
+ String dml = "UPSERT INTO MD5_RETRIEVE_TEST VALUES('FOO','BAR')";
+ conn.createStatement().execute(dml);
+ conn.commit();
+
+ ResultSet rs = conn.createStatement().executeQuery("SELECT MD5((K1,K2)) FROM MD5_RETRIEVE_TEST");
+ assertTrue(rs.next());
+ byte[] first = MessageDigest.getInstance("MD5").digest(testString.getBytes());
+ byte[] second = rs.getBytes(1);
+ assertArrayEquals(first, second);
+ assertFalse(rs.next());
+ }
+
+ @Test
public void testUpsert() throws Exception {
String testString1 = "mwalsh1";
String testString2 = "mwalsh2";