You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2016/11/29 19:16:05 UTC
phoenix git commit: PHOENIX-3295 Remove
ReplaceArrayColumnWithKeyValueColumnExpressionVisitor
Repository: phoenix
Updated Branches:
refs/heads/encodecolumns2 0c64b4a8d -> 581a9652b
PHOENIX-3295 Remove ReplaceArrayColumnWithKeyValueColumnExpressionVisitor
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/581a9652
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/581a9652
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/581a9652
Branch: refs/heads/encodecolumns2
Commit: 581a9652b1134ffc2a6523c2daff71477dceeedb
Parents: 0c64b4a
Author: Thomas D'Silva <td...@salesforce.com>
Authored: Tue Nov 22 12:32:34 2016 -0800
Committer: Thomas D'Silva <td...@salesforce.com>
Committed: Tue Nov 29 10:53:15 2016 -0800
----------------------------------------------------------------------
.../apache/phoenix/compile/WhereCompiler.java | 3 ++-
.../expression/ArrayColumnExpression.java | 28 +++++++++++++-------
.../apache/phoenix/index/IndexMaintainer.java | 11 ++++----
.../apache/phoenix/query/QueryConstants.java | 7 +++--
.../org/apache/phoenix/schema/PTableImpl.java | 4 +--
5 files changed, 32 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/581a9652/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
index dd1daf2..52eba47 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
@@ -46,6 +46,7 @@ import org.apache.phoenix.parse.ParseNodeFactory;
import org.apache.phoenix.parse.SelectStatement;
import org.apache.phoenix.parse.StatelessTraverseAllParseNodeVisitor;
import org.apache.phoenix.parse.SubqueryParseNode;
+import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.schema.AmbiguousColumnException;
import org.apache.phoenix.schema.ColumnNotFoundException;
import org.apache.phoenix.schema.ColumnRef;
@@ -173,7 +174,7 @@ public class WhereCompiler {
Expression newColumnExpression = ref.newColumnExpression(node.isTableNameCaseSensitive(), node.isCaseSensitive());
if (tableRef.equals(context.getCurrentTable()) && !SchemaUtil.isPKColumn(ref.getColumn())) {
byte[] cq = tableRef.getTable().getStorageScheme() == StorageScheme.ONE_CELL_PER_COLUMN_FAMILY
- ? ref.getColumn().getFamilyName().getBytes() : EncodedColumnsUtil.getColumnQualifier(ref.getColumn(), tableRef.getTable());
+ ? QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES : EncodedColumnsUtil.getColumnQualifier(ref.getColumn(), tableRef.getTable());
// track the where condition columns. Later we need to ensure the Scan in HRS scans these column CFs
context.addWhereCoditionColumn(ref.getColumn().getFamilyName().getBytes(), cq);
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/581a9652/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayColumnExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayColumnExpression.java
index 0b5e5d7..f09fb62 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayColumnExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayColumnExpression.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.io.WritableUtils;
import org.apache.phoenix.compile.CreateTableCompiler.ViewWhereExpressionVisitor;
import org.apache.phoenix.expression.visitor.ExpressionVisitor;
+import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PDatum;
import org.apache.phoenix.schema.SortOrder;
@@ -45,19 +46,22 @@ public class ArrayColumnExpression extends KeyValueColumnExpression {
private int positionInArray;
private String arrayColDisplayName;
+ private KeyValueColumnExpression keyValueColumnExpression;
public ArrayColumnExpression() {
}
public ArrayColumnExpression(PDatum column, byte[] cf, int encodedCQ) {
- super(column, cf, cf);
+ super(column, cf, QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES);
this.positionInArray = encodedCQ;
+ setKeyValueExpression();
}
public ArrayColumnExpression(PColumn column, String displayName, boolean encodedColumnName) {
- super(column, column.getFamilyName().getBytes(), column.getFamilyName().getBytes());
+ super(column, column.getFamilyName().getBytes(), QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES);
this.arrayColDisplayName = displayName;
this.positionInArray = column.getEncodedColumnQualifier();
+ setKeyValueExpression();
}
@Override
@@ -77,7 +81,8 @@ public class ArrayColumnExpression extends KeyValueColumnExpression {
@Override
public void readFields(DataInput input) throws IOException {
super.readFields(input);
- positionInArray = WritableUtils.readVInt(input);
+ this.positionInArray = WritableUtils.readVInt(input);
+ setKeyValueExpression();
}
@Override
@@ -87,13 +92,16 @@ public class ArrayColumnExpression extends KeyValueColumnExpression {
}
public KeyValueColumnExpression getKeyValueExpression() {
- final boolean isNullable = isNullable();
- final SortOrder sortOrder = getSortOrder();
- final Integer scale = getScale();
- final Integer maxLength = getMaxLength();
- final PDataType datatype = getDataType();
- return new KeyValueColumnExpression(new PDatum() {
-
+ return keyValueColumnExpression;
+ }
+
+ private void setKeyValueExpression() {
+ final boolean isNullable = isNullable();
+ final SortOrder sortOrder = getSortOrder();
+ final Integer scale = getScale();
+ final Integer maxLength = getMaxLength();
+ final PDataType datatype = getDataType();
+ this.keyValueColumnExpression = new KeyValueColumnExpression(new PDatum() {
@Override
public boolean isNullable() {
return isNullable;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/581a9652/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
index e20c994..2ab3730 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
@@ -25,7 +25,6 @@ import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.nio.ByteBuffer;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -938,18 +937,18 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> {
ImmutableBytesPtr rowKey = new ImmutableBytesPtr(indexRowKey);
if (storeColsInSingleCell) {
// map from index column family to list of pair of index column and data column (for covered columns)
- Map<ByteBuffer, List<Pair<ColumnReference, ColumnReference>>> familyToColListMap = Maps.newHashMap();
+ Map<ImmutableBytesPtr, List<Pair<ColumnReference, ColumnReference>>> familyToColListMap = Maps.newHashMap();
for (ColumnReference ref : this.getCoveredColumns()) {
ColumnReference indexColRef = this.coveredColumnsMap.get(ref);
- ByteBuffer cf = ByteBuffer.wrap(indexColRef.getFamily());
+ ImmutableBytesPtr cf = new ImmutableBytesPtr(indexColRef.getFamily());
if (!familyToColListMap.containsKey(cf)) {
familyToColListMap.put(cf, Lists.<Pair<ColumnReference, ColumnReference>>newArrayList());
}
familyToColListMap.get(cf).add(Pair.newPair(indexColRef, ref));
}
// iterate over each column family and create a byte[] containing all the columns
- for (Entry<ByteBuffer, List<Pair<ColumnReference, ColumnReference>>> entry : familyToColListMap.entrySet()) {
- byte[] columnFamily = entry.getKey().array();
+ for (Entry<ImmutableBytesPtr, List<Pair<ColumnReference, ColumnReference>>> entry : familyToColListMap.entrySet()) {
+ byte[] columnFamily = entry.getKey().copyBytesIfNecessary();
List<Pair<ColumnReference, ColumnReference>> colRefPairs = entry.getValue();
int maxIndex = Integer.MIN_VALUE;
// find the max col qualifier
@@ -1014,7 +1013,7 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> {
}
ImmutableBytesPtr colFamilyPtr = new ImmutableBytesPtr(columnFamily);
//this is a little bit of extra work for installations that are running <0.94.14, but that should be rare and is a short-term set of wrappers - it shouldn't kill GC
- put.add(kvBuilder.buildPut(rowKey, colFamilyPtr, colFamilyPtr, ts, ptr));
+ put.add(kvBuilder.buildPut(rowKey, colFamilyPtr, QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES_PTR, ts, ptr));
}
}
else {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/581a9652/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
index 954e78a..fe0d9cb 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
@@ -123,8 +123,6 @@ import org.apache.phoenix.schema.MetaDataSplitPolicy;
import org.apache.phoenix.schema.PName;
import org.apache.phoenix.schema.PNameFactory;
import org.apache.phoenix.schema.SortOrder;
-import org.apache.phoenix.schema.types.PInteger;
-import org.apache.phoenix.util.EncodedColumnsUtil;
/**
@@ -221,6 +219,11 @@ public interface QueryConstants {
public static final byte[] DEFAULT_COLUMN_FAMILY_BYTES = Bytes.toBytes(DEFAULT_COLUMN_FAMILY);
public static final ImmutableBytesPtr DEFAULT_COLUMN_FAMILY_BYTES_PTR = new ImmutableBytesPtr(
DEFAULT_COLUMN_FAMILY_BYTES);
+ // column qualifier of the single key value used to store all columns for the COLUMNS_STORED_IN_SINGLE_CELL storage scheme
+ public static final String SINGLE_KEYVALUE_COLUMN_QUALIFIER = "0";
+ public final static byte[] SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES = Bytes.toBytes(SINGLE_KEYVALUE_COLUMN_QUALIFIER);
+ public static final ImmutableBytesPtr SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES_PTR = new ImmutableBytesPtr(
+ SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES);
public static final String LOCAL_INDEX_COLUMN_FAMILY_PREFIX = "L#";
public static final byte[] LOCAL_INDEX_COLUMN_FAMILY_PREFIX_BYTES = Bytes.toBytes(LOCAL_INDEX_COLUMN_FAMILY_PREFIX);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/581a9652/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
index e225940..8522c13 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
@@ -914,7 +914,7 @@ public class PTableImpl implements PTable {
arrayExpression.evaluate(new BaseTuple() {}, ptr);
ImmutableBytesPtr colFamilyPtr = new ImmutableBytesPtr(columnFamily);
addQuietly(put, kvBuilder, kvBuilder.buildPut(keyPtr,
- colFamilyPtr, colFamilyPtr, ts, ptr));
+ colFamilyPtr, QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES_PTR, ts, ptr));
}
setValues = put;
}
@@ -988,7 +988,7 @@ public class PTableImpl implements PTable {
ptr.set(byteValue);
type.pad(ptr, maxLength, sortOrder);
removeIfPresent(unsetValues, family, qualifier);
- // store all columns for a given column family in a single cell instead of one column per cell in order to improve write performance
+ // store all columns for a given column family in a single cell instead of one column per cell in order to improve write performance
// we don't need to do anything with unsetValues as it is only used when storeNulls is false, storeNulls is always true when storeColsInSingleCell is true
if (storageScheme == StorageScheme.ONE_CELL_PER_COLUMN_FAMILY) {
columnToValueMap.put(column, ptr.get());