Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1756319893 for ; Mon, 25 Apr 2016 18:52:47 +0000 (UTC) Received: (qmail 44803 invoked by uid 500); 25 Apr 2016 18:52:46 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 44734 invoked by uid 500); 25 Apr 2016 18:52:46 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 43934 invoked by uid 99); 25 Apr 2016 18:52:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Apr 2016 18:52:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6853DDFF70; Mon, 25 Apr 2016 18:52:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: samarth@apache.org To: commits@phoenix.apache.org Date: Mon, 25 Apr 2016 18:53:22 -0000 Message-Id: <32fa9ca329f74368b523ca9c33ee3d28@git.apache.org> In-Reply-To: <9ebccd69205b40469f4553addf9ffe9e@git.apache.org> References: <9ebccd69205b40469f4553addf9ffe9e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [38/52] [abbrv] phoenix git commit: Provide right column qualifiers for arrays Provide right column qualifiers for arrays Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d89c5cb1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d89c5cb1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d89c5cb1 Branch: refs/heads/encodecolumns Commit: d89c5cb119df5b769f6e6f9931dcab229c6dedc6 Parents: 13a900f Author: Samarth Authored: Thu Mar 24 15:53:39 2016 -0700 Committer: Samarth Committed: Mon Apr 25 11:51:31 2016 -0700 ---------------------------------------------------------------------- .../apache/phoenix/compile/ProjectionCompiler.java | 4 ++-- .../coprocessor/BaseScannerRegionObserver.java | 16 +--------------- .../java/org/apache/phoenix/schema/PColumn.java | 2 +- .../java/org/apache/phoenix/util/IndexUtil.java | 5 ++--- .../java/org/apache/phoenix/util/SchemaUtil.java | 4 ++++ 5 files changed, 10 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/d89c5cb1/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java index e07b350..b9bfff3 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java @@ -702,8 +702,8 @@ public class ProjectionCompiler { public Void visit(ProjectedColumnExpression expression) { if (expression.getDataType().isArrayType()) { indexProjectedColumns.add(expression); - //TODO: samarth confirm this change is to have encodedColumnNames as false. - KeyValueColumnExpression keyValueColumnExpression = new KeyValueColumnExpression(expression.getColumn(), false); + PColumn col = expression.getColumn(); + KeyValueColumnExpression keyValueColumnExpression = new KeyValueColumnExpression(col, SchemaUtil.hasEncodedColumnName(col)); indexKVs.add(keyValueColumnExpression); copyOfChildren.set(0, keyValueColumnExpression); Integer count = arrayExpressionCounts.get(expression); http://git-wip-us.apache.org/repos/asf/phoenix/blob/d89c5cb1/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java index d66c7ae..9814a7d 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java @@ -395,24 +395,10 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { // Using KeyValueSchema to set and retrieve the value // collect the first kv to get the row Cell rowKv = result.get(0); - for (KeyValueColumnExpression kvExp : arrayKVRefs) { - if (kvExp.evaluate(tuple, ptr)) { - for (int idx = tuple.size() - 1; idx >= 0; idx--) { - Cell kv = tuple.getValue(idx); - if (Bytes.equals(kvExp.getColumnFamily(), 0, kvExp.getColumnFamily().length, - kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength()) - && Bytes.equals(kvExp.getColumnQualifier(), 0, kvExp.getColumnQualifier().length, - kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength())) { - // remove the kv that has the full array values. - result.remove(idx); - break; - } - } - } - } byte[] value = kvSchema.toBytes(tuple, arrayFuncRefs, kvSchemaBitSet, ptr); // Add a dummy kv with the exact value of the array index + // TODO: samarth how does this dummy column qualifier play with encoded column names result.add(new KeyValue(rowKv.getRowArray(), rowKv.getRowOffset(), rowKv.getRowLength(), QueryConstants.ARRAY_VALUE_COLUMN_FAMILY, 0, QueryConstants.ARRAY_VALUE_COLUMN_FAMILY.length, QueryConstants.ARRAY_VALUE_COLUMN_QUALIFIER, 0, http://git-wip-us.apache.org/repos/asf/phoenix/blob/d89c5cb1/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java index 3ffb845..8f61d6d 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumn.java @@ -64,7 +64,7 @@ public interface PColumn extends PDatum { /** * @return name of the HBase column qualifier * TODO: samarth I think we should should change this to return byte[] array. - * Then we won't have to worry about calling SchemaUtil... everywhere. I think. + * Then we won't have to worry about calling SchemaUtil... everywhere */ Integer getColumnQualifier(); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/d89c5cb1/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java index bdc546f..15fc605 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import co.cask.tephra.TxConstants; + import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.KeyValue; @@ -67,7 +69,6 @@ import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.parse.ParseNode; import org.apache.phoenix.parse.SQLParser; import org.apache.phoenix.parse.SelectStatement; -import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.ColumnFamilyNotFoundException; import org.apache.phoenix.schema.ColumnNotFoundException; import org.apache.phoenix.schema.ColumnRef; @@ -87,8 +88,6 @@ import org.apache.phoenix.schema.types.PVarchar; import com.google.common.collect.Lists; -import co.cask.tephra.TxConstants; - public class IndexUtil { public static final String INDEX_COLUMN_NAME_SEP = ":"; public static final byte[] INDEX_COLUMN_NAME_SEP_BYTES = Bytes.toBytes(INDEX_COLUMN_NAME_SEP); http://git-wip-us.apache.org/repos/asf/phoenix/blob/d89c5cb1/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java index 2202277..d7d7d8b 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java @@ -1068,4 +1068,8 @@ public class SchemaUtil { QueryConstants.EMPTY_COLUMN_VALUE_BYTES); } + public static boolean hasEncodedColumnName(PColumn column){ + return !SchemaUtil.isPKColumn(column) && column.getColumnQualifier() != null; + } + }