git commit: PHOENIX-1110 Fix flappy MultiCfQueryExecIT

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 17397dcb8 - 097312fcd


PHOENIX-1110 Fix flappy MultiCfQueryExecIT


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/097312fc
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/097312fc
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/097312fc

Branch: refs/heads/master
Commit: 097312fcd77a301341893ee9f4d9c37909e817a0
Parents: 17397dc
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 14:28:39 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 14:40:00 2014 -0700

--
 .../org/apache/phoenix/end2end/ArrayIT.java |  79 ++
 .../end2end/ColumnProjectionOptimizationIT.java |  65 +--
 .../java/org/apache/phoenix/query/BaseTest.java | 109 ---
 3 files changed, 133 insertions(+), 120 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/097312fc/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
index 47d7265..77eaa2e 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
@@ -17,6 +17,7 @@
  */
 package org.apache.phoenix.end2end;
 
+import static org.apache.phoenix.util.PhoenixRuntime.CURRENT_SCN_ATTRIB;
 import static org.apache.phoenix.util.TestUtil.B_VALUE;
 import static org.apache.phoenix.util.TestUtil.ROW1;
 import static org.apache.phoenix.util.TestUtil.TABLE_WITH_ARRAY;
@@ -53,6 +54,84 @@ public class ArrayIT extends BaseClientManagedTimeIT {
 
private static final String SIMPLE_TABLE_WITH_ARRAY = 
SIMPLE_TABLE_WITH_ARRAY;
 
+private static void initTablesWithArrays(String tenantId, Date date, Long 
ts, boolean useNull, String url) throws Exception {
+Properties props = new Properties();
+if (ts != null) {
+props.setProperty(CURRENT_SCN_ATTRIB, ts.toString());
+}
+Connection conn = DriverManager.getConnection(url, props);
+try {
+// Insert all rows at ts
+PreparedStatement stmt = conn.prepareStatement(
+upsert into  +
+TABLE_WITH_ARRAY( +
+ORGANIZATION_ID,  +
+ENTITY_ID,  +
+a_string_array,  +
+B_STRING,  +
+A_INTEGER,  +
+A_DATE,  +
+X_DECIMAL,  +
+x_long_array,  +
+X_INTEGER, +
+a_byte_array, +
+A_SHORT, +
+A_FLOAT, +
+a_double_array, +
+A_UNSIGNED_FLOAT, +
+A_UNSIGNED_DOUBLE) +
+VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?));
+stmt.setString(1, tenantId);
+stmt.setString(2, ROW1);
+// Need to support primitive
+String[] strArr =  new String[4];
+strArr[0] = ABC;
+if (useNull) {
+strArr[1] = null;
+} else {
+strArr[1] = CEDF;
+}
+strArr[2] = XYZWER;
+strArr[3] = AB;
+Array array = conn.createArrayOf(VARCHAR, strArr);
+stmt.setArray(3, array);
+stmt.setString(4, B_VALUE);
+stmt.setInt(5, 1);
+stmt.setDate(6, date);
+stmt.setBigDecimal(7, null);
+// Need to support primitive
+Long[] longArr =  new Long[2];
+longArr[0] = 25l;
+longArr[1] = 36l;
+array = conn.createArrayOf(BIGINT, longArr);
+stmt.setArray(8, array);
+stmt.setNull(9, Types.INTEGER);
+// Need to support primitive
+Byte[] byteArr =  new Byte[2];
+byteArr[0] = 25;
+byteArr[1] = 36;
+array = conn.createArrayOf(TINYINT, byteArr);
+stmt.setArray(10, array);
+stmt.setShort(11, (short) 128);
+stmt.setFloat(12, 0.01f);
+// Need to support primitive
+Double[] doubleArr =  new Double[4];
+doubleArr[0] = 25.343;
+doubleArr[1] = 36.763;
+doubleArr[2] = 37.56;
+doubleArr[3] = 386.63;
+array = conn.createArrayOf(DOUBLE, doubleArr);
+

git commit: PHOENIX-1109 PhoenixTestDriver needs to call shutdown on executor (SamarthJain)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 097312fcd - 7a16517b4


PHOENIX-1109 PhoenixTestDriver needs to call shutdown on executor (SamarthJain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7a16517b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7a16517b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7a16517b

Branch: refs/heads/master
Commit: 7a16517b4ef5769d0a4506a789db7d859ce44d45
Parents: 097312f
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 15:03:56 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 15:07:53 2014 -0700

--
 .../phoenix/end2end/ExecuteStatementsIT.java|  2 +-
 .../apache/phoenix/jdbc/PhoenixTestDriver.java  | 36 +---
 2 files changed, 32 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7a16517b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
index c2bf5c5..0d64f2e 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
@@ -198,7 +198,7 @@ public class ExecuteStatementsIT extends 
BaseHBaseManagedTimeIT {
 
 // test upsert statement with padding
 String tenantId = getOrganizationId();
-initATableValues(tenantId, getDefaultSplits(tenantId), null, 
nextTimestamp()-1, getUrl());
+initATableValues(tenantId, getDefaultSplits(tenantId), getUrl());
 
 upsert = UPSERT INTO  + tableName + (a_id, a_string, b_string) 
 +
 SELECT A_INTEGER, A_STRING, B_STRING FROM ATABLE WHERE 
a_string = ?;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7a16517b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java 
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
index cfa8c4b..1184fdf 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
@@ -20,6 +20,7 @@ package org.apache.phoenix.jdbc;
 import java.sql.SQLException;
 import java.util.Properties;
 
+import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
 
 import org.apache.phoenix.end2end.ConnectionQueryServicesTestImpl;
@@ -42,9 +43,16 @@ import org.apache.phoenix.util.ReadOnlyProps;
 @ThreadSafe
 public class PhoenixTestDriver extends PhoenixEmbeddedDriver {
 
+@GuardedBy(this)
 private ConnectionQueryServices connectionQueryServices;
 private final ReadOnlyProps overrideProps;
+
+@GuardedBy(this)
 private final QueryServices queryServices;
+
+//The only place it is modified is under a lock provided by this. 
+//So ok to have it just as volatile.
+private volatile boolean closed = false;
 
 public PhoenixTestDriver() {
 this.overrideProps = ReadOnlyProps.EMPTY_PROPS;
@@ -58,18 +66,21 @@ public class PhoenixTestDriver extends 
PhoenixEmbeddedDriver {
 }
 
 @Override
-public QueryServices getQueryServices() {
+public synchronized QueryServices getQueryServices() {
+checkClosed();
 return queryServices;
 }
 
 @Override
 public boolean acceptsURL(String url) throws SQLException {
+checkClosed();
 // Accept the url only if test=true attribute set
 return super.acceptsURL(url)  isTestUrl(url);
 }
 
 @Override // public for testing
 public synchronized ConnectionQueryServices 
getConnectionQueryServices(String url, Properties info) throws SQLException {
+checkClosed();
 if (connectionQueryServices != null) { return connectionQueryServices; 
}
 ConnectionInfo connInfo = ConnectionInfo.create(url);
 if (connInfo.isConnectionless()) {
@@ -81,11 +92,26 @@ public class PhoenixTestDriver extends 
PhoenixEmbeddedDriver {
 return connectionQueryServices;
 }
 
+private void checkClosed() {
+if (closed) {
+throw new IllegalStateException(The Phoenix jdbc test driver has 
been closed.);
+}
+}
+
 @Override
 public synchronized void close() throws SQLException {
-connectionQueryServices.close();
-queryServices.close();
+if 

git commit: Additonal query more tests (SamarthJain)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.0 690d8c02e - efd848828


Additonal query more tests (SamarthJain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/efd84882
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/efd84882
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/efd84882

Branch: refs/heads/4.0
Commit: efd848828ecc1802fe7b1d9b616851ffb7cdff56
Parents: 690d8c0
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 15:17:07 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 15:18:16 2014 -0700

--
 .../org/apache/phoenix/end2end/QueryMoreIT.java | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/efd84882/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index e2dd1b8..50b3d47 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -41,18 +41,30 @@ import com.google.common.collect.Lists;
 @Category(HBaseManagedTimeTest.class)
 public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 
-//Cursor table - salted/non-multi-tenant. Data table - 
salted/multi-tenant. 
+//Data table - multi-tenant = true, salted = true 
 @Test
 public void testQueryMore1() throws Exception {
 testQueryMore(true, true);
 }
 
-//Cursor table - salted/non-multi-tenant. Data table - salted/non 
multi-tenant. 
+//Data table - multi-tenant = false, salted = true 
 @Test
 public void testQueryMore2() throws Exception {
 testQueryMore(false, true);
 }
 
+//Data table - multi-tenant = false, salted = false
+@Test
+public void testQueryMore3() throws Exception {
+testQueryMore(false, false);
+}
+
+//Data table - multi-tenant = true, salted = false 
+@Test
+public void testQueryMore4() throws Exception {
+testQueryMore(true, false);
+}
+
 private void testQueryMore(boolean dataTableMultiTenant, boolean 
dataTableSalted) throws Exception {
 String[] tenantIds = new String[] {00Dxtenant1, 
00Dxtenant2, 00Dxtenant3};
 int numRowsPerTenant = 10;



git commit: Additonal query more tests (SamarthJain)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 7a16517b4 - 6057e3e87


Additonal query more tests (SamarthJain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/6057e3e8
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6057e3e8
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6057e3e8

Branch: refs/heads/master
Commit: 6057e3e87ecd6af19607ff20f6441b3fc9332bb9
Parents: 7a16517
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 15:17:07 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 15:18:33 2014 -0700

--
 .../org/apache/phoenix/end2end/QueryMoreIT.java | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/6057e3e8/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index e2dd1b8..50b3d47 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -41,18 +41,30 @@ import com.google.common.collect.Lists;
 @Category(HBaseManagedTimeTest.class)
 public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 
-//Cursor table - salted/non-multi-tenant. Data table - 
salted/multi-tenant. 
+//Data table - multi-tenant = true, salted = true 
 @Test
 public void testQueryMore1() throws Exception {
 testQueryMore(true, true);
 }
 
-//Cursor table - salted/non-multi-tenant. Data table - salted/non 
multi-tenant. 
+//Data table - multi-tenant = false, salted = true 
 @Test
 public void testQueryMore2() throws Exception {
 testQueryMore(false, true);
 }
 
+//Data table - multi-tenant = false, salted = false
+@Test
+public void testQueryMore3() throws Exception {
+testQueryMore(false, false);
+}
+
+//Data table - multi-tenant = true, salted = false 
+@Test
+public void testQueryMore4() throws Exception {
+testQueryMore(true, false);
+}
+
 private void testQueryMore(boolean dataTableMultiTenant, boolean 
dataTableSalted) throws Exception {
 String[] tenantIds = new String[] {00Dxtenant1, 
00Dxtenant2, 00Dxtenant3};
 int numRowsPerTenant = 10;



git commit: Additonal tests for IN list (KyleBuzsaki)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/3.0 3b526970b - e5b1835fb


Additonal tests for IN list (KyleBuzsaki)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e5b1835f
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e5b1835f
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e5b1835f

Branch: refs/heads/3.0
Commit: e5b1835fb928fa5272b9960c6e7812c87e83da45
Parents: 3b52697
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 15:32:46 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 15:32:46 2014 -0700

--
 .../org/apache/phoenix/end2end/InListIT.java| 199 +++
 1 file changed, 199 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e5b1835f/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
index bd9aa1b..9789c46 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
@@ -1,5 +1,6 @@
 package org.apache.phoenix.end2end;
 
+import static java.util.Collections.singletonList;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -8,11 +9,20 @@ import static org.junit.Assert.assertTrue;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Properties;
 
+import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.util.PhoenixRuntime;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
 @Category(ClientManagedTimeTest.class)
 public class InListIT extends BaseHBaseManagedTimeIT {
 
@@ -34,6 +44,8 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 assertTrue(rs.next());
 assertEquals(c, rs.getString(1));
 assertFalse(rs.next());
+
+conn.close();
 }
 
 @Test
@@ -50,5 +62,192 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 assertTrue(rs.next());
 assertEquals(1, rs.getInt(1));
 assertFalse(rs.next());
+
+conn.close();
+}
+
+/**
+ * Builds the DDL statement that will create a table with the given 
properties.
+ * Assumes 5 pk columns of the given type.
+ * Adds a non primary key column named nonPk
+ * @param tableName  the name to use for the table
+ * @param pkType  the data type of the primary key columns
+ * @param saltBuckets  the number of salt buckets if the table is salted, 
otherwise 0
+ * @param isMultiTenant  whether or not the table needs a tenant_id column
+ * @return  the final DDL statement
+ */
+private static String createTableDDL(String tableName, PDataType pkType, 
int saltBuckets, boolean isMultiTenant) {
+StringBuilder ddlBuilder = new StringBuilder();
+ddlBuilder.append(CREATE TABLE ).append(tableName).append( ( );
+
+// column declarations
+if(isMultiTenant) {
+ddlBuilder.append(tenantId VARCHAR(5) NOT NULL, );
+}
+for(int i = 0; i  5; i++) {
+ddlBuilder.append(pk).append(i + 1).append( 
).append(pkType.getSqlTypeName()).append( NOT NULL, );
+}
+ddlBuilder.append(nonPk VARCHAR );
+
+// primary key constraint declaration
+ddlBuilder.append(CONSTRAINT pk PRIMARY KEY ();
+if(isMultiTenant) {
+ddlBuilder.append(tenantId, );
+}
+ddlBuilder.append(pk1, pk2, pk3, pk4, pk5) ) );
+
+// modifier declarations
+if(saltBuckets != 0) {
+ddlBuilder.append(SALT_BUCKETS = ).append(saltBuckets);
+}
+if(saltBuckets != 0  isMultiTenant) {
+ddlBuilder.append(, );
+}
+if(isMultiTenant) {
+ddlBuilder.append(MULTI_TENANT=true);
+}
+
+return ddlBuilder.toString();
+}
+
+/**
+ * Creates a table with the given properties and returns its name. If the 
table is multi-tenant,
+ * also creates a tenant view for that table and returns the name of the 
view instead.
+ * @param baseConn  a non-tenant specific connection. Used to create the 
base tables
+ * @param conn  a tenant-specific connection, if necessary. Otherwise 
ignored.
+ * @param 

git commit: Additonal tests for IN list (KyleBuzsaki)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.0 efd848828 - 094513493


Additonal tests for IN list (KyleBuzsaki)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/09451349
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/09451349
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/09451349

Branch: refs/heads/4.0
Commit: 094513493bb9bfcfafc3839a914feb9345a2f667
Parents: efd8488
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 15:32:46 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 15:33:36 2014 -0700

--
 .../org/apache/phoenix/end2end/InListIT.java| 199 +++
 1 file changed, 199 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/09451349/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
index bd9aa1b..9789c46 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
@@ -1,5 +1,6 @@
 package org.apache.phoenix.end2end;
 
+import static java.util.Collections.singletonList;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -8,11 +9,20 @@ import static org.junit.Assert.assertTrue;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Properties;
 
+import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.util.PhoenixRuntime;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
 @Category(ClientManagedTimeTest.class)
 public class InListIT extends BaseHBaseManagedTimeIT {
 
@@ -34,6 +44,8 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 assertTrue(rs.next());
 assertEquals(c, rs.getString(1));
 assertFalse(rs.next());
+
+conn.close();
 }
 
 @Test
@@ -50,5 +62,192 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 assertTrue(rs.next());
 assertEquals(1, rs.getInt(1));
 assertFalse(rs.next());
+
+conn.close();
+}
+
+/**
+ * Builds the DDL statement that will create a table with the given 
properties.
+ * Assumes 5 pk columns of the given type.
+ * Adds a non primary key column named nonPk
+ * @param tableName  the name to use for the table
+ * @param pkType  the data type of the primary key columns
+ * @param saltBuckets  the number of salt buckets if the table is salted, 
otherwise 0
+ * @param isMultiTenant  whether or not the table needs a tenant_id column
+ * @return  the final DDL statement
+ */
+private static String createTableDDL(String tableName, PDataType pkType, 
int saltBuckets, boolean isMultiTenant) {
+StringBuilder ddlBuilder = new StringBuilder();
+ddlBuilder.append(CREATE TABLE ).append(tableName).append( ( );
+
+// column declarations
+if(isMultiTenant) {
+ddlBuilder.append(tenantId VARCHAR(5) NOT NULL, );
+}
+for(int i = 0; i  5; i++) {
+ddlBuilder.append(pk).append(i + 1).append( 
).append(pkType.getSqlTypeName()).append( NOT NULL, );
+}
+ddlBuilder.append(nonPk VARCHAR );
+
+// primary key constraint declaration
+ddlBuilder.append(CONSTRAINT pk PRIMARY KEY ();
+if(isMultiTenant) {
+ddlBuilder.append(tenantId, );
+}
+ddlBuilder.append(pk1, pk2, pk3, pk4, pk5) ) );
+
+// modifier declarations
+if(saltBuckets != 0) {
+ddlBuilder.append(SALT_BUCKETS = ).append(saltBuckets);
+}
+if(saltBuckets != 0  isMultiTenant) {
+ddlBuilder.append(, );
+}
+if(isMultiTenant) {
+ddlBuilder.append(MULTI_TENANT=true);
+}
+
+return ddlBuilder.toString();
+}
+
+/**
+ * Creates a table with the given properties and returns its name. If the 
table is multi-tenant,
+ * also creates a tenant view for that table and returns the name of the 
view instead.
+ * @param baseConn  a non-tenant specific connection. Used to create the 
base tables
+ * @param conn  a tenant-specific connection, if necessary. Otherwise 
ignored.
+ * @param 

git commit: Additonal tests for IN list (KyleBuzsaki)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 6057e3e87 - 2f1ae8092


Additonal tests for IN list (KyleBuzsaki)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2f1ae809
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2f1ae809
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2f1ae809

Branch: refs/heads/master
Commit: 2f1ae80921a10befecf29f796091dc1103e049ea
Parents: 6057e3e
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 15:32:46 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 15:33:52 2014 -0700

--
 .../org/apache/phoenix/end2end/InListIT.java| 199 +++
 1 file changed, 199 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2f1ae809/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
index bd9aa1b..9789c46 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
@@ -1,5 +1,6 @@
 package org.apache.phoenix.end2end;
 
+import static java.util.Collections.singletonList;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -8,11 +9,20 @@ import static org.junit.Assert.assertTrue;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Properties;
 
+import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.util.PhoenixRuntime;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
 @Category(ClientManagedTimeTest.class)
 public class InListIT extends BaseHBaseManagedTimeIT {
 
@@ -34,6 +44,8 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 assertTrue(rs.next());
 assertEquals(c, rs.getString(1));
 assertFalse(rs.next());
+
+conn.close();
 }
 
 @Test
@@ -50,5 +62,192 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 assertTrue(rs.next());
 assertEquals(1, rs.getInt(1));
 assertFalse(rs.next());
+
+conn.close();
+}
+
+/**
+ * Builds the DDL statement that will create a table with the given 
properties.
+ * Assumes 5 pk columns of the given type.
+ * Adds a non primary key column named nonPk
+ * @param tableName  the name to use for the table
+ * @param pkType  the data type of the primary key columns
+ * @param saltBuckets  the number of salt buckets if the table is salted, 
otherwise 0
+ * @param isMultiTenant  whether or not the table needs a tenant_id column
+ * @return  the final DDL statement
+ */
+private static String createTableDDL(String tableName, PDataType pkType, 
int saltBuckets, boolean isMultiTenant) {
+StringBuilder ddlBuilder = new StringBuilder();
+ddlBuilder.append(CREATE TABLE ).append(tableName).append( ( );
+
+// column declarations
+if(isMultiTenant) {
+ddlBuilder.append(tenantId VARCHAR(5) NOT NULL, );
+}
+for(int i = 0; i  5; i++) {
+ddlBuilder.append(pk).append(i + 1).append( 
).append(pkType.getSqlTypeName()).append( NOT NULL, );
+}
+ddlBuilder.append(nonPk VARCHAR );
+
+// primary key constraint declaration
+ddlBuilder.append(CONSTRAINT pk PRIMARY KEY ();
+if(isMultiTenant) {
+ddlBuilder.append(tenantId, );
+}
+ddlBuilder.append(pk1, pk2, pk3, pk4, pk5) ) );
+
+// modifier declarations
+if(saltBuckets != 0) {
+ddlBuilder.append(SALT_BUCKETS = ).append(saltBuckets);
+}
+if(saltBuckets != 0  isMultiTenant) {
+ddlBuilder.append(, );
+}
+if(isMultiTenant) {
+ddlBuilder.append(MULTI_TENANT=true);
+}
+
+return ddlBuilder.toString();
+}
+
+/**
+ * Creates a table with the given properties and returns its name. If the 
table is multi-tenant,
+ * also creates a tenant view for that table and returns the name of the 
view instead.
+ * @param baseConn  a non-tenant specific connection. Used to create the 
base tables
+ * @param conn  a tenant-specific connection, if necessary. Otherwise 
ignored.
+ * 

Apache-Phoenix | 4.0 | Hadoop1 | Build Successful

2014-07-24 Thread Apache Jenkins Server
4.0 branch build status Successful

Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Compiled Artifacts https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastSuccessfulBuild/artifact/

Test Report https://builds.apache.org/job/Phoenix-4.0-hadoop1/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1109 PhoenixTestDriver needs to call shutdown on executor (SamarthJain)

[jtaylor] Additonal query more tests (SamarthJain)



Apache-Phoenix | Master | Hadoop1 | Build Successful

2014-07-24 Thread Apache Jenkins Server
Master branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-master-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-master-hadoop1/lastCompletedBuild/testReport/

Changes
[jtaylor] Additonal tests for IN list (KyleBuzsaki)



Apache-Phoenix | 3.0 | Hadoop1 | Build Successful

2014-07-24 Thread Apache Jenkins Server
3.0 branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1083 IN list of RVC combined with AND doesn't return expected rows

[jtaylor] PHOENIX-1110 Fix flappy MultiCfQueryExecIT

[jtaylor] PHOENIX-1109 PhoenixTestDriver needs to call shutdown on executor (SamarthJain)

[jtaylor] Additonal query more tests (SamarthJain)

[jtaylor] Additonal tests for IN list (KyleBuzsaki)



git commit: Better test coverage for IN list with RVC (KyleBuzsaki)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 2f1ae8092 - 3d3bbe219


Better test coverage for IN list with RVC (KyleBuzsaki)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3d3bbe21
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3d3bbe21
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3d3bbe21

Branch: refs/heads/master
Commit: 3d3bbe2197cacdb5baa1e0ff7c6719a93cfe497c
Parents: 2f1ae80
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 22:48:23 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 22:53:13 2014 -0700

--
 .../org/apache/phoenix/end2end/InListIT.java| 166 ++-
 1 file changed, 159 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3d3bbe21/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
index 9789c46..19e5037 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
@@ -22,6 +22,7 @@ import org.junit.experimental.categories.Category;
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
 import com.google.common.collect.Lists;
+import java.util.Collections;
 
 @Category(ClientManagedTimeTest.class)
 public class InListIT extends BaseHBaseManagedTimeIT {
@@ -211,16 +212,87 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 }
 });
 
+// test variations used:
+// 1. queries with no results
+// 2. queries with fully qualified row keys
+// 3. queries with partiall qualified row keys, starting from the beginning
+// 4. queries with partially qualified row keys, but not the beginning
+// 5. queries with partially qualified row keys with a hole slot in the 
middle
+
 @Test
-public void testLeadingPKWithTrailingRVC3() throws Exception {
-String whereClause = WHERE pk1 = 2 AND (pk3, pk4, pk5) IN ((4, 5, 6), 
(5, 6, 4));
+public void testPlainRVCNoResults() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk3, pk4, pk5) IN ((1, 2, 3, 4, 
5), (1, 2, 4, 5, 3));
+ListString expecteds = Collections.StringemptyList();
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCFullyQualified() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk3, pk4, pk5) IN ((1, 2, 3, 4, 
5), (1, 2, 4, 5, 6));
+ListString expecteds = singletonList(row1);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCPartiallyQualifiedBegin() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk3, pk4) IN ((2, 3, 4, 5), (1, 
2, 4, 5));
+ListString expecteds = Arrays.asList(row1, row2);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCPartiallyQualifiedEnd() throws Exception {
+String whereClause = WHERE (pk2, pk3, pk4, pk5) IN ((2, 3, 4, 5), (2, 
4, 5, 6));
+ListString expecteds = singletonList(row1);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCSlotHole() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk4, pk5) IN ((1, 2, 4, 5), (6, 
5, 3, 2));
+ListString expecteds = singletonList(row4);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testLeadingPKWithTrailingRVCNoResults() throws Exception {
+String whereClause = WHERE pk1 != 2 AND (pk3, pk4, pk5) IN ((6, 4, 
5), (5, 6, 4));
+ListString expecteds = Collections.StringemptyList();
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testLeadingPKWithTrailingRVCFullyQualified() throws Exception {
+String whereClause = WHERE pk1 = 2 AND (pk2, pk3, pk4, pk5) IN ((2, 
4, 5, 6), (3, 4, 5, 6));
 ListString expecteds = singletonList(row2);
 
 testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
 }
 
 @Test
-public void 

git commit: Better test coverage for IN list with RVC (KyleBuzsaki)

2014-07-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.0 094513493 - 9fad9b529


Better test coverage for IN list with RVC (KyleBuzsaki)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9fad9b52
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9fad9b52
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9fad9b52

Branch: refs/heads/4.0
Commit: 9fad9b5291ee94eee2a9461e0fd7874415e9c6c1
Parents: 0945134
Author: James Taylor jtay...@salesforce.com
Authored: Thu Jul 24 22:48:23 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Thu Jul 24 22:49:13 2014 -0700

--
 .../org/apache/phoenix/end2end/InListIT.java| 166 ++-
 1 file changed, 159 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9fad9b52/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
--
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
index 9789c46..19e5037 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java
@@ -22,6 +22,7 @@ import org.junit.experimental.categories.Category;
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
 import com.google.common.collect.Lists;
+import java.util.Collections;
 
 @Category(ClientManagedTimeTest.class)
 public class InListIT extends BaseHBaseManagedTimeIT {
@@ -211,16 +212,87 @@ public class InListIT extends BaseHBaseManagedTimeIT {
 }
 });
 
+// test variations used:
+// 1. queries with no results
+// 2. queries with fully qualified row keys
+// 3. queries with partiall qualified row keys, starting from the beginning
+// 4. queries with partially qualified row keys, but not the beginning
+// 5. queries with partially qualified row keys with a hole slot in the 
middle
+
 @Test
-public void testLeadingPKWithTrailingRVC3() throws Exception {
-String whereClause = WHERE pk1 = 2 AND (pk3, pk4, pk5) IN ((4, 5, 6), 
(5, 6, 4));
+public void testPlainRVCNoResults() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk3, pk4, pk5) IN ((1, 2, 3, 4, 
5), (1, 2, 4, 5, 3));
+ListString expecteds = Collections.StringemptyList();
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCFullyQualified() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk3, pk4, pk5) IN ((1, 2, 3, 4, 
5), (1, 2, 4, 5, 6));
+ListString expecteds = singletonList(row1);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCPartiallyQualifiedBegin() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk3, pk4) IN ((2, 3, 4, 5), (1, 
2, 4, 5));
+ListString expecteds = Arrays.asList(row1, row2);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCPartiallyQualifiedEnd() throws Exception {
+String whereClause = WHERE (pk2, pk3, pk4, pk5) IN ((2, 3, 4, 5), (2, 
4, 5, 6));
+ListString expecteds = singletonList(row1);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testPlainRVCSlotHole() throws Exception {
+String whereClause = WHERE (pk1, pk2, pk4, pk5) IN ((1, 2, 4, 5), (6, 
5, 3, 2));
+ListString expecteds = singletonList(row4);
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testLeadingPKWithTrailingRVCNoResults() throws Exception {
+String whereClause = WHERE pk1 != 2 AND (pk3, pk4, pk5) IN ((6, 4, 
5), (5, 6, 4));
+ListString expecteds = Collections.StringemptyList();
+
+testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
+}
+
+@Test
+public void testLeadingPKWithTrailingRVCFullyQualified() throws Exception {
+String whereClause = WHERE pk1 = 2 AND (pk2, pk3, pk4, pk5) IN ((2, 
4, 5, 6), (3, 4, 5, 6));
 ListString expecteds = singletonList(row2);
 
 testWithIntegerTypesWithVariedSaltingAndTenancy(DEFAULT_UPSERT_BODIES, 
whereClause, expecteds);
 }
 
 @Test
-public void testLeadingPKWithTrailingRVC4()