[4/5] git commit: PHOENIX-619 Support DELETE over table with immutable index when possible

2014-10-14 Thread jamestaylor
PHOENIX-619 Support DELETE over table with immutable index when possible

Conflicts:

phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java

phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java

phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java

phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java


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

Branch: refs/heads/3.0
Commit: 88121cb05b5aa911e7cc27ff5306423299d5d1b6
Parents: 9777b6c
Author: James Taylor jtay...@salesforce.com
Authored: Mon Oct 13 20:23:43 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Mon Oct 13 23:41:27 2014 -0700

--
 .../end2end/BaseTenantSpecificTablesIT.java |   4 +-
 .../end2end/TenantSpecificTablesDMLIT.java  |  43 ++
 .../phoenix/end2end/index/ImmutableIndexIT.java |   2 +-
 .../phoenix/end2end/index/ViewIndexIT.java  |  87 +++
 .../apache/phoenix/compile/DeleteCompiler.java  | 541 ---
 .../MutatingParallelIteratorFactory.java|   5 +-
 .../phoenix/compile/PostIndexDDLCompiler.java   |  37 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   4 +-
 .../phoenix/exception/SQLExceptionCode.java |   2 +-
 .../apache/phoenix/execute/MutationState.java   |  44 +-
 .../apache/phoenix/jdbc/PhoenixResultSet.java   |   4 +
 .../apache/phoenix/optimize/QueryOptimizer.java |  55 +-
 .../query/ConnectionQueryServicesImpl.java  |   1 +
 .../java/org/apache/phoenix/util/IndexUtil.java |  14 +-
 .../phoenix/compile/QueryCompilerTest.java  |  14 +-
 .../TenantSpecificViewIndexCompileTest.java |   2 +-
 16 files changed, 600 insertions(+), 259 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/88121cb0/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
index 362fa08..6d6bffc 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
@@ -44,7 +44,7 @@ public abstract class BaseTenantSpecificTablesIT extends 
BaseOwnClusterClientMan
 tenant_id VARCHAR(5) NOT NULL,\n + 
 tenant_type_id VARCHAR(3) NOT NULL, \n + 
 id INTEGER NOT NULL\n + 
-CONSTRAINT pk PRIMARY KEY (tenant_id, 
tenant_type_id, id)) MULTI_TENANT=true;
+CONSTRAINT pk PRIMARY KEY (tenant_id, 
tenant_type_id, id)) MULTI_TENANT=true, IMMUTABLE_ROWS=true;
 
 protected static final String TENANT_TABLE_NAME = TENANT_TABLE;
 protected static final String TENANT_TABLE_DDL = CREATE VIEW  + 
TENANT_TABLE_NAME +  ( \n + 
@@ -56,7 +56,7 @@ public abstract class BaseTenantSpecificTablesIT extends 
BaseOwnClusterClientMan
 user VARCHAR ,\n + 
 tenant_id VARCHAR(5) NOT NULL,\n + 
 id INTEGER NOT NULL,\n + 
-CONSTRAINT pk PRIMARY KEY (tenant_id, id)) 
MULTI_TENANT=true;
+CONSTRAINT pk PRIMARY KEY (tenant_id, id)) 
MULTI_TENANT=true, IMMUTABLE_ROWS=true;
 
 protected static final String TENANT_TABLE_NAME_NO_TENANT_TYPE_ID = 
TENANT_TABLE_NO_TENANT_TYPE_ID;
 protected static final String TENANT_TABLE_DDL_NO_TENANT_TYPE_ID = CREATE 
VIEW  + TENANT_TABLE_NAME_NO_TENANT_TYPE_ID +  ( \n + 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/88121cb0/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
index 76a8c7c..7fd3a82 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
@@ -265,6 +265,49 @@ public class TenantSpecificTablesDMLIT extends 

git commit: PHOENIX-619 Support DELETE over table with immutable index when possible

2014-10-13 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 49ec34be2 - 8f2a76d60


PHOENIX-619 Support DELETE over table with immutable index when possible


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

Branch: refs/heads/master
Commit: 8f2a76d60ba1452466133da8e1dc3de8d1140ed2
Parents: 49ec34b
Author: James Taylor jtay...@salesforce.com
Authored: Mon Oct 13 20:23:43 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Mon Oct 13 20:23:43 2014 -0700

--
 .../end2end/BaseTenantSpecificTablesIT.java |   4 +-
 .../end2end/TenantSpecificTablesDMLIT.java  |  43 ++
 .../phoenix/end2end/index/ImmutableIndexIT.java |   2 +-
 .../phoenix/end2end/index/ViewIndexIT.java  |   5 +-
 .../apache/phoenix/compile/DeleteCompiler.java  | 550 ---
 .../MutatingParallelIteratorFactory.java|   5 +-
 .../phoenix/compile/PostIndexDDLCompiler.java   |  37 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   4 +-
 .../phoenix/exception/SQLExceptionCode.java |   2 +-
 .../apache/phoenix/execute/MutationState.java   |  45 +-
 .../apache/phoenix/jdbc/PhoenixResultSet.java   |   4 +
 .../apache/phoenix/optimize/QueryOptimizer.java |  53 +-
 .../query/ConnectionQueryServicesImpl.java  |   2 +
 .../apache/phoenix/schema/MetaDataClient.java   |  48 +-
 .../java/org/apache/phoenix/util/IndexUtil.java |  14 +-
 .../phoenix/compile/QueryCompilerTest.java  |  14 +-
 .../TenantSpecificViewIndexCompileTest.java |   2 +-
 17 files changed, 541 insertions(+), 293 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/8f2a76d6/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
index 362fa08..6d6bffc 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
@@ -44,7 +44,7 @@ public abstract class BaseTenantSpecificTablesIT extends 
BaseOwnClusterClientMan
 tenant_id VARCHAR(5) NOT NULL,\n + 
 tenant_type_id VARCHAR(3) NOT NULL, \n + 
 id INTEGER NOT NULL\n + 
-CONSTRAINT pk PRIMARY KEY (tenant_id, 
tenant_type_id, id)) MULTI_TENANT=true;
+CONSTRAINT pk PRIMARY KEY (tenant_id, 
tenant_type_id, id)) MULTI_TENANT=true, IMMUTABLE_ROWS=true;
 
 protected static final String TENANT_TABLE_NAME = TENANT_TABLE;
 protected static final String TENANT_TABLE_DDL = CREATE VIEW  + 
TENANT_TABLE_NAME +  ( \n + 
@@ -56,7 +56,7 @@ public abstract class BaseTenantSpecificTablesIT extends 
BaseOwnClusterClientMan
 user VARCHAR ,\n + 
 tenant_id VARCHAR(5) NOT NULL,\n + 
 id INTEGER NOT NULL,\n + 
-CONSTRAINT pk PRIMARY KEY (tenant_id, id)) 
MULTI_TENANT=true;
+CONSTRAINT pk PRIMARY KEY (tenant_id, id)) 
MULTI_TENANT=true, IMMUTABLE_ROWS=true;
 
 protected static final String TENANT_TABLE_NAME_NO_TENANT_TYPE_ID = 
TENANT_TABLE_NO_TENANT_TYPE_ID;
 protected static final String TENANT_TABLE_DDL_NO_TENANT_TYPE_ID = CREATE 
VIEW  + TENANT_TABLE_NAME_NO_TENANT_TYPE_ID +  ( \n + 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8f2a76d6/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
index f0ed1d0..cdc3c07 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
@@ -267,6 +267,49 @@ public class TenantSpecificTablesDMLIT extends 
BaseTenantSpecificTablesIT {
 }
 
 @Test
+public void testDeleteWhenImmutableIndex() throws Exception {
+Connection conn = nextConnection(getUrl());
+try {
+conn.setAutoCommit(true);
+conn.createStatement().executeUpdate(delete from  + 
PARENT_TABLE_NAME);
+conn.close();
+
+conn = 

git commit: PHOENIX-619 Support DELETE over table with immutable index when possible

2014-10-13 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.0 ae51cae69 - 6c47f8a2b


PHOENIX-619 Support DELETE over table with immutable index when possible


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

Branch: refs/heads/4.0
Commit: 6c47f8a2ba19f00db9369df1f7efdfdf0fbfd5f2
Parents: ae51cae
Author: James Taylor jtay...@salesforce.com
Authored: Mon Oct 13 20:23:43 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Mon Oct 13 22:58:24 2014 -0700

--
 .../end2end/BaseTenantSpecificTablesIT.java |   4 +-
 .../end2end/TenantSpecificTablesDMLIT.java  |  43 ++
 .../phoenix/end2end/index/ImmutableIndexIT.java |   2 +-
 .../phoenix/end2end/index/ViewIndexIT.java  |   5 +-
 .../apache/phoenix/compile/DeleteCompiler.java  | 550 ---
 .../MutatingParallelIteratorFactory.java|   5 +-
 .../phoenix/compile/PostIndexDDLCompiler.java   |  37 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   4 +-
 .../phoenix/exception/SQLExceptionCode.java |   2 +-
 .../apache/phoenix/execute/MutationState.java   |  45 +-
 .../apache/phoenix/jdbc/PhoenixResultSet.java   |   4 +
 .../apache/phoenix/optimize/QueryOptimizer.java |  53 +-
 .../query/ConnectionQueryServicesImpl.java  |   2 +
 .../apache/phoenix/schema/MetaDataClient.java   |  48 +-
 .../java/org/apache/phoenix/util/IndexUtil.java |  14 +-
 .../phoenix/compile/QueryCompilerTest.java  |  14 +-
 .../TenantSpecificViewIndexCompileTest.java |   2 +-
 17 files changed, 541 insertions(+), 293 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/6c47f8a2/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
index 362fa08..6d6bffc 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java
@@ -44,7 +44,7 @@ public abstract class BaseTenantSpecificTablesIT extends 
BaseOwnClusterClientMan
 tenant_id VARCHAR(5) NOT NULL,\n + 
 tenant_type_id VARCHAR(3) NOT NULL, \n + 
 id INTEGER NOT NULL\n + 
-CONSTRAINT pk PRIMARY KEY (tenant_id, 
tenant_type_id, id)) MULTI_TENANT=true;
+CONSTRAINT pk PRIMARY KEY (tenant_id, 
tenant_type_id, id)) MULTI_TENANT=true, IMMUTABLE_ROWS=true;
 
 protected static final String TENANT_TABLE_NAME = TENANT_TABLE;
 protected static final String TENANT_TABLE_DDL = CREATE VIEW  + 
TENANT_TABLE_NAME +  ( \n + 
@@ -56,7 +56,7 @@ public abstract class BaseTenantSpecificTablesIT extends 
BaseOwnClusterClientMan
 user VARCHAR ,\n + 
 tenant_id VARCHAR(5) NOT NULL,\n + 
 id INTEGER NOT NULL,\n + 
-CONSTRAINT pk PRIMARY KEY (tenant_id, id)) 
MULTI_TENANT=true;
+CONSTRAINT pk PRIMARY KEY (tenant_id, id)) 
MULTI_TENANT=true, IMMUTABLE_ROWS=true;
 
 protected static final String TENANT_TABLE_NAME_NO_TENANT_TYPE_ID = 
TENANT_TABLE_NO_TENANT_TYPE_ID;
 protected static final String TENANT_TABLE_DDL_NO_TENANT_TYPE_ID = CREATE 
VIEW  + TENANT_TABLE_NAME_NO_TENANT_TYPE_ID +  ( \n + 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6c47f8a2/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
index f0ed1d0..cdc3c07 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java
@@ -267,6 +267,49 @@ public class TenantSpecificTablesDMLIT extends 
BaseTenantSpecificTablesIT {
 }
 
 @Test
+public void testDeleteWhenImmutableIndex() throws Exception {
+Connection conn = nextConnection(getUrl());
+try {
+conn.setAutoCommit(true);
+conn.createStatement().executeUpdate(delete from  + 
PARENT_TABLE_NAME);
+conn.close();
+
+conn =