phoenix git commit: PHOENIX-4462 Fix license issues with rat plugin (Pedro Boado)

2017-12-16 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.11.2 a50bf3e5f -> 716a38a94


PHOENIX-4462 Fix license issues with rat plugin (Pedro Boado)


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

Branch: refs/heads/4.x-cdh5.11.2
Commit: 716a38a946d984fce42714d19f3b742cf8639e92
Parents: a50bf3e
Author: James Taylor 
Authored: Sat Dec 16 16:46:59 2017 -0800
Committer: James Taylor 
Committed: Sat Dec 16 16:46:59 2017 -0800

--
 .../apache/phoenix/end2end/SystemCatalogIT.java | 17 +
 phoenix-parcel/pom.xml  |  9 +
 .../src/parcel/bin/phoenix-performance.py   | 20 
 phoenix-parcel/src/parcel/bin/phoenix-psql.py   | 20 
 .../src/parcel/bin/phoenix-sqlline.py   | 20 
 phoenix-parcel/src/parcel/bin/phoenix-utils.py  | 20 
 .../src/parcel/cloudera/cdh_version.properties  | 19 +++
 phoenix-parcel/src/parcel/meta/phoenix_env.sh   | 20 
 .../org/apache/phoenix/end2end/KdcUtil.java | 17 +
 9 files changed, 162 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/716a38a9/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogIT.java
index 8a9bca2..a754cb6 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogIT.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.phoenix.end2end;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/716a38a9/phoenix-parcel/pom.xml
--
diff --git a/phoenix-parcel/pom.xml b/phoenix-parcel/pom.xml
index 26f3cee..5498c0e 100644
--- a/phoenix-parcel/pom.xml
+++ b/phoenix-parcel/pom.xml
@@ -108,6 +108,15 @@
   
 
   
+  
+org.apache.rat
+apache-rat-plugin
+
+  
+**/*.json
+  
+
+  
 
   
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/716a38a9/phoenix-parcel/src/parcel/bin/phoenix-performance.py
--
diff --git a/phoenix-parcel/src/parcel/bin/phoenix-performance.py 
b/phoenix-parcel/src/parcel/bin/phoenix-performance.py
index e51a298..6916d17 100755
--- a/phoenix-parcel/src/parcel/bin/phoenix-performance.py
+++ b/phoenix-parcel/src/parcel/bin/phoenix-performance.py
@@ -1,4 +1,24 @@
 #!/bin/bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
   # Reference: 

[12/16] phoenix git commit: PHOENIX-672 Add GRANT and REVOKE commands using HBase AccessController

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd72ce3d/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
index 971383b..8666bb8 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
@@ -16,144 +16,53 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
 import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.AuthUtil;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.NamespaceDescriptor;
-import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.security.AccessDeniedException;
 import org.apache.hadoop.hbase.security.access.AccessControlClient;
 import org.apache.hadoop.hbase.security.access.Permission.Action;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.phoenix.exception.PhoenixIOException;
-import org.apache.phoenix.query.QueryServices;
-import org.apache.phoenix.util.MetaDataUtil;
 import org.apache.phoenix.util.SchemaUtil;
-import org.junit.After;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import com.google.common.collect.Maps;
 
 /**
  * Test that verifies a user can read Phoenix tables with a minimal set of 
permissions.
  */
 @Category(NeedsOwnMiniClusterTest.class)
-@RunWith(Parameterized.class)
-public class TableDDLPermissionsIT{
-private static String SUPERUSER;
-
-private static HBaseTestingUtility testUtil;
-
-private static final Set PHOENIX_SYSTEM_TABLES = new 
HashSet<>(Arrays.asList(
-"SYSTEM.CATALOG", "SYSTEM.SEQUENCE", "SYSTEM.STATS", 
"SYSTEM.FUNCTION",
-"SYSTEM.MUTEX"));
-// PHOENIX- SYSTEM.MUTEX isn't being created in the SYSTEM namespace 
as it should be.
-private static final Set PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES = 
new HashSet<>(
-Arrays.asList("SYSTEM:CATALOG", "SYSTEM:SEQUENCE", "SYSTEM:STATS", 
"SYSTEM:FUNCTION",
-"SYSTEM.MUTEX"));
-private static final String GROUP_SYSTEM_ACCESS = "group_system_access";
-final UserGroupInformation superUser = 
UserGroupInformation.createUserForTesting(SUPERUSER, new String[0]);
-final UserGroupInformation superUser2 = 
UserGroupInformation.createUserForTesting("superuser", new String[0]);
-final UserGroupInformation regularUser = 
UserGroupInformation.createUserForTesting("user",  new String[0]);
-final UserGroupInformation groupUser = 
UserGroupInformation.createUserForTesting("user2", new String[] { 
GROUP_SYSTEM_ACCESS });
-final UserGroupInformation unprivilegedUser = 
UserGroupInformation.createUserForTesting("unprivilegedUser",
-new String[0]);
-
+public class TableDDLPermissionsIT extends BasePermissionsIT {
 
-private static final int NUM_RECORDS = 5;
-
-private boolean isNamespaceMapped;
-
-public TableDDLPermissionsIT(final boolean isNamespaceMapped) throws 
Exception {
-this.isNamespaceMapped = isNamespaceMapped;
-Map clientProps = Maps.newHashMapWithExpectedSize(1);
-clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true");
+public TableDDLPermissionsIT(boolean isNamespaceMapped) throws Exception {
+super(isNamespaceMapped);
 }
 
-private void startNewMiniCluster(Configuration overrideConf) throws 
Exception{
-if (null != testUtil) {
-testUtil.shutdownMiniCluster();
-testUtil = null;
-}
-testUtil = new HBaseTestingUtility();
-
-Configuration config = testUtil.getConfiguration();
-
-config.set("hbase.coprocessor.master.classes",
-

[11/16] phoenix git commit: PHOENIX-4322 DESC primary key column with variable length does not work in SkipScanFilter

2017-12-16 Thread jamestaylor
PHOENIX-4322 DESC primary key column with variable length does not work in 
SkipScanFilter


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 7e61234047b3107cd0b69bae860118c31e2e9927
Parents: 597764c
Author: maryannxue 
Authored: Sun Nov 5 02:37:55 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../it/java/org/apache/phoenix/end2end/SortOrderIT.java  | 11 ++-
 .../expression/RowValueConstructorExpression.java|  4 ++--
 2 files changed, 12 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7e612340/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
index 655dbb1..3f749c1 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
@@ -167,7 +167,16 @@ public class SortOrderIT extends ParallelStatsDisabledIT {
 runQueryTest(ddl, upsert("oid", "code"), insertedRows, new 
Object[][]{{"o2", 2}}, new WhereCondition("oid", "IN", "('o2')"),
 table);
 }
-
+
+@Test
+public void inDescCompositePK3() throws Exception {
+String table = generateUniqueName();
+String ddl = "CREATE table " + table + " (oid VARCHAR NOT NULL, code 
VARCHAR NOT NULL constraint pk primary key (oid DESC, code DESC))";
+Object[][] insertedRows = new Object[][]{{"o1", "1"}, {"o2", "2"}, 
{"o3", "3"}};
+runQueryTest(ddl, upsert("oid", "code"), insertedRows, new 
Object[][]{{"o2", "2"}, {"o1", "1"}}, new WhereCondition("(oid, code)", "IN", 
"(('o2', '2'), ('o1', '1'))"),
+table);
+}
+
 @Test
 public void likeDescCompositePK1() throws Exception {
 String table = generateUniqueName();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7e612340/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
index 15f6e3e..9bb7234 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
@@ -199,8 +199,8 @@ public class RowValueConstructorExpression extends 
BaseCompoundExpression {
 // as otherwise we need it to ensure sort order is correct
 for (int k = expressionCount -1 ; 
 k >=0 &&  getChildren().get(k).getDataType() != 
null 
-  && 
!getChildren().get(k).getDataType().isFixedWidth() 
-  && outputBytes[outputSize-1] == 
QueryConstants.SEPARATOR_BYTE ; k--) {
+  && 
!getChildren().get(k).getDataType().isFixedWidth()
+  && outputBytes[outputSize-1] == 
SchemaUtil.getSeparatorByte(true, false, getChildren().get(k)) ; k--) {
 outputSize--;
 }
 ptr.set(outputBytes, 0, outputSize);



[07/16] phoenix git commit: PHOENIX-4386 Calculate the estimatedSize of MutationState using Map<TableRef, Map<ImmutableBytesPtr, RowMutationState>> mutations (addendum)

2017-12-16 Thread jamestaylor
PHOENIX-4386 Calculate the estimatedSize of MutationState using Map> mutations (addendum)


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

Branch: refs/heads/4.x-HBase-1.2
Commit: eb0f744dc1f453e559cc8f9722122f6ed8daf739
Parents: a6db039
Author: Thomas D'Silva 
Authored: Tue Nov 21 03:13:53 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../apache/phoenix/execute/PartialCommitIT.java |   5 +-
 .../apache/phoenix/compile/DeleteCompiler.java  |  11 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   7 +-
 .../apache/phoenix/execute/MutationState.java   | 127 ---
 .../java/org/apache/phoenix/util/IndexUtil.java |   4 +-
 .../org/apache/phoenix/util/KeyValueUtil.java   |   5 +-
 6 files changed, 98 insertions(+), 61 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/eb0f744d/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
index 10fd7f8..e5b57e3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
@@ -33,7 +33,6 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
@@ -52,8 +51,8 @@ import 
org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.end2end.BaseOwnClusterIT;
+import org.apache.phoenix.execute.MutationState.MultiRowMutationState;
 import org.apache.phoenix.hbase.index.Indexer;
-import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.monitoring.GlobalMetric;
 import org.apache.phoenix.monitoring.MetricType;
@@ -285,7 +284,7 @@ public class PartialCommitIT extends BaseOwnClusterIT {
 private PhoenixConnection 
getConnectionWithTableOrderPreservingMutationState() throws SQLException {
 Connection con = driver.connect(url, new Properties());
 PhoenixConnection phxCon = new 
PhoenixConnection(con.unwrap(PhoenixConnection.class));
-final 
Map> mutations = 
Maps.newTreeMap(new TableRefComparator());
+final Map mutations = 
Maps.newTreeMap(new TableRefComparator());
 // passing a null mutation state forces the 
connection.newMutationState() to be used to create the MutationState
 return new PhoenixConnection(phxCon, null) {
 @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/eb0f744d/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
index f9ca300..a06e2ca 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
@@ -26,7 +26,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.hadoop.hbase.Cell;
@@ -43,6 +42,7 @@ import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.execute.AggregatePlan;
 import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.execute.MutationState.MultiRowMutationState;
 import org.apache.phoenix.execute.MutationState.RowMutationState;
 import org.apache.phoenix.filter.SkipScanFilter;
 import org.apache.phoenix.hbase.index.ValueGetter;
@@ -91,7 +91,6 @@ import org.apache.phoenix.util.ScanUtil;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import com.sun.istack.NotNull;
 
 public class DeleteCompiler {
@@ -121,14 +120,14 @@ public class DeleteCompiler {
 final int maxSize = 

[13/16] phoenix git commit: PHOENIX-672 Add GRANT and REVOKE commands using HBase AccessController

2017-12-16 Thread jamestaylor
PHOENIX-672 Add GRANT and REVOKE commands using HBase AccessController


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

Branch: refs/heads/4.x-HBase-1.2
Commit: bd72ce3d4bb8943a46b1431380d7db9a0dcbf339
Parents: 493a54f
Author: Karan Mehta 
Authored: Wed Nov 29 02:37:55 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../phoenix/end2end/BasePermissionsIT.java  | 754 +++
 .../phoenix/end2end/ChangePermissionsIT.java| 269 +++
 .../end2end/SystemTablePermissionsIT.java   | 226 +-
 .../phoenix/end2end/TableDDLPermissionsIT.java  | 583 ++
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |  30 +-
 .../coprocessor/PhoenixAccessController.java|  29 +-
 .../phoenix/exception/SQLExceptionCode.java |   1 +
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  40 +-
 .../phoenix/parse/ChangePermsStatement.java | 102 +++
 .../apache/phoenix/parse/ParseNodeFactory.java  |   7 +-
 .../query/ConnectionQueryServicesImpl.java  |  24 +-
 .../apache/phoenix/query/QueryConstants.java|   1 +
 .../org/apache/phoenix/query/QueryServices.java |   2 -
 .../phoenix/query/QueryServicesOptions.java |   8 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 138 
 .../schema/TablesNotInSyncException.java|  22 +
 .../org/apache/phoenix/util/SchemaUtil.java |  25 +-
 .../apache/phoenix/parse/QueryParserTest.java   |  46 +-
 18 files changed, 1544 insertions(+), 763 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd72ce3d/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java
new file mode 100644
index 000..9d7ef1b
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java
@@ -0,0 +1,754 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Throwables;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.AuthUtil;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.security.AccessDeniedException;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.security.access.AccessControlClient;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.jdbc.PhoenixStatement;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.QueryUtil;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.PrivilegedExceptionAction;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;

[10/16] phoenix git commit: PHOENIX-4198 Remove the need for users to have access to the Phoenix SYSTEM tables to create tables

2017-12-16 Thread jamestaylor
PHOENIX-4198 Remove the need for users to have access to the Phoenix SYSTEM 
tables to create tables


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 493a54f9fdca2c7dcdae8802ca1208b1e8fdfd33
Parents: d523350
Author: Ankit Singhal 
Authored: Thu Nov 9 02:37:55 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../phoenix/end2end/TableDDLPermissionsIT.java  | 692 +++
 .../org/apache/hadoop/hbase/ipc/RpcUtil.java|  32 +
 .../BaseMetaDataEndpointObserver.java   | 111 +++
 .../coprocessor/MetaDataEndpointImpl.java   | 339 +++--
 .../coprocessor/MetaDataEndpointObserver.java   |  68 ++
 .../coprocessor/MetaDataRegionObserver.java |  17 +-
 .../coprocessor/PhoenixAccessController.java| 628 +
 .../PhoenixMetaDataCoprocessorHost.java | 236 +++
 .../index/PhoenixIndexFailurePolicy.java| 109 +--
 .../query/ConnectionQueryServicesImpl.java  |  15 +-
 .../org/apache/phoenix/query/QueryServices.java |   4 +
 .../phoenix/query/QueryServicesOptions.java |  14 +-
 .../phoenix/schema/stats/StatisticsWriter.java  |  42 +-
 .../org/apache/phoenix/util/MetaDataUtil.java   |  18 +
 .../org/apache/phoenix/util/SchemaUtil.java |  12 +
 15 files changed, 2196 insertions(+), 141 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/493a54f9/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
new file mode 100644
index 000..971383b
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableDDLPermissionsIT.java
@@ -0,0 +1,692 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.PrivilegedExceptionAction;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.AuthUtil;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.security.AccessDeniedException;
+import org.apache.hadoop.hbase.security.access.AccessControlClient;
+import org.apache.hadoop.hbase.security.access.Permission.Action;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.phoenix.exception.PhoenixIOException;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import com.google.common.collect.Maps;

[05/16] phoenix git commit: PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

2017-12-16 Thread jamestaylor
PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

Signed-off-by: aertoria 


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

Branch: refs/heads/4.x-HBase-1.2
Commit: bab1e46eba7ccd6b1f21dcd62a0dfc40a90e97d1
Parents: a23439c
Author: Chinmay Kulkarni 
Authored: Thu Nov 16 02:31:20 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../org/apache/phoenix/query/ConnectionQueryServicesImpl.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/bab1e46e/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 532b586..874ac9c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1721,7 +1721,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 Set tableDescriptors = Collections.emptySet();
 Set origTableDescriptors = Collections.emptySet();
 boolean nonTxToTx = false;
-Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, families, tableProps);
+Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, tableProps);
 HTableDescriptor tableDescriptor = tableDescriptorPair.getSecond();
 HTableDescriptor origTableDescriptor = tableDescriptorPair.getFirst();
 if (tableDescriptor != null) {
@@ -1939,7 +1939,8 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 this.addCoprocessors(tableDescriptor.getName(), tableDescriptor, 
tableType, tableProps);
 }
 
-private Pair 
separateAndValidateProperties(PTable table, Map>> properties, Set colFamiliesForPColumnsToBeAdded, 
List>> families, Map 
tableProps) throws SQLException {
+private Pair 
separateAndValidateProperties(PTable table, Map>> properties,
+  Set colFamiliesForPColumnsToBeAdded, Map 
tableProps) throws SQLException {
 Map> stmtFamiliesPropsMap = new 
HashMap<>(properties.size());
 Map commonFamilyProps = new HashMap<>();
 boolean addingColumns = colFamiliesForPColumnsToBeAdded != null && 
!colFamiliesForPColumnsToBeAdded.isEmpty();



[14/16] phoenix git commit: PHOENIX-3050 Handle DESC columns in child/parent join optimization

2017-12-16 Thread jamestaylor
PHOENIX-3050 Handle DESC columns in child/parent join optimization


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 4968e88e6d5f4d650ee05303dbce8baa5c911087
Parents: 7e61234
Author: maryannxue 
Authored: Mon Nov 6 02:37:55 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../phoenix/end2end/join/HashJoinMoreIT.java |  5 +
 .../org/apache/phoenix/compile/JoinCompiler.java | 19 +--
 .../apache/phoenix/compile/QueryCompiler.java|  6 +++---
 .../apache/phoenix/compile/WhereOptimizer.java   |  5 -
 4 files changed, 21 insertions(+), 14 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/4968e88e/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java
index 37ffd02..f09f1d3 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java
@@ -895,6 +895,11 @@ public class HashJoinMoreIT extends 
ParallelStatsDisabledIT {
 + "FROM ( SELECT ACCOUNT_ID, BUCKET_ID, OBJECT_ID, 
MAX(OBJECT_VERSION) AS MAXVER "
 + "   FROM test2961 GROUP BY ACCOUNT_ID, BUCKET_ID, 
OBJECT_ID) AS X "
 + "   INNER JOIN test2961 AS OBJ ON X.ACCOUNT_ID = 
OBJ.ACCOUNT_ID AND X.BUCKET_ID = OBJ.BUCKET_ID AND X.OBJECT_ID = OBJ.OBJECT_ID 
AND  X.MAXVER = OBJ.OBJECT_VERSION";
+rs = conn.createStatement().executeQuery("explain " + q);
+String plan = QueryUtil.getExplainPlan(rs);
+String dynamicFilter = "DYNAMIC SERVER FILTER BY (OBJ.ACCOUNT_ID, 
OBJ.BUCKET_ID, OBJ.OBJECT_ID, OBJ.OBJECT_VERSION) IN ((X.ACCOUNT_ID, 
X.BUCKET_ID, X.OBJECT_ID, X.MAXVER))";
+assertTrue("Expected '" + dynamicFilter + "' to be used for the 
query, but got:\n" + plan,
+plan.contains(dynamicFilter));
 rs = conn.createStatement().executeQuery(q);
 assertTrue(rs.next());
 assertEquals("", rs.getString(4));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4968e88e/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
index 887e2d2..439a79b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
@@ -110,6 +110,12 @@ import com.google.common.collect.Sets;
 
 public class JoinCompiler {
 
+public enum Strategy {
+HASH_BUILD_LEFT,
+HASH_BUILD_RIGHT,
+SORT_MERGE,
+}
+
 public enum ColumnRefType {
 JOINLOCAL,
 GENERAL,
@@ -489,7 +495,7 @@ public class JoinCompiler {
 return dependencies;
 }
 
-public Pair 
compileJoinConditions(StatementContext lhsCtx, StatementContext rhsCtx, boolean 
sortExpressions) throws SQLException {
+public Pair 
compileJoinConditions(StatementContext lhsCtx, StatementContext rhsCtx, 
Strategy strategy) throws SQLException {
 if (onConditions.isEmpty()) {
 return new Pair(
 Collections. 
singletonList(LiteralExpression.newConstant(1)),
@@ -505,15 +511,16 @@ public class JoinCompiler {
 rhsCompiler.reset();
 Expression right = condition.getRHS().accept(rhsCompiler);
 PDataType toType = getCommonType(left.getDataType(), 
right.getDataType());
-if (left.getDataType() != toType || left.getSortOrder() == 
SortOrder.DESC) {
-left = CoerceExpression.create(left, toType, 
SortOrder.ASC, left.getMaxLength());
+SortOrder toSortOrder = strategy == Strategy.SORT_MERGE ? 
SortOrder.ASC : (strategy == Strategy.HASH_BUILD_LEFT ? right.getSortOrder() : 
left.getSortOrder());
+if (left.getDataType() != toType || left.getSortOrder() != 
toSortOrder) {
+left = CoerceExpression.create(left, toType, toSortOrder, 
left.getMaxLength());
 }
-

[16/16] phoenix git commit: PHOENIX-4386 Calculate the estimatedSize of MutationState using Map<TableRef, Map<ImmutableBytesPtr, RowMutationState>> mutations (addendum)

2017-12-16 Thread jamestaylor
PHOENIX-4386 Calculate the estimatedSize of MutationState using Map> mutations (addendum)


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 5b493962a437a264bb45f9698223a59f43623373
Parents: 4968e88
Author: Thomas D'Silva 
Authored: Tue Nov 21 03:13:53 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../apache/phoenix/execute/PartialCommitIT.java |   5 +-
 .../apache/phoenix/compile/DeleteCompiler.java  |  11 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   7 +-
 .../apache/phoenix/execute/MutationState.java   | 127 ---
 .../java/org/apache/phoenix/util/IndexUtil.java |   4 +-
 .../org/apache/phoenix/util/KeyValueUtil.java   |   5 +-
 6 files changed, 98 insertions(+), 61 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/5b493962/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
index 10fd7f8..e5b57e3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
@@ -33,7 +33,6 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
@@ -52,8 +51,8 @@ import 
org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.end2end.BaseOwnClusterIT;
+import org.apache.phoenix.execute.MutationState.MultiRowMutationState;
 import org.apache.phoenix.hbase.index.Indexer;
-import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.monitoring.GlobalMetric;
 import org.apache.phoenix.monitoring.MetricType;
@@ -285,7 +284,7 @@ public class PartialCommitIT extends BaseOwnClusterIT {
 private PhoenixConnection 
getConnectionWithTableOrderPreservingMutationState() throws SQLException {
 Connection con = driver.connect(url, new Properties());
 PhoenixConnection phxCon = new 
PhoenixConnection(con.unwrap(PhoenixConnection.class));
-final 
Map> mutations = 
Maps.newTreeMap(new TableRefComparator());
+final Map mutations = 
Maps.newTreeMap(new TableRefComparator());
 // passing a null mutation state forces the 
connection.newMutationState() to be used to create the MutationState
 return new PhoenixConnection(phxCon, null) {
 @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/5b493962/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
index f9ca300..a06e2ca 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
@@ -26,7 +26,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.hadoop.hbase.Cell;
@@ -43,6 +42,7 @@ import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.execute.AggregatePlan;
 import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.execute.MutationState.MultiRowMutationState;
 import org.apache.phoenix.execute.MutationState.RowMutationState;
 import org.apache.phoenix.filter.SkipScanFilter;
 import org.apache.phoenix.hbase.index.ValueGetter;
@@ -91,7 +91,6 @@ import org.apache.phoenix.util.ScanUtil;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import com.sun.istack.NotNull;
 
 public class DeleteCompiler {
@@ -121,14 +120,14 @@ public class DeleteCompiler {
 final int maxSize = 

[02/16] phoenix git commit: PHOENIX-3837 Feature enabling to set property on an index with Alter statement

2017-12-16 Thread jamestaylor
PHOENIX-3837 Feature enabling to set property on an index with Alter statement

Signed-off-by: aertoria 


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

Branch: refs/heads/4.x-HBase-1.2
Commit: ef174bb22ccce806dcdf5435d17319cbfa86c0d5
Parents: 5b49396
Author: aertoria 
Authored: Mon Nov 27 03:13:53 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../apache/phoenix/end2end/AlterTableIT.java|   2 +-
 .../phoenix/end2end/index/IndexMetadataIT.java  |  55 ++
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |   5 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  10 +-
 .../phoenix/parse/AddColumnStatement.java   |   2 +-
 .../phoenix/parse/AlterIndexStatement.java  |  14 +
 .../apache/phoenix/parse/ParseNodeFactory.java  |   6 +-
 .../phoenix/query/ConnectionQueryServices.java  |   2 +
 .../query/ConnectionQueryServicesImpl.java  |  20 +
 .../query/ConnectionlessQueryServicesImpl.java  |   7 +
 .../query/DelegateConnectionQueryServices.java  |   8 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 566 +--
 12 files changed, 520 insertions(+), 177 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ef174bb2/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index 5265b09..17f08c4 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -1080,7 +1080,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT 
{
} catch (SQLException e) {

assertEquals(SQLExceptionCode.CANNOT_CREATE_TXN_TABLE_IF_TXNS_DISABLED.getErrorCode(),
 e.getErrorCode());
}
-   // altering a table to be transactional  should fail if 
transactions are disabled
+   // altering a table to be transactional should fail if 
transactions are disabled
conn.createStatement().execute("CREATE TABLE " + 
dataTableFullName + "(k INTEGER PRIMARY KEY, v VARCHAR)");
try {
conn.createStatement().execute("ALTER TABLE " + 
dataTableFullName + " SET TRANSACTIONAL=true");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ef174bb2/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
index 0ce36dd..986c317 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
@@ -674,4 +674,59 @@ public class IndexMetadataIT extends 
ParallelStatsDisabledIT {
 conn.close();
 }
 }
+
+
+
+@Test
+public void testIndexAlterPhoenixProperty() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+Connection conn = DriverManager.getConnection(getUrl(), props);
+String testTable = generateUniqueName();
+
+
+String ddl = "create table " + testTable  + " (k varchar primary key, 
v1 varchar)";
+Statement stmt = conn.createStatement();
+stmt.execute(ddl);
+String indexName = "IDX_" + generateUniqueName();
+
+ddl = "CREATE INDEX " + indexName + " ON " + testTable  + " (v1) ";
+stmt.execute(ddl);
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 10");
+
+ResultSet rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+assertEquals(10,rs.getInt(1));
+
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 20");
+rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+assertEquals(20,rs.getInt(1));
+}
+
+
+@Test
+public 

[15/16] phoenix git commit: PHOENIX-4415 Ignore CURRENT_SCN property if set in Pig Storer

2017-12-16 Thread jamestaylor
PHOENIX-4415 Ignore CURRENT_SCN property if set in Pig Storer


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

Branch: refs/heads/4.x-HBase-1.2
Commit: a3db33567b4eb91f9c7b41d0232331da1f7873bb
Parents: ef174bb
Author: James Taylor 
Authored: Wed Nov 8 03:13:53 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../phoenix/mapreduce/PhoenixOutputFormat.java  | 13 ++-
 .../phoenix/mapreduce/PhoenixRecordWriter.java  |  8 ++-
 .../phoenix/mapreduce/util/ConnectionUtil.java  | 23 
 .../org/apache/phoenix/util/PropertiesUtil.java |  9 +++-
 .../java/org/apache/phoenix/pig/BasePigIT.java  |  4 
 .../apache/phoenix/pig/PhoenixHBaseStorage.java | 12 ++
 6 files changed, 58 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3db3356/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixOutputFormat.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixOutputFormat.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixOutputFormat.java
index e55b977..4217e40 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixOutputFormat.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixOutputFormat.java
@@ -19,6 +19,8 @@ package org.apache.phoenix.mapreduce;
 
 import java.io.IOException;
 import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -36,6 +38,15 @@ import org.apache.hadoop.mapreduce.lib.db.DBWritable;
  */
 public class PhoenixOutputFormat  extends 
OutputFormat {
 private static final Log LOG = 
LogFactory.getLog(PhoenixOutputFormat.class);
+private final Set propsToIgnore;
+
+public PhoenixOutputFormat() {
+this(Collections.emptySet());
+}
+
+public PhoenixOutputFormat(Set propsToIgnore) {
+this.propsToIgnore = propsToIgnore;
+}
 
 @Override
 public void checkOutputSpecs(JobContext jobContext) throws IOException, 
InterruptedException {  
@@ -52,7 +63,7 @@ public class PhoenixOutputFormat  
extends OutputFormat getRecordWriter(TaskAttemptContext 
context) throws IOException, InterruptedException {
 try {
-return new PhoenixRecordWriter(context.getConfiguration());
+return new PhoenixRecordWriter(context.getConfiguration(), 
propsToIgnore);
 } catch (SQLException e) {
 LOG.error("Error calling PhoenixRecordWriter "  + e.getMessage());
 throw new RuntimeException(e);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3db3356/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixRecordWriter.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixRecordWriter.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixRecordWriter.java
index 70ee3f5..52f2fe3 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixRecordWriter.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixRecordWriter.java
@@ -21,6 +21,8 @@ import java.io.IOException;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -46,7 +48,11 @@ public class PhoenixRecordWriter  
extends RecordWriteremptySet());
+}
+
+public PhoenixRecordWriter(final Configuration configuration, Set 
propsToIgnore) throws SQLException {
+this.conn = 
ConnectionUtil.getOutputConnectionWithoutTheseProps(configuration, 
propsToIgnore);
 this.batchSize = PhoenixConfigurationUtil.getBatchSize(configuration);
 final String upsertQuery = 
PhoenixConfigurationUtil.getUpsertStatement(configuration);
 this.statement = this.conn.prepareStatement(upsertQuery);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3db3356/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
index 

[03/16] phoenix git commit: PHOENIX-4288 Indexes not used when ordering by primary key

2017-12-16 Thread jamestaylor
PHOENIX-4288 Indexes not used when ordering by primary key


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 597764c06e2ee5254856a9be58021f0363a9f765
Parents: bd72ce3
Author: maryannxue 
Authored: Sun Nov 5 02:37:55 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../phoenix/end2end/CostBasedDecisionIT.java| 466 +++
 .../apache/phoenix/end2end/MutationStateIT.java |  17 +
 .../apache/phoenix/end2end/SystemCatalogIT.java |   1 -
 .../phoenix/compile/ListJarsQueryPlan.java  |   6 +
 .../org/apache/phoenix/compile/QueryPlan.java   |   5 +-
 .../apache/phoenix/compile/TraceQueryPlan.java  |   6 +
 .../apache/phoenix/execute/AggregatePlan.java   |  30 +-
 .../apache/phoenix/execute/BaseQueryPlan.java   |  21 +-
 .../phoenix/execute/ClientAggregatePlan.java|  28 ++
 .../apache/phoenix/execute/ClientScanPlan.java  |  25 +
 .../apache/phoenix/execute/CorrelatePlan.java   |  25 +
 .../phoenix/execute/DelegateQueryPlan.java  |   6 +
 .../apache/phoenix/execute/HashJoinPlan.java|  29 ++
 .../execute/LiteralResultIterationPlan.java |   6 +
 .../org/apache/phoenix/execute/ScanPlan.java|  25 +
 .../phoenix/execute/SortMergeJoinPlan.java  |  18 +
 .../org/apache/phoenix/execute/UnionPlan.java   |  10 +
 .../apache/phoenix/jdbc/PhoenixStatement.java   |   6 +
 .../java/org/apache/phoenix/optimize/Cost.java  | 123 +
 .../apache/phoenix/optimize/QueryOptimizer.java |  30 +-
 .../org/apache/phoenix/query/QueryServices.java |   3 +
 .../phoenix/query/QueryServicesOptions.java |   4 +
 .../java/org/apache/phoenix/util/CostUtil.java  |  90 
 .../query/ParallelIteratorsSplitTest.java   |   6 +
 24 files changed, 971 insertions(+), 15 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/597764c0/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java
new file mode 100644
index 000..a3584ce
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java
@@ -0,0 +1,466 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.QueryUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+public class CostBasedDecisionIT extends BaseUniqueNamesOwnClusterIT {
+
+@BeforeClass
+public static void doSetup() throws Exception {
+Map props = Maps.newHashMapWithExpectedSize(1);
+props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, 
Long.toString(20));
+props.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(5));
+props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, 
Boolean.toString(true));
+props.put(QueryServices.COST_BASED_OPTIMIZER_ENABLED, 
Boolean.toString(true));
+setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+}
+
+@Test
+public void testCostOverridesStaticPlanOrdering1() throws Exception {
+Properties props = 

[09/16] phoenix git commit: PHOENIX-4198 Remove the need for users to have access to the Phoenix SYSTEM tables to create tables

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/493a54f9/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
new file mode 100644
index 000..8437b37
--- /dev/null
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
@@ -0,0 +1,628 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.coprocessor;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.AuthUtil;
+import org.apache.hadoop.hbase.CoprocessorEnvironment;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.ClusterConnection;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.coprocessor.BaseMasterAndRegionObserver;
+import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.ipc.PayloadCarryingRpcController;
+import org.apache.hadoop.hbase.ipc.RpcServer;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
+import 
org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
+import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
+import org.apache.hadoop.hbase.security.AccessDeniedException;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.security.UserProvider;
+import org.apache.hadoop.hbase.security.access.AccessControlClient;
+import org.apache.hadoop.hbase.security.access.AuthResult;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.security.access.Permission.Action;
+import org.apache.hadoop.hbase.security.access.UserPermission;
+import org.apache.hadoop.hbase.util.Bytes;
+import 
org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost.PhoenixMetaDataControllerEnvironment;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.query.QueryServicesOptions;
+import org.apache.phoenix.schema.PIndexState;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+
+import com.google.common.collect.Lists;
+import com.google.protobuf.RpcCallback;
+
+public class PhoenixAccessController extends BaseMetaDataEndpointObserver {
+
+private PhoenixMetaDataControllerEnvironment env;
+private ArrayList accessControllers;
+private boolean accessCheckEnabled;
+private UserProvider userProvider;
+private boolean isAutomaticGrantEnabled;
+private boolean isStrictMode;
+public static final Log LOG = 
LogFactory.getLog(PhoenixAccessController.class);
+private static final Log AUDITLOG =
+
LogFactory.getLog("SecurityLogger."+PhoenixAccessController.class.getName());
+
+private List getAccessControllers() throws 
IOException {
+if (accessControllers == null) {
+synchronized (this) {
+if (accessControllers == null) {
+accessControllers = new 
ArrayList();
+RegionCoprocessorHost cpHost = 
this.env.getCoprocessorHost();
+List coprocessors = cpHost
+

[04/16] phoenix git commit: PHOENIX-4342 - Surface QueryPlan in MutationPlan

2017-12-16 Thread jamestaylor
PHOENIX-4342 - Surface QueryPlan in MutationPlan


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

Branch: refs/heads/4.x-HBase-1.2
Commit: a23439cf61a9ba8d4b298b97caf9498c71d29e64
Parents: 0b1f227
Author: Geoffrey Jacoby 
Authored: Thu Nov 2 20:41:02 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../phoenix/compile/BaseMutationPlan.java   |   5 +
 .../phoenix/compile/DelegateMutationPlan.java   |   5 +
 .../apache/phoenix/compile/DeleteCompiler.java  | 545 ---
 .../apache/phoenix/compile/MutationPlan.java|   5 +-
 .../apache/phoenix/compile/UpsertCompiler.java  | 675 +++
 .../apache/phoenix/jdbc/PhoenixStatement.java   |   9 +-
 6 files changed, 733 insertions(+), 511 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a23439cf/phoenix-core/src/main/java/org/apache/phoenix/compile/BaseMutationPlan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/BaseMutationPlan.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/BaseMutationPlan.java
index 0e45682..60eb59a 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/BaseMutationPlan.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/BaseMutationPlan.java
@@ -79,4 +79,9 @@ public abstract class BaseMutationPlan implements 
MutationPlan {
 return 0l;
 }
 
+@Override
+public QueryPlan getQueryPlan() {
+return null;
+}
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a23439cf/phoenix-core/src/main/java/org/apache/phoenix/compile/DelegateMutationPlan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/DelegateMutationPlan.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/DelegateMutationPlan.java
index 343ec32..90eef61 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/DelegateMutationPlan.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/DelegateMutationPlan.java
@@ -42,6 +42,11 @@ public class DelegateMutationPlan implements MutationPlan {
 }
 
 @Override
+public QueryPlan getQueryPlan() {
+return plan.getQueryPlan();
+}
+
+@Override
 public ParameterMetaData getParameterMetaData() {
 return plan.getParameterMetaData();
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a23439cf/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
index f038cda..8d9a5b6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
@@ -303,14 +303,16 @@ public class DeleteCompiler {
 return Collections.emptyList();
 }
 
-private class MultiDeleteMutationPlan implements MutationPlan {
+private class MultiRowDeleteMutationPlan implements MutationPlan {
 private final List plans;
 private final MutationPlan firstPlan;
-
-public MultiDeleteMutationPlan(@NotNull List plans) {
+private final QueryPlan dataPlan;
+
+public MultiRowDeleteMutationPlan(QueryPlan dataPlan, @NotNull 
List plans) {
 Preconditions.checkArgument(!plans.isEmpty());
 this.plans = plans;
 this.firstPlan = plans.get(0);
+this.dataPlan = dataPlan;
 }
 
 @Override
@@ -348,8 +350,8 @@ public class DeleteCompiler {
 return firstPlan.getSourceRefs();
 }
 
-   @Override
-   public Operation getOperation() {
+   @Override
+   public Operation getOperation() {
return operation;
}
 
@@ -401,6 +403,11 @@ public class DeleteCompiler {
 }
 return estInfoTimestamp;
 }
+
+@Override
+public QueryPlan getQueryPlan() {
+return dataPlan;
+}
 }
 
 public MutationPlan compile(DeleteStatement delete) throws SQLException {
@@ -548,69 +555,9 @@ public class DeleteCompiler {
 List mutationPlans = 
Lists.newArrayListWithExpectedSize(queryPlans.size());
 for (final 

[08/16] phoenix git commit: Revert "PHOENIX-4386 Calculate the estimatedSize of MutationState using Map<TableRef, Map<ImmutableBytesPtr, RowMutationState>> mutations (addendum)"

2017-12-16 Thread jamestaylor
Revert "PHOENIX-4386 Calculate the estimatedSize of MutationState using 
Map> mutations (addendum)"

This reverts commit 4e0c0a33ed8b401f7785dde8979041dd5ab9a1f4.


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

Branch: refs/heads/4.x-HBase-1.2
Commit: d523350ef9251dba06e2b9f76bab794896e18862
Parents: eb0f744
Author: Thomas D'Silva 
Authored: Wed Nov 29 02:37:55 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../apache/phoenix/execute/PartialCommitIT.java |   5 +-
 .../apache/phoenix/compile/DeleteCompiler.java  |  11 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   7 +-
 .../apache/phoenix/execute/MutationState.java   | 127 +++
 .../java/org/apache/phoenix/util/IndexUtil.java |   4 +-
 .../org/apache/phoenix/util/KeyValueUtil.java   |   5 +-
 6 files changed, 61 insertions(+), 98 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d523350e/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
index e5b57e3..10fd7f8 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
@@ -33,6 +33,7 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
@@ -51,8 +52,8 @@ import 
org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.end2end.BaseOwnClusterIT;
-import org.apache.phoenix.execute.MutationState.MultiRowMutationState;
 import org.apache.phoenix.hbase.index.Indexer;
+import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.monitoring.GlobalMetric;
 import org.apache.phoenix.monitoring.MetricType;
@@ -284,7 +285,7 @@ public class PartialCommitIT extends BaseOwnClusterIT {
 private PhoenixConnection 
getConnectionWithTableOrderPreservingMutationState() throws SQLException {
 Connection con = driver.connect(url, new Properties());
 PhoenixConnection phxCon = new 
PhoenixConnection(con.unwrap(PhoenixConnection.class));
-final Map mutations = 
Maps.newTreeMap(new TableRefComparator());
+final 
Map> mutations = 
Maps.newTreeMap(new TableRefComparator());
 // passing a null mutation state forces the 
connection.newMutationState() to be used to create the MutationState
 return new PhoenixConnection(phxCon, null) {
 @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d523350e/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
index a06e2ca..f9ca300 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.hadoop.hbase.Cell;
@@ -42,7 +43,6 @@ import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.execute.AggregatePlan;
 import org.apache.phoenix.execute.MutationState;
-import org.apache.phoenix.execute.MutationState.MultiRowMutationState;
 import org.apache.phoenix.execute.MutationState.RowMutationState;
 import org.apache.phoenix.filter.SkipScanFilter;
 import org.apache.phoenix.hbase.index.ValueGetter;
@@ -91,6 +91,7 @@ import org.apache.phoenix.util.ScanUtil;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import com.sun.istack.NotNull;
 
 public class DeleteCompiler {
@@ -120,14 

[01/16] phoenix git commit: PHOENIX-4424 Allow users to create "DEFAULT" and "HBASE" Schema (Uppercase Schema Names)

2017-12-16 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 0b1f22749 -> f6f7b4678


PHOENIX-4424 Allow users to create "DEFAULT" and "HBASE" Schema (Uppercase 
Schema Names)


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

Branch: refs/heads/4.x-HBase-1.2
Commit: f6f7b467883e6089ab564b94d32042340186472d
Parents: a3db335
Author: Karan Mehta 
Authored: Sat Nov 4 03:13:53 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../phoenix/end2end/ChangePermissionsIT.java|  5 +-
 .../apache/phoenix/end2end/CreateSchemaIT.java  | 64 ++--
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |  2 +-
 .../phoenix/parse/CreateSchemaStatement.java|  2 +-
 .../apache/phoenix/query/QueryConstants.java|  1 -
 .../apache/phoenix/schema/MetaDataClient.java   |  8 ++-
 .../org/apache/phoenix/util/SchemaUtil.java |  5 +-
 .../apache/phoenix/parse/QueryParserTest.java   | 13 
 8 files changed, 73 insertions(+), 27 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/f6f7b467/phoenix-core/src/it/java/org/apache/phoenix/end2end/ChangePermissionsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ChangePermissionsIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ChangePermissionsIT.java
index c023440..2bf7fe1 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ChangePermissionsIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ChangePermissionsIT.java
@@ -23,6 +23,7 @@ import org.apache.hadoop.hbase.security.User;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.schema.TableNotFoundException;
+import org.apache.phoenix.util.SchemaUtil;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -144,7 +145,7 @@ public class ChangePermissionsIT extends BasePermissionsIT {
 verifyAllowed(createSchema(SCHEMA_NAME), superUser1);
 verifyAllowed(grantPermissions("C", regularUser1, SCHEMA_NAME, 
true), superUser1);
 } else {
-verifyAllowed(grantPermissions("C", regularUser1, "\"" + 
QueryConstants.HBASE_DEFAULT_SCHEMA_NAME + "\"", true), superUser1);
+verifyAllowed(grantPermissions("C", regularUser1, "\"" + 
SchemaUtil.SCHEMA_FOR_DEFAULT_NAMESPACE + "\"", true), superUser1);
 }
 
 // Create new table. Create indexes, views and view indexes on top of 
it. Verify the contents by querying it
@@ -235,7 +236,7 @@ public class ChangePermissionsIT extends BasePermissionsIT {
 verifyAllowed(createSchema(SCHEMA_NAME), superUser1);
 verifyAllowed(grantPermissions("C", regularUser1, SCHEMA_NAME, 
true), superUser1);
 } else {
-verifyAllowed(grantPermissions("C", regularUser1, "\"" + 
QueryConstants.HBASE_DEFAULT_SCHEMA_NAME + "\"", true), superUser1);
+verifyAllowed(grantPermissions("C", regularUser1, "\"" + 
SchemaUtil.SCHEMA_FOR_DEFAULT_NAMESPACE + "\"", true), superUser1);
 }
 
 // Create MultiTenant Table (View Index Table should be automatically 
created)

http://git-wip-us.apache.org/repos/asf/phoenix/blob/f6f7b467/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java
index fe09dcd..8002dc1 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java
@@ -43,31 +43,61 @@ public class CreateSchemaIT extends ParallelStatsDisabledIT 
{
 Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
 props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, 
Boolean.toString(true));
 String schemaName = generateUniqueName();
-String ddl = "CREATE SCHEMA " + schemaName;
+String schemaName1 = schemaName.toLowerCase();
+String schemaName2 = schemaName.toLowerCase();
+// Create unique name schema and verify that it exists
+// ddl1 should create lowercase schemaName since it is passed in with 
double-quotes
+// ddl2 should create uppercase schemaName since Phoenix upper-cases 
identifiers without quotes
+// Both the statements should succeed
+String 

[06/16] phoenix git commit: PHOENIX-4386 Calculate the estimatedSize of MutationState using Map<TableRef, Map<ImmutableBytesPtr, RowMutationState>> mutations

2017-12-16 Thread jamestaylor
PHOENIX-4386 Calculate the estimatedSize of MutationState using Map> mutations


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

Branch: refs/heads/4.x-HBase-1.2
Commit: a6db039268964534715eab31fcc985861de4d0a9
Parents: bab1e46
Author: Thomas D'Silva 
Authored: Fri Nov 17 19:11:43 2017 +
Committer: James Taylor 
Committed: Sat Dec 16 16:42:54 2017 -0800

--
 .../apache/phoenix/end2end/MutationStateIT.java | 144 +++
 .../org/apache/phoenix/end2end/QueryMoreIT.java |  42 --
 .../apache/phoenix/compile/DeleteCompiler.java  |   6 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   4 +-
 .../apache/phoenix/execute/MutationState.java   |  50 +--
 .../org/apache/phoenix/util/KeyValueUtil.java   |  51 ++-
 6 files changed, 201 insertions(+), 96 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a6db0392/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
new file mode 100644
index 000..2d5f360
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
@@ -0,0 +1,144 @@
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.QueryServices;
+import org.junit.Test;
+
+public class MutationStateIT extends ParallelStatsDisabledIT {
+
+private static final String DDL =
+" (ORGANIZATION_ID CHAR(15) NOT NULL, SCORE DOUBLE, "
++ "ENTITY_ID CHAR(15) NOT NULL, TAGS VARCHAR, CONSTRAINT 
PAGE_SNAPSHOT_PK "
++ "PRIMARY KEY (ORGANIZATION_ID, ENTITY_ID DESC)) 
MULTI_TENANT=TRUE";
+
+private void upsertRows(PhoenixConnection conn, String fullTableName) 
throws SQLException {
+PreparedStatement stmt =
+conn.prepareStatement("upsert into " + fullTableName
++ " (organization_id, entity_id, score) values 
(?,?,?)");
+for (int i = 0; i < 1; i++) {
+stmt.setString(1, "" + i);
+stmt.setString(2, "" + i);
+stmt.setInt(3, 1);
+stmt.execute();
+}
+}
+
+@Test
+public void testMaxMutationSize() throws Exception {
+Properties connectionProperties = new Properties();
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "3");
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, 
"100");
+PhoenixConnection connection =
+(PhoenixConnection) DriverManager.getConnection(getUrl(), 
connectionProperties);
+String fullTableName = generateUniqueName();
+try (Statement stmt = connection.createStatement()) {
+stmt.execute(
+"CREATE TABLE " + fullTableName + DDL);
+}
+try {
+upsertRows(connection, fullTableName);
+fail();
+} catch (SQLException e) {
+
assertEquals(SQLExceptionCode.MAX_MUTATION_SIZE_EXCEEDED.getErrorCode(),
+e.getErrorCode());
+}
+
+// set the max mutation size (bytes) to a low value
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, 
"1000");
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, 
"4");
+connection =
+(PhoenixConnection) DriverManager.getConnection(getUrl(), 
connectionProperties);
+try {
+upsertRows(connection, fullTableName);
+fail();
+} catch (SQLException e) {
+
assertEquals(SQLExceptionCode.MAX_MUTATION_SIZE_BYTES_EXCEEDED.getErrorCode(),
+e.getErrorCode());
+}
+}
+
+@Test
+public void testMutationEstimatedSize() throws Exception {
+PhoenixConnection conn = (PhoenixConnection) 
DriverManager.getConnection(getUrl());
+conn.setAutoCommit(false);
+String fullTableName = 

[4/6] phoenix git commit: Revert "Sync 4.x-HBase-1.2 to master (Pedro Boado)"

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
index 97f3f3d..ddc2004 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
@@ -24,7 +24,6 @@ import org.apache.phoenix.schema.TableRef;
 
 
 public interface MutationPlan extends StatementPlan {
-MutationState execute() throws SQLException;
-TableRef getTargetRef();
-QueryPlan getQueryPlan();
+public MutationState execute() throws SQLException;
+public TableRef getTargetRef();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
index 287f9e0..af2254b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
@@ -307,7 +307,7 @@ public class QueryCompiler {
 JoinSpec joinSpec = joinSpecs.get(i);
 
context.setResolver(FromCompiler.getResolverForProjectedTable(projectedTable, 
context.getConnection(), query.getUdfParseNodes()));
 joinIds[i] = new ImmutableBytesPtr(emptyByteArray); // 
place-holder
-Pair joinConditions = 
joinSpec.compileJoinConditions(context, subContexts[i], 
JoinCompiler.Strategy.HASH_BUILD_RIGHT);
+Pair joinConditions = 
joinSpec.compileJoinConditions(context, subContexts[i], true);
 joinExpressions[i] = joinConditions.getFirst();
 List hashExpressions = joinConditions.getSecond();
 Pair keyRangeExpressions = new 
Pair(null, null);
@@ -369,7 +369,7 @@ public class QueryCompiler {
 context.setCurrentTable(rhsTableRef);
 
context.setResolver(FromCompiler.getResolverForProjectedTable(rhsProjTable, 
context.getConnection(), rhs.getUdfParseNodes()));
 ImmutableBytesPtr[] joinIds = new ImmutableBytesPtr[] {new 
ImmutableBytesPtr(emptyByteArray)};
-Pair joinConditions = 
lastJoinSpec.compileJoinConditions(lhsCtx, context, 
JoinCompiler.Strategy.HASH_BUILD_LEFT);
+Pair joinConditions = 
lastJoinSpec.compileJoinConditions(lhsCtx, context, true);
 List joinExpressions = joinConditions.getSecond();
 List hashExpressions = joinConditions.getFirst();
 boolean needsMerge = lhsJoin.hasPostReference();
@@ -422,7 +422,7 @@ public class QueryCompiler {
 QueryPlan rhsPlan = compileJoinQuery(rhsCtx, binds, rhsJoin, true, 
true, rhsOrderBy);
 PTable rhsProjTable = 
rhsCtx.getResolver().getTables().get(0).getTable();
 
-Pair joinConditions = 
lastJoinSpec.compileJoinConditions(type == JoinType.Right ? rhsCtx : lhsCtx, 
type == JoinType.Right ? lhsCtx : rhsCtx, JoinCompiler.Strategy.SORT_MERGE);
+Pair joinConditions = 
lastJoinSpec.compileJoinConditions(type == JoinType.Right ? rhsCtx : lhsCtx, 
type == JoinType.Right ? lhsCtx : rhsCtx, false);
 List lhsKeyExpressions = type == JoinType.Right ? 
joinConditions.getSecond() : joinConditions.getFirst();
 List rhsKeyExpressions = type == JoinType.Right ? 
joinConditions.getFirst() : joinConditions.getSecond();
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
index ca88984..f7cdcbf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
@@ -26,7 +26,6 @@ import org.apache.phoenix.compile.GroupByCompiler.GroupBy;
 import org.apache.phoenix.compile.OrderByCompiler.OrderBy;
 import org.apache.phoenix.iterate.ParallelScanGrouper;
 import org.apache.phoenix.iterate.ResultIterator;
-import org.apache.phoenix.optimize.Cost;
 import org.apache.phoenix.parse.FilterableStatement;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.schema.TableRef;
@@ -53,9 +52,7 @@ public interface QueryPlan extends StatementPlan {
 

[5/6] phoenix git commit: Revert "Sync 4.x-HBase-1.2 to master (Pedro Boado)"

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
deleted file mode 100644
index 36782c1..000
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.phoenix.end2end;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import org.apache.phoenix.exception.SQLExceptionCode;
-import org.apache.phoenix.execute.MutationState;
-import org.apache.phoenix.jdbc.PhoenixConnection;
-import org.apache.phoenix.query.QueryServices;
-import org.junit.Test;
-
-public class MutationStateIT extends ParallelStatsDisabledIT {
-
-private static final String DDL =
-" (ORGANIZATION_ID CHAR(15) NOT NULL, SCORE DOUBLE, "
-+ "ENTITY_ID CHAR(15) NOT NULL, TAGS VARCHAR, CONSTRAINT 
PAGE_SNAPSHOT_PK "
-+ "PRIMARY KEY (ORGANIZATION_ID, ENTITY_ID DESC)) 
MULTI_TENANT=TRUE";
-
-private void upsertRows(PhoenixConnection conn, String fullTableName) 
throws SQLException {
-PreparedStatement stmt =
-conn.prepareStatement("upsert into " + fullTableName
-+ " (organization_id, entity_id, score) values 
(?,?,?)");
-for (int i = 0; i < 1; i++) {
-stmt.setString(1, "" + i);
-stmt.setString(2, "" + i);
-stmt.setInt(3, 1);
-stmt.execute();
-}
-}
-
-@Test
-public void testMaxMutationSize() throws Exception {
-Properties connectionProperties = new Properties();
-
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "3");
-
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, 
"100");
-PhoenixConnection connection =
-(PhoenixConnection) DriverManager.getConnection(getUrl(), 
connectionProperties);
-String fullTableName = generateUniqueName();
-try (Statement stmt = connection.createStatement()) {
-stmt.execute(
-"CREATE TABLE " + fullTableName + DDL);
-}
-try {
-upsertRows(connection, fullTableName);
-fail();
-} catch (SQLException e) {
-
assertEquals(SQLExceptionCode.MAX_MUTATION_SIZE_EXCEEDED.getErrorCode(),
-e.getErrorCode());
-}
-
-// set the max mutation size (bytes) to a low value
-
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, 
"1000");
-
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, 
"4");
-connection =
-(PhoenixConnection) DriverManager.getConnection(getUrl(), 
connectionProperties);
-try {
-upsertRows(connection, fullTableName);
-fail();
-} catch (SQLException e) {
-
assertEquals(SQLExceptionCode.MAX_MUTATION_SIZE_BYTES_EXCEEDED.getErrorCode(),
-e.getErrorCode());
-}
-}
-
-@Test
-public void testMutationEstimatedSize() throws Exception {
-PhoenixConnection conn = (PhoenixConnection) 
DriverManager.getConnection(getUrl());
-conn.setAutoCommit(false);
-String fullTableName = generateUniqueName();
-try (Statement stmt = conn.createStatement()) {
-stmt.execute(
-"CREATE TABLE " + fullTableName + DDL);
-}
-
-// upserting rows should increase the mutation state size
-MutationState state = 
conn.unwrap(PhoenixConnection.class).getMutationState();
-long prevEstimatedSize = state.getEstimatedSize();
-upsertRows(conn, fullTableName);
- 

[1/6] phoenix git commit: Revert "Sync 4.x-HBase-1.2 to master (Pedro Boado)"

2017-12-16 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 2d70f55ae -> 0b1f22749


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index 0b80f4d..a4a4124 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -260,8 +260,6 @@ public interface QueryServices extends SQLCloseable {
 
 //currently BASE64 and ASCII is supported
 public static final String UPLOAD_BINARY_DATA_TYPE_ENCODING = 
"phoenix.upload.binaryDataType.encoding";
-// Toggle for server-written updates to SYSTEM.CATALOG
-public static final String PHOENIX_ACLS_ENABLED = "phoenix.acls.enabled";
 
 public static final String INDEX_ASYNC_BUILD_ENABLED = 
"phoenix.index.async.build.enabled";
 
@@ -294,9 +292,6 @@ public interface QueryServices extends SQLCloseable {
 //Update Cache Frequency default config attribute
 public static final String DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB  = 
"phoenix.default.update.cache.frequency";
 
-// Whether to enable cost-based-decision in the query optimizer
-public static final String COST_BASED_OPTIMIZER_ENABLED = 
"phoenix.costbased.optimizer.enabled";
-
 /**
  * Get executor service used for parallel scans
  */

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index 4d31974..af6a054 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -25,7 +25,6 @@ import static 
org.apache.phoenix.query.QueryServices.CALL_QUEUE_PRODUCER_ATTRIB_
 import static 
org.apache.phoenix.query.QueryServices.CALL_QUEUE_ROUND_ROBIN_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.COLLECT_REQUEST_LEVEL_METRICS;
 import static org.apache.phoenix.query.QueryServices.COMMIT_STATS_ASYNC;
-import static 
org.apache.phoenix.query.QueryServices.COST_BASED_OPTIMIZER_ENABLED;
 import static org.apache.phoenix.query.QueryServices.DATE_FORMAT_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.DELAY_FOR_SCHEMA_UPDATE_CHECK;
@@ -59,7 +58,6 @@ import static 
org.apache.phoenix.query.QueryServices.MAX_TENANT_MEMORY_PERC_ATTR
 import static 
org.apache.phoenix.query.QueryServices.MIN_STATS_UPDATE_FREQ_MS_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.NUM_RETRIES_FOR_SCHEMA_UPDATE_CHECK;
-import static org.apache.phoenix.query.QueryServices.PHOENIX_ACLS_ENABLED;
 import static 
org.apache.phoenix.query.QueryServices.PHOENIX_QUERY_SERVER_CLUSTER_BASE_PATH;
 import static 
org.apache.phoenix.query.QueryServices.PHOENIX_QUERY_SERVER_LOADBALANCER_ENABLED;
 import static 
org.apache.phoenix.query.QueryServices.PHOENIX_QUERY_SERVER_SERVICE_NAME;
@@ -318,9 +316,6 @@ public class QueryServicesOptions {
 public static final int DEFAULT_CLIENT_CONNECTION_MAX_ALLOWED_CONNECTIONS 
= 0;
 public static final boolean DEFAULT_STATS_COLLECTION_ENABLED = true;
 public static final boolean DEFAULT_USE_STATS_FOR_PARALLELIZATION = true;
-
-//Security defaults
-public static final boolean DEFAULT_PHOENIX_ACLS_ENABLED = false;
 
 //default update cache frequency
 public static final int DEFAULT_UPDATE_CACHE_FREQUENCY = 0;
@@ -342,8 +337,6 @@ public class QueryServicesOptions {
 // RS -> RS calls for upsert select statements are disabled by default
 public static final boolean DEFAULT_ENABLE_SERVER_UPSERT_SELECT = false;
 
-public static final boolean DEFAULT_COST_BASED_OPTIMIZER_ENABLED = false;
-
 private final Configuration config;
 
 private QueryServicesOptions(Configuration config) {
@@ -420,10 +413,7 @@ public class QueryServicesOptions {
 .setIfUnset(TRACING_BATCH_SIZE, DEFAULT_TRACING_BATCH_SIZE)
 .setIfUnset(TRACING_THREAD_POOL_SIZE, 
DEFAULT_TRACING_THREAD_POOL_SIZE)
 .setIfUnset(STATS_COLLECTION_ENABLED, 
DEFAULT_STATS_COLLECTION_ENABLED)
-.setIfUnset(USE_STATS_FOR_PARALLELIZATION, 
DEFAULT_USE_STATS_FOR_PARALLELIZATION)
-.setIfUnset(COST_BASED_OPTIMIZER_ENABLED, 
DEFAULT_COST_BASED_OPTIMIZER_ENABLED)
-

[3/6] phoenix git commit: Revert "Sync 4.x-HBase-1.2 to master (Pedro Boado)"

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
deleted file mode 100644
index 86b8bf1..000
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.phoenix.coprocessor;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.hadoop.hbase.Coprocessor;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.coprocessor.ObserverContext;
-import 
org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost.PhoenixMetaDataControllerEnvironment;
-import org.apache.phoenix.schema.PIndexState;
-import org.apache.phoenix.schema.PTable;
-import org.apache.phoenix.schema.PTableType;
-
-public interface MetaDataEndpointObserver extends Coprocessor {
-
-void preGetTable( ObserverContext 
ctx,  String tenantId,String tableName,
- TableName physicalTableName) throws IOException;
-
-void preCreateTable(final 
ObserverContext ctx, final String 
tenantId,
-String tableName, TableName physicalTableName, final TableName 
parentPhysicalTableName,
-PTableType tableType, final Set familySet, Set 
indexes) throws IOException;
-
-void preDropTable(final 
ObserverContext ctx, final String 
tenantId,
-final String tableName,TableName physicalTableName, TableName 
parentPhysicalTableName, PTableType tableType, List indexes) throws 
IOException;
-
-void preAlterTable(final 
ObserverContext ctx, final String 
tenantId,final String tableName,
-final TableName physicalTableName,final TableName 
parentPhysicalTableName, PTableType type) throws IOException;
-
-void preGetSchema(final 
ObserverContext ctx, final String 
schemaName)
-throws IOException;
-
-void preCreateSchema(final 
ObserverContext ctx, final String 
schemaName)
-throws IOException;
-
-void preDropSchema(final 
ObserverContext ctx, final String 
schemaName)
-throws IOException;
-
-void preCreateFunction(final 
ObserverContext ctx, final String 
tenantId,
-final String functionName) throws IOException;
-
-void preDropFunction(final 
ObserverContext ctx, final String 
tenantId,
-final String functionName) throws IOException;
-
-void preGetFunctions(final 
ObserverContext ctx, final String 
tenantId,
-final String functionName) throws IOException;
-
-void preIndexUpdate(ObserverContext 
ctx, String tenantId,
-String indexName, TableName physicalTableName, TableName 
parentPhysicalTableName, PIndexState newState) throws IOException;
-
-}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index af06235..c816549 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -20,7 +20,6 @@ package org.apache.phoenix.coprocessor;
 import static org.apache.phoenix.schema.types.PDataType.TRUE_BYTES;
 
 import java.io.IOException;
-import java.security.PrivilegedExceptionAction;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -51,7 +50,6 @@ import org.apache.hadoop.hbase.filter.CompareFilter;
 import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import 

[2/6] phoenix git commit: Revert "Sync 4.x-HBase-1.2 to master (Pedro Boado)"

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b1f2274/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index 993438e..0faa20c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -96,7 +96,6 @@ import org.apache.phoenix.util.SQLCloseable;
 import org.apache.phoenix.util.SQLCloseables;
 import org.apache.phoenix.util.ScanUtil;
 import org.apache.phoenix.util.ServerUtil;
-import org.apache.phoenix.util.SizedUtil;
 import org.apache.phoenix.util.TransactionUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -123,7 +122,7 @@ public class MutationState implements SQLCloseable {
 private final long batchSize;
 private final long batchSizeBytes;
 private long batchCount = 0L;
-private final Map mutations;
+private final Map> 
mutations;
 private final Set uncommittedPhysicalNames = 
Sets.newHashSetWithExpectedSize(10);
 
 private long sizeOffset;
@@ -131,7 +130,7 @@ public class MutationState implements SQLCloseable {
 private long estimatedSize = 0;
 private int[] uncommittedStatementIndexes = EMPTY_STATEMENT_INDEX_ARRAY;
 private boolean isExternalTxContext = false;
-private Map txMutations = 
Collections.emptyMap();
+private Map> txMutations 
= Collections.emptyMap();
 
 final PhoenixTransactionContext phoenixTransactionContext;
 
@@ -159,12 +158,12 @@ public class MutationState implements SQLCloseable {
 }
 
 private MutationState(long maxSize, long maxSizeBytes, PhoenixConnection 
connection, boolean subTask, PhoenixTransactionContext txContext, long 
sizeOffset) {
-this(maxSize, maxSizeBytes, connection, Maps.newHashMapWithExpectedSize(5), subTask, txContext);
+this(maxSize, maxSizeBytes, connection, Maps.>newHashMapWithExpectedSize(5), subTask, 
txContext);
 this.sizeOffset = sizeOffset;
 }
 
 MutationState(long maxSize, long maxSizeBytes, PhoenixConnection 
connection,
-Map mutations,
+Map> mutations,
 boolean subTask, PhoenixTransactionContext txContext) {
 this.maxSize = maxSize;
 this.maxSizeBytes = maxSizeBytes;
@@ -189,19 +188,15 @@ public class MutationState implements SQLCloseable {
 }
 }
 
-public MutationState(TableRef table, MultiRowMutationState mutations, long 
sizeOffset, long maxSize, long maxSizeBytes, PhoenixConnection connection)  
throws SQLException {
+public MutationState(TableRef table, 
Map mutations, long sizeOffset, long 
maxSize, long maxSizeBytes, PhoenixConnection connection) throws SQLException {
 this(maxSize, maxSizeBytes, connection, false, null, sizeOffset);
 if (!mutations.isEmpty()) {
 this.mutations.put(table, mutations);
 }
 this.numRows = mutations.size();
-this.estimatedSize = 
KeyValueUtil.getEstimatedRowMutationSize(this.mutations);
+this.estimatedSize = KeyValueUtil.getEstimatedRowSize(table, 
mutations);
 throwIfTooBig();
 }
-
-public long getEstimatedSize() {
-return estimatedSize;
-}
 
 public long getMaxSize() {
 return maxSize;
@@ -350,7 +345,7 @@ public class MutationState implements SQLCloseable {
 }
 
 public static MutationState emptyMutationState(long maxSize, long 
maxSizeBytes, PhoenixConnection connection) {
-MutationState state = new MutationState(maxSize, maxSizeBytes, 
connection, Collections.emptyMap(), false, 
null);
+MutationState state = new MutationState(maxSize, maxSizeBytes, 
connection, Collections.>emptyMap(), false, null);
 state.sizeOffset = 0;
 return state;
 }
@@ -372,12 +367,12 @@ public class MutationState implements SQLCloseable {
 return sizeOffset + numRows;
 }
 
-private void joinMutationState(TableRef tableRef, MultiRowMutationState 
srcRows,
-Map dstMutations) {
+private void joinMutationState(TableRef tableRef, 
Map srcRows,
+Map> 
dstMutations) {
 PTable table = tableRef.getTable();
 boolean isIndex = 

[6/6] phoenix git commit: Revert "Sync 4.x-HBase-1.2 to master (Pedro Boado)"

2017-12-16 Thread jamestaylor
Revert "Sync 4.x-HBase-1.2 to master (Pedro Boado)"

This reverts commit 2d70f55ae6b1a3850e2d2a5a01eb40d5928c65de.


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 0b1f22749c4786a8543b88e03fc5cf91de535b3d
Parents: 2d70f55
Author: James Taylor 
Authored: Sat Dec 16 16:36:44 2017 -0800
Committer: James Taylor 
Committed: Sat Dec 16 16:36:44 2017 -0800

--
 .../apache/phoenix/end2end/AlterTableIT.java|   2 +-
 .../phoenix/end2end/BasePermissionsIT.java  | 754 ---
 .../phoenix/end2end/ChangePermissionsIT.java| 270 ---
 .../phoenix/end2end/CostBasedDecisionIT.java| 466 
 .../apache/phoenix/end2end/CreateSchemaIT.java  |  64 +-
 .../apache/phoenix/end2end/MutationStateIT.java | 161 
 .../org/apache/phoenix/end2end/QueryMoreIT.java |  42 ++
 .../org/apache/phoenix/end2end/SortOrderIT.java |  11 +-
 .../apache/phoenix/end2end/SystemCatalogIT.java |   1 +
 .../end2end/SystemTablePermissionsIT.java   | 226 +-
 .../phoenix/end2end/TableDDLPermissionsIT.java  | 233 --
 .../phoenix/end2end/index/IndexMetadataIT.java  |  55 --
 .../phoenix/end2end/join/HashJoinMoreIT.java|   5 -
 .../apache/phoenix/execute/PartialCommitIT.java |   5 +-
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |  37 +-
 .../org/apache/hadoop/hbase/ipc/RpcUtil.java|  32 -
 .../phoenix/compile/BaseMutationPlan.java   |   5 -
 .../phoenix/compile/DelegateMutationPlan.java   |   5 -
 .../apache/phoenix/compile/DeleteCompiler.java  | 558 ++
 .../apache/phoenix/compile/JoinCompiler.java|  19 +-
 .../phoenix/compile/ListJarsQueryPlan.java  |   6 -
 .../apache/phoenix/compile/MutationPlan.java|   5 +-
 .../apache/phoenix/compile/QueryCompiler.java   |   6 +-
 .../org/apache/phoenix/compile/QueryPlan.java   |   5 +-
 .../apache/phoenix/compile/TraceQueryPlan.java  |   6 -
 .../apache/phoenix/compile/UpsertCompiler.java  | 684 +++--
 .../apache/phoenix/compile/WhereOptimizer.java  |   5 +
 .../BaseMetaDataEndpointObserver.java   | 111 ---
 .../coprocessor/MetaDataEndpointImpl.java   | 339 ++---
 .../coprocessor/MetaDataEndpointObserver.java   |  68 --
 .../coprocessor/MetaDataRegionObserver.java |  17 +-
 .../coprocessor/PhoenixAccessController.java| 611 ---
 .../PhoenixMetaDataCoprocessorHost.java | 236 --
 .../phoenix/exception/SQLExceptionCode.java |   1 -
 .../apache/phoenix/execute/AggregatePlan.java   |  30 +-
 .../apache/phoenix/execute/BaseQueryPlan.java   |  21 +-
 .../phoenix/execute/ClientAggregatePlan.java|  28 -
 .../apache/phoenix/execute/ClientScanPlan.java  |  25 -
 .../apache/phoenix/execute/CorrelatePlan.java   |  25 -
 .../phoenix/execute/DelegateQueryPlan.java  |   6 -
 .../apache/phoenix/execute/HashJoinPlan.java|  29 -
 .../execute/LiteralResultIterationPlan.java |   6 -
 .../apache/phoenix/execute/MutationState.java   | 159 ++--
 .../org/apache/phoenix/execute/ScanPlan.java|  25 -
 .../phoenix/execute/SortMergeJoinPlan.java  |  18 -
 .../org/apache/phoenix/execute/UnionPlan.java   |  10 -
 .../RowValueConstructorExpression.java  |   4 +-
 .../index/PhoenixIndexFailurePolicy.java| 109 ++-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  65 +-
 .../phoenix/mapreduce/PhoenixOutputFormat.java  |  13 +-
 .../phoenix/mapreduce/PhoenixRecordWriter.java  |   8 +-
 .../phoenix/mapreduce/util/ConnectionUtil.java  |  23 +-
 .../java/org/apache/phoenix/optimize/Cost.java  | 123 ---
 .../apache/phoenix/optimize/QueryOptimizer.java |  30 +-
 .../phoenix/parse/AddColumnStatement.java   |   2 +-
 .../phoenix/parse/AlterIndexStatement.java  |  14 -
 .../phoenix/parse/ChangePermsStatement.java | 102 ---
 .../phoenix/parse/CreateSchemaStatement.java|   2 +-
 .../apache/phoenix/parse/ParseNodeFactory.java  |  13 +-
 .../phoenix/query/ConnectionQueryServices.java  |   2 -
 .../query/ConnectionQueryServicesImpl.java  |  64 +-
 .../query/ConnectionlessQueryServicesImpl.java  |   7 -
 .../query/DelegateConnectionQueryServices.java  |   8 +-
 .../org/apache/phoenix/query/QueryServices.java |   5 -
 .../phoenix/query/QueryServicesOptions.java |  12 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 710 -
 .../schema/TablesNotInSyncException.java|  22 -
 .../phoenix/schema/stats/StatisticsWriter.java  |  42 +-
 .../java/org/apache/phoenix/util/CostUtil.java  |  90 ---
 .../java/org/apache/phoenix/util/IndexUtil.java |   4 +-
 .../org/apache/phoenix/util/KeyValueUtil.java   |  52 +-
 .../org/apache/phoenix/util/MetaDataUtil.java   |  18 

Jenkins build is back to normal : Phoenix-4.x-HBase-1.2 #222

2017-12-16 Thread Apache Jenkins Server
See 




[6/6] phoenix git commit: Sync 4.x-HBase-1.2 to master (Pedro Boado)

2017-12-16 Thread jamestaylor
Sync 4.x-HBase-1.2 to master (Pedro Boado)


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 2d70f55ae6b1a3850e2d2a5a01eb40d5928c65de
Parents: 6d19972
Author: James Taylor 
Authored: Sat Dec 16 10:48:52 2017 -0800
Committer: James Taylor 
Committed: Sat Dec 16 10:48:52 2017 -0800

--
 .../apache/phoenix/end2end/AlterTableIT.java|   2 +-
 .../phoenix/end2end/BasePermissionsIT.java  | 754 +++
 .../phoenix/end2end/ChangePermissionsIT.java| 270 +++
 .../phoenix/end2end/CostBasedDecisionIT.java| 466 
 .../apache/phoenix/end2end/CreateSchemaIT.java  |  64 +-
 .../apache/phoenix/end2end/MutationStateIT.java | 161 
 .../org/apache/phoenix/end2end/QueryMoreIT.java |  42 --
 .../org/apache/phoenix/end2end/SortOrderIT.java |  11 +-
 .../apache/phoenix/end2end/SystemCatalogIT.java |   1 -
 .../end2end/SystemTablePermissionsIT.java   | 226 +-
 .../phoenix/end2end/TableDDLPermissionsIT.java  | 233 ++
 .../phoenix/end2end/index/IndexMetadataIT.java  |  55 ++
 .../phoenix/end2end/join/HashJoinMoreIT.java|   5 +
 .../apache/phoenix/execute/PartialCommitIT.java |   5 +-
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |  37 +-
 .../org/apache/hadoop/hbase/ipc/RpcUtil.java|  32 +
 .../phoenix/compile/BaseMutationPlan.java   |   5 +
 .../phoenix/compile/DelegateMutationPlan.java   |   5 +
 .../apache/phoenix/compile/DeleteCompiler.java  | 558 --
 .../apache/phoenix/compile/JoinCompiler.java|  19 +-
 .../phoenix/compile/ListJarsQueryPlan.java  |   6 +
 .../apache/phoenix/compile/MutationPlan.java|   5 +-
 .../apache/phoenix/compile/QueryCompiler.java   |   6 +-
 .../org/apache/phoenix/compile/QueryPlan.java   |   5 +-
 .../apache/phoenix/compile/TraceQueryPlan.java  |   6 +
 .../apache/phoenix/compile/UpsertCompiler.java  | 684 ++---
 .../apache/phoenix/compile/WhereOptimizer.java  |   5 -
 .../BaseMetaDataEndpointObserver.java   | 111 +++
 .../coprocessor/MetaDataEndpointImpl.java   | 339 +++--
 .../coprocessor/MetaDataEndpointObserver.java   |  68 ++
 .../coprocessor/MetaDataRegionObserver.java |  17 +-
 .../coprocessor/PhoenixAccessController.java| 611 +++
 .../PhoenixMetaDataCoprocessorHost.java | 236 ++
 .../phoenix/exception/SQLExceptionCode.java |   1 +
 .../apache/phoenix/execute/AggregatePlan.java   |  30 +-
 .../apache/phoenix/execute/BaseQueryPlan.java   |  21 +-
 .../phoenix/execute/ClientAggregatePlan.java|  28 +
 .../apache/phoenix/execute/ClientScanPlan.java  |  25 +
 .../apache/phoenix/execute/CorrelatePlan.java   |  25 +
 .../phoenix/execute/DelegateQueryPlan.java  |   6 +
 .../apache/phoenix/execute/HashJoinPlan.java|  29 +
 .../execute/LiteralResultIterationPlan.java |   6 +
 .../apache/phoenix/execute/MutationState.java   | 159 ++--
 .../org/apache/phoenix/execute/ScanPlan.java|  25 +
 .../phoenix/execute/SortMergeJoinPlan.java  |  18 +
 .../org/apache/phoenix/execute/UnionPlan.java   |  10 +
 .../RowValueConstructorExpression.java  |   4 +-
 .../index/PhoenixIndexFailurePolicy.java| 109 +--
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  65 +-
 .../phoenix/mapreduce/PhoenixOutputFormat.java  |  13 +-
 .../phoenix/mapreduce/PhoenixRecordWriter.java  |   8 +-
 .../phoenix/mapreduce/util/ConnectionUtil.java  |  23 +-
 .../java/org/apache/phoenix/optimize/Cost.java  | 123 +++
 .../apache/phoenix/optimize/QueryOptimizer.java |  30 +-
 .../phoenix/parse/AddColumnStatement.java   |   2 +-
 .../phoenix/parse/AlterIndexStatement.java  |  14 +
 .../phoenix/parse/ChangePermsStatement.java | 102 +++
 .../phoenix/parse/CreateSchemaStatement.java|   2 +-
 .../apache/phoenix/parse/ParseNodeFactory.java  |  13 +-
 .../phoenix/query/ConnectionQueryServices.java  |   2 +
 .../query/ConnectionQueryServicesImpl.java  |  64 +-
 .../query/ConnectionlessQueryServicesImpl.java  |   7 +
 .../query/DelegateConnectionQueryServices.java  |   8 +-
 .../org/apache/phoenix/query/QueryServices.java |   5 +
 .../phoenix/query/QueryServicesOptions.java |  12 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 710 +
 .../schema/TablesNotInSyncException.java|  22 +
 .../phoenix/schema/stats/StatisticsWriter.java  |  42 +-
 .../java/org/apache/phoenix/util/CostUtil.java  |  90 +++
 .../java/org/apache/phoenix/util/IndexUtil.java |   4 +-
 .../org/apache/phoenix/util/KeyValueUtil.java   |  52 +-
 .../org/apache/phoenix/util/MetaDataUtil.java   |  18 +
 .../org/apache/phoenix/util/PropertiesUtil.java |   9 +-
 

[3/6] phoenix git commit: Sync 4.x-HBase-1.2 to master (Pedro Boado)

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
new file mode 100644
index 000..86b8bf1
--- /dev/null
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointObserver.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.coprocessor;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.hbase.Coprocessor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import 
org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost.PhoenixMetaDataControllerEnvironment;
+import org.apache.phoenix.schema.PIndexState;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+
+public interface MetaDataEndpointObserver extends Coprocessor {
+
+void preGetTable( ObserverContext 
ctx,  String tenantId,String tableName,
+ TableName physicalTableName) throws IOException;
+
+void preCreateTable(final 
ObserverContext ctx, final String 
tenantId,
+String tableName, TableName physicalTableName, final TableName 
parentPhysicalTableName,
+PTableType tableType, final Set familySet, Set 
indexes) throws IOException;
+
+void preDropTable(final 
ObserverContext ctx, final String 
tenantId,
+final String tableName,TableName physicalTableName, TableName 
parentPhysicalTableName, PTableType tableType, List indexes) throws 
IOException;
+
+void preAlterTable(final 
ObserverContext ctx, final String 
tenantId,final String tableName,
+final TableName physicalTableName,final TableName 
parentPhysicalTableName, PTableType type) throws IOException;
+
+void preGetSchema(final 
ObserverContext ctx, final String 
schemaName)
+throws IOException;
+
+void preCreateSchema(final 
ObserverContext ctx, final String 
schemaName)
+throws IOException;
+
+void preDropSchema(final 
ObserverContext ctx, final String 
schemaName)
+throws IOException;
+
+void preCreateFunction(final 
ObserverContext ctx, final String 
tenantId,
+final String functionName) throws IOException;
+
+void preDropFunction(final 
ObserverContext ctx, final String 
tenantId,
+final String functionName) throws IOException;
+
+void preGetFunctions(final 
ObserverContext ctx, final String 
tenantId,
+final String functionName) throws IOException;
+
+void preIndexUpdate(ObserverContext 
ctx, String tenantId,
+String indexName, TableName physicalTableName, TableName 
parentPhysicalTableName, PIndexState newState) throws IOException;
+
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index c816549..af06235 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -20,6 +20,7 @@ package org.apache.phoenix.coprocessor;
 import static org.apache.phoenix.schema.types.PDataType.TRUE_BYTES;
 
 import java.io.IOException;
+import java.security.PrivilegedExceptionAction;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -50,6 +51,7 @@ import org.apache.hadoop.hbase.filter.CompareFilter;
 import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import 

[1/6] phoenix git commit: Sync 4.x-HBase-1.2 to master (Pedro Boado)

2017-12-16 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 6d19972b0 -> 2d70f55ae


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index a4a4124..0b80f4d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -260,6 +260,8 @@ public interface QueryServices extends SQLCloseable {
 
 //currently BASE64 and ASCII is supported
 public static final String UPLOAD_BINARY_DATA_TYPE_ENCODING = 
"phoenix.upload.binaryDataType.encoding";
+// Toggle for server-written updates to SYSTEM.CATALOG
+public static final String PHOENIX_ACLS_ENABLED = "phoenix.acls.enabled";
 
 public static final String INDEX_ASYNC_BUILD_ENABLED = 
"phoenix.index.async.build.enabled";
 
@@ -292,6 +294,9 @@ public interface QueryServices extends SQLCloseable {
 //Update Cache Frequency default config attribute
 public static final String DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB  = 
"phoenix.default.update.cache.frequency";
 
+// Whether to enable cost-based-decision in the query optimizer
+public static final String COST_BASED_OPTIMIZER_ENABLED = 
"phoenix.costbased.optimizer.enabled";
+
 /**
  * Get executor service used for parallel scans
  */

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index af6a054..4d31974 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -25,6 +25,7 @@ import static 
org.apache.phoenix.query.QueryServices.CALL_QUEUE_PRODUCER_ATTRIB_
 import static 
org.apache.phoenix.query.QueryServices.CALL_QUEUE_ROUND_ROBIN_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.COLLECT_REQUEST_LEVEL_METRICS;
 import static org.apache.phoenix.query.QueryServices.COMMIT_STATS_ASYNC;
+import static 
org.apache.phoenix.query.QueryServices.COST_BASED_OPTIMIZER_ENABLED;
 import static org.apache.phoenix.query.QueryServices.DATE_FORMAT_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.DELAY_FOR_SCHEMA_UPDATE_CHECK;
@@ -58,6 +59,7 @@ import static 
org.apache.phoenix.query.QueryServices.MAX_TENANT_MEMORY_PERC_ATTR
 import static 
org.apache.phoenix.query.QueryServices.MIN_STATS_UPDATE_FREQ_MS_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServices.NUM_RETRIES_FOR_SCHEMA_UPDATE_CHECK;
+import static org.apache.phoenix.query.QueryServices.PHOENIX_ACLS_ENABLED;
 import static 
org.apache.phoenix.query.QueryServices.PHOENIX_QUERY_SERVER_CLUSTER_BASE_PATH;
 import static 
org.apache.phoenix.query.QueryServices.PHOENIX_QUERY_SERVER_LOADBALANCER_ENABLED;
 import static 
org.apache.phoenix.query.QueryServices.PHOENIX_QUERY_SERVER_SERVICE_NAME;
@@ -316,6 +318,9 @@ public class QueryServicesOptions {
 public static final int DEFAULT_CLIENT_CONNECTION_MAX_ALLOWED_CONNECTIONS 
= 0;
 public static final boolean DEFAULT_STATS_COLLECTION_ENABLED = true;
 public static final boolean DEFAULT_USE_STATS_FOR_PARALLELIZATION = true;
+
+//Security defaults
+public static final boolean DEFAULT_PHOENIX_ACLS_ENABLED = false;
 
 //default update cache frequency
 public static final int DEFAULT_UPDATE_CACHE_FREQUENCY = 0;
@@ -337,6 +342,8 @@ public class QueryServicesOptions {
 // RS -> RS calls for upsert select statements are disabled by default
 public static final boolean DEFAULT_ENABLE_SERVER_UPSERT_SELECT = false;
 
+public static final boolean DEFAULT_COST_BASED_OPTIMIZER_ENABLED = false;
+
 private final Configuration config;
 
 private QueryServicesOptions(Configuration config) {
@@ -413,7 +420,10 @@ public class QueryServicesOptions {
 .setIfUnset(TRACING_BATCH_SIZE, DEFAULT_TRACING_BATCH_SIZE)
 .setIfUnset(TRACING_THREAD_POOL_SIZE, 
DEFAULT_TRACING_THREAD_POOL_SIZE)
 .setIfUnset(STATS_COLLECTION_ENABLED, 
DEFAULT_STATS_COLLECTION_ENABLED)
-.setIfUnset(USE_STATS_FOR_PARALLELIZATION, 
DEFAULT_USE_STATS_FOR_PARALLELIZATION);
+.setIfUnset(USE_STATS_FOR_PARALLELIZATION, 
DEFAULT_USE_STATS_FOR_PARALLELIZATION)
+

[5/6] phoenix git commit: Sync 4.x-HBase-1.2 to master (Pedro Boado)

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
new file mode 100644
index 000..36782c1
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.QueryServices;
+import org.junit.Test;
+
+public class MutationStateIT extends ParallelStatsDisabledIT {
+
+private static final String DDL =
+" (ORGANIZATION_ID CHAR(15) NOT NULL, SCORE DOUBLE, "
++ "ENTITY_ID CHAR(15) NOT NULL, TAGS VARCHAR, CONSTRAINT 
PAGE_SNAPSHOT_PK "
++ "PRIMARY KEY (ORGANIZATION_ID, ENTITY_ID DESC)) 
MULTI_TENANT=TRUE";
+
+private void upsertRows(PhoenixConnection conn, String fullTableName) 
throws SQLException {
+PreparedStatement stmt =
+conn.prepareStatement("upsert into " + fullTableName
++ " (organization_id, entity_id, score) values 
(?,?,?)");
+for (int i = 0; i < 1; i++) {
+stmt.setString(1, "" + i);
+stmt.setString(2, "" + i);
+stmt.setInt(3, 1);
+stmt.execute();
+}
+}
+
+@Test
+public void testMaxMutationSize() throws Exception {
+Properties connectionProperties = new Properties();
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "3");
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, 
"100");
+PhoenixConnection connection =
+(PhoenixConnection) DriverManager.getConnection(getUrl(), 
connectionProperties);
+String fullTableName = generateUniqueName();
+try (Statement stmt = connection.createStatement()) {
+stmt.execute(
+"CREATE TABLE " + fullTableName + DDL);
+}
+try {
+upsertRows(connection, fullTableName);
+fail();
+} catch (SQLException e) {
+
assertEquals(SQLExceptionCode.MAX_MUTATION_SIZE_EXCEEDED.getErrorCode(),
+e.getErrorCode());
+}
+
+// set the max mutation size (bytes) to a low value
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, 
"1000");
+
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, 
"4");
+connection =
+(PhoenixConnection) DriverManager.getConnection(getUrl(), 
connectionProperties);
+try {
+upsertRows(connection, fullTableName);
+fail();
+} catch (SQLException e) {
+
assertEquals(SQLExceptionCode.MAX_MUTATION_SIZE_BYTES_EXCEEDED.getErrorCode(),
+e.getErrorCode());
+}
+}
+
+@Test
+public void testMutationEstimatedSize() throws Exception {
+PhoenixConnection conn = (PhoenixConnection) 
DriverManager.getConnection(getUrl());
+conn.setAutoCommit(false);
+String fullTableName = generateUniqueName();
+try (Statement stmt = conn.createStatement()) {
+stmt.execute(
+"CREATE TABLE " + fullTableName + DDL);
+}
+
+// upserting rows should increase the mutation state size
+MutationState state = 
conn.unwrap(PhoenixConnection.class).getMutationState();
+long prevEstimatedSize = state.getEstimatedSize();
+upsertRows(conn, fullTableName);
+ 

[2/6] phoenix git commit: Sync 4.x-HBase-1.2 to master (Pedro Boado)

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index 0faa20c..993438e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -96,6 +96,7 @@ import org.apache.phoenix.util.SQLCloseable;
 import org.apache.phoenix.util.SQLCloseables;
 import org.apache.phoenix.util.ScanUtil;
 import org.apache.phoenix.util.ServerUtil;
+import org.apache.phoenix.util.SizedUtil;
 import org.apache.phoenix.util.TransactionUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -122,7 +123,7 @@ public class MutationState implements SQLCloseable {
 private final long batchSize;
 private final long batchSizeBytes;
 private long batchCount = 0L;
-private final Map> 
mutations;
+private final Map mutations;
 private final Set uncommittedPhysicalNames = 
Sets.newHashSetWithExpectedSize(10);
 
 private long sizeOffset;
@@ -130,7 +131,7 @@ public class MutationState implements SQLCloseable {
 private long estimatedSize = 0;
 private int[] uncommittedStatementIndexes = EMPTY_STATEMENT_INDEX_ARRAY;
 private boolean isExternalTxContext = false;
-private Map> txMutations 
= Collections.emptyMap();
+private Map txMutations = 
Collections.emptyMap();
 
 final PhoenixTransactionContext phoenixTransactionContext;
 
@@ -158,12 +159,12 @@ public class MutationState implements SQLCloseable {
 }
 
 private MutationState(long maxSize, long maxSizeBytes, PhoenixConnection 
connection, boolean subTask, PhoenixTransactionContext txContext, long 
sizeOffset) {
-this(maxSize, maxSizeBytes, connection, Maps.>newHashMapWithExpectedSize(5), subTask, 
txContext);
+this(maxSize, maxSizeBytes, connection, Maps.newHashMapWithExpectedSize(5), subTask, txContext);
 this.sizeOffset = sizeOffset;
 }
 
 MutationState(long maxSize, long maxSizeBytes, PhoenixConnection 
connection,
-Map> mutations,
+Map mutations,
 boolean subTask, PhoenixTransactionContext txContext) {
 this.maxSize = maxSize;
 this.maxSizeBytes = maxSizeBytes;
@@ -188,15 +189,19 @@ public class MutationState implements SQLCloseable {
 }
 }
 
-public MutationState(TableRef table, 
Map mutations, long sizeOffset, long 
maxSize, long maxSizeBytes, PhoenixConnection connection) throws SQLException {
+public MutationState(TableRef table, MultiRowMutationState mutations, long 
sizeOffset, long maxSize, long maxSizeBytes, PhoenixConnection connection)  
throws SQLException {
 this(maxSize, maxSizeBytes, connection, false, null, sizeOffset);
 if (!mutations.isEmpty()) {
 this.mutations.put(table, mutations);
 }
 this.numRows = mutations.size();
-this.estimatedSize = KeyValueUtil.getEstimatedRowSize(table, 
mutations);
+this.estimatedSize = 
KeyValueUtil.getEstimatedRowMutationSize(this.mutations);
 throwIfTooBig();
 }
+
+public long getEstimatedSize() {
+return estimatedSize;
+}
 
 public long getMaxSize() {
 return maxSize;
@@ -345,7 +350,7 @@ public class MutationState implements SQLCloseable {
 }
 
 public static MutationState emptyMutationState(long maxSize, long 
maxSizeBytes, PhoenixConnection connection) {
-MutationState state = new MutationState(maxSize, maxSizeBytes, 
connection, Collections.>emptyMap(), false, null);
+MutationState state = new MutationState(maxSize, maxSizeBytes, 
connection, Collections.emptyMap(), false, 
null);
 state.sizeOffset = 0;
 return state;
 }
@@ -367,12 +372,12 @@ public class MutationState implements SQLCloseable {
 return sizeOffset + numRows;
 }
 
-private void joinMutationState(TableRef tableRef, 
Map srcRows,
-Map> 
dstMutations) {
+private void joinMutationState(TableRef tableRef, MultiRowMutationState 
srcRows,
+Map dstMutations) {
 PTable table = tableRef.getTable();
 boolean isIndex = 

[4/6] phoenix git commit: Sync 4.x-HBase-1.2 to master (Pedro Boado)

2017-12-16 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
index ddc2004..97f3f3d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutationPlan.java
@@ -24,6 +24,7 @@ import org.apache.phoenix.schema.TableRef;
 
 
 public interface MutationPlan extends StatementPlan {
-public MutationState execute() throws SQLException;
-public TableRef getTargetRef();
+MutationState execute() throws SQLException;
+TableRef getTargetRef();
+QueryPlan getQueryPlan();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
index af2254b..287f9e0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
@@ -307,7 +307,7 @@ public class QueryCompiler {
 JoinSpec joinSpec = joinSpecs.get(i);
 
context.setResolver(FromCompiler.getResolverForProjectedTable(projectedTable, 
context.getConnection(), query.getUdfParseNodes()));
 joinIds[i] = new ImmutableBytesPtr(emptyByteArray); // 
place-holder
-Pair joinConditions = 
joinSpec.compileJoinConditions(context, subContexts[i], true);
+Pair joinConditions = 
joinSpec.compileJoinConditions(context, subContexts[i], 
JoinCompiler.Strategy.HASH_BUILD_RIGHT);
 joinExpressions[i] = joinConditions.getFirst();
 List hashExpressions = joinConditions.getSecond();
 Pair keyRangeExpressions = new 
Pair(null, null);
@@ -369,7 +369,7 @@ public class QueryCompiler {
 context.setCurrentTable(rhsTableRef);
 
context.setResolver(FromCompiler.getResolverForProjectedTable(rhsProjTable, 
context.getConnection(), rhs.getUdfParseNodes()));
 ImmutableBytesPtr[] joinIds = new ImmutableBytesPtr[] {new 
ImmutableBytesPtr(emptyByteArray)};
-Pair joinConditions = 
lastJoinSpec.compileJoinConditions(lhsCtx, context, true);
+Pair joinConditions = 
lastJoinSpec.compileJoinConditions(lhsCtx, context, 
JoinCompiler.Strategy.HASH_BUILD_LEFT);
 List joinExpressions = joinConditions.getSecond();
 List hashExpressions = joinConditions.getFirst();
 boolean needsMerge = lhsJoin.hasPostReference();
@@ -422,7 +422,7 @@ public class QueryCompiler {
 QueryPlan rhsPlan = compileJoinQuery(rhsCtx, binds, rhsJoin, true, 
true, rhsOrderBy);
 PTable rhsProjTable = 
rhsCtx.getResolver().getTables().get(0).getTable();
 
-Pair joinConditions = 
lastJoinSpec.compileJoinConditions(type == JoinType.Right ? rhsCtx : lhsCtx, 
type == JoinType.Right ? lhsCtx : rhsCtx, false);
+Pair joinConditions = 
lastJoinSpec.compileJoinConditions(type == JoinType.Right ? rhsCtx : lhsCtx, 
type == JoinType.Right ? lhsCtx : rhsCtx, JoinCompiler.Strategy.SORT_MERGE);
 List lhsKeyExpressions = type == JoinType.Right ? 
joinConditions.getSecond() : joinConditions.getFirst();
 List rhsKeyExpressions = type == JoinType.Right ? 
joinConditions.getFirst() : joinConditions.getSecond();
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70f55a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
index f7cdcbf..ca88984 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryPlan.java
@@ -26,6 +26,7 @@ import org.apache.phoenix.compile.GroupByCompiler.GroupBy;
 import org.apache.phoenix.compile.OrderByCompiler.OrderBy;
 import org.apache.phoenix.iterate.ParallelScanGrouper;
 import org.apache.phoenix.iterate.ResultIterator;
+import org.apache.phoenix.optimize.Cost;
 import org.apache.phoenix.parse.FilterableStatement;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.schema.TableRef;
@@ -52,7 +53,9 @@ public interface QueryPlan extends StatementPlan {
 

[1/2] phoenix git commit: PHOENIX-4453 Incompatible httpclient version included in thin client library (Pedro Boado)

2017-12-16 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.11.2 bea0592c2 -> a50bf3e5f


PHOENIX-4453 Incompatible httpclient version included in thin client library 
(Pedro Boado)


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

Branch: refs/heads/4.x-cdh5.11.2
Commit: 4332122ddcf26c14b0341bf86e1f26b41611bd5f
Parents: bea0592
Author: James Taylor 
Authored: Sat Dec 16 10:20:06 2017 -0800
Committer: James Taylor 
Committed: Sat Dec 16 10:20:06 2017 -0800

--
 phoenix-queryserver-client/pom.xml | 11 +++
 1 file changed, 11 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/4332122d/phoenix-queryserver-client/pom.xml
--
diff --git a/phoenix-queryserver-client/pom.xml 
b/phoenix-queryserver-client/pom.xml
index 473a97e..2e19863 100644
--- a/phoenix-queryserver-client/pom.xml
+++ b/phoenix-queryserver-client/pom.xml
@@ -193,5 +193,16 @@
   org.apache.hadoop
   hadoop-common
 
+
+
+  org.apache.httpcomponents
+  httpclient
+  4.5.2
+
+
+  org.apache.httpcomponents
+  httpcore
+  4.4.4
+
   
 



Build failed in Jenkins: Phoenix Compile Compatibility with HBase #490

2017-12-16 Thread Apache Jenkins Server
See 


--
Started by timer
[EnvInject] - Loading node environment variables.
Building remotely on H25 (ubuntu xenial) in workspace 

[Phoenix_Compile_Compat_wHBase] $ /bin/bash /tmp/jenkins8469615300650967640.sh
core file size  (blocks, -c) 0
data seg size   (kbytes, -d) unlimited
scheduling priority (-e) 0
file size   (blocks, -f) unlimited
pending signals (-i) 386417
max locked memory   (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files  (-n) 6
pipe size(512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority  (-r) 0
stack size  (kbytes, -s) 8192
cpu time   (seconds, -t) unlimited
max user processes  (-u) 10240
virtual memory  (kbytes, -v) unlimited
file locks  (-x) unlimited
core id : 0
core id : 1
core id : 2
core id : 3
core id : 4
core id : 5
physical id : 0
physical id : 1
MemTotal:   98958120 kB
MemFree:26343548 kB
Filesystem  Size  Used Avail Use% Mounted on
udev 48G 0   48G   0% /dev
tmpfs   9.5G  962M  8.5G  10% /run
/dev/sda1   364G  206G  140G  60% /
tmpfs48G  1.1M   48G   1% /dev/shm
tmpfs   5.0M 0  5.0M   0% /run/lock
tmpfs48G 0   48G   0% /sys/fs/cgroup
tmpfs   9.5G 0  9.5G   0% /run/user/910
apache-maven-2.2.1
apache-maven-3.0.4
apache-maven-3.0.5
apache-maven-3.2.1
apache-maven-3.2.5
apache-maven-3.3.3
apache-maven-3.3.9
apache-maven-3.5.0
apache-maven-3.5.2
latest
latest2
latest3


===
Verifying compile level compatibility with HBase 0.98 with Phoenix 
4.x-HBase-0.98
===

Cloning into 'hbase'...
Switched to a new branch '0.98'
Branch 0.98 set up to track remote branch 0.98 from origin.

main:
 [exec] 
~/jenkins-slave/workspace/Phoenix_Compile_Compat_wHBase/hbase/hbase-common 
~/jenkins-slave/workspace/Phoenix_Compile_Compat_wHBase/hbase/hbase-common
 [exec] 
~/jenkins-slave/workspace/Phoenix_Compile_Compat_wHBase/hbase/hbase-common

main:
[mkdir] Created dir: 

 [exec] tar: hadoop-snappy-nativelibs.tar: Cannot open: No such file or 
directory
 [exec] tar: Error is not recoverable: exiting now
 [exec] Result: 2

main:
[mkdir] Created dir: 

 [copy] Copying 20 files to 

[mkdir] Created dir: 

[mkdir] Created dir: 


main:
[mkdir] Created dir: 

 [copy] Copying 17 files to 

[mkdir] Created dir: 


main:
[mkdir] Created dir: 

 [copy] Copying 1 file to 

[mkdir] Created dir: 


HBase pom.xml:

Got HBase version as 0.98.25-SNAPSHOT
Cloning into 'phoenix'...
Switched to a new branch '4.x-HBase-0.98'
Branch 4.x-HBase-0.98 set up to track remote branch 4.x-HBase-0.98 from origin.
ANTLR Parser Generator  Version 3.5.2
Output file 

 does not exist: must build 

PhoenixSQL.g


===
Verifying compile level compatibility with HBase branch-1.3 with Phoenix master