Repository: phoenix Updated Branches: refs/heads/encodecolumns2 61d9035cd -> 1f3f7323a
http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/phoenix-core/src/main/java/org/apache/phoenix/util/EncodedColumnsUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/EncodedColumnsUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/EncodedColumnsUtil.java index 1726115..ce2c98c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/EncodedColumnsUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/EncodedColumnsUtil.java @@ -20,17 +20,23 @@ package org.apache.phoenix.util; import static com.google.common.base.Preconditions.checkNotNull; import static org.apache.phoenix.schema.PTable.QualifierEncodingScheme.NON_ENCODED_QUALIFIERS; +import java.util.Arrays; import java.util.Map; import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; import org.apache.phoenix.coprocessor.BaseScannerRegionObserver; +import org.apache.phoenix.expression.DelegateExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.PColumn; import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTable.ImmutableStorageScheme; import org.apache.phoenix.schema.PTable.QualifierEncodingScheme; -import org.apache.phoenix.schema.PTable.StorageScheme; +import org.apache.phoenix.schema.tuple.Tuple; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; @@ -46,7 +52,7 @@ public class EncodedColumnsUtil { } public static void setColumns(PColumn column, PTable table, Scan scan) { - if (table.getStorageScheme() == StorageScheme.ONE_CELL_PER_COLUMN_FAMILY) { + if (table.getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS) { // if a table storage scheme is COLUMNS_STORED_IN_SINGLE_CELL set then all columns of a column family are stored in a single cell // (with the qualifier name being same as the family name), just project the column family here // so that we can calculate estimatedByteSize correctly in ProjectionCompiler @@ -59,9 +65,13 @@ public class EncodedColumnsUtil { } } - public static QualifierEncodingScheme getEncodingScheme(Scan s) { + public static QualifierEncodingScheme getQualifierEncodingScheme(Scan s) { return QualifierEncodingScheme.fromSerializedValue(s.getAttribute(BaseScannerRegionObserver.QUALIFIER_ENCODING_SCHEME)[0]); } + + public static ImmutableStorageScheme getImmutableStorageScheme(Scan s) { + return ImmutableStorageScheme.fromSerializedValue(s.getAttribute(BaseScannerRegionObserver.IMMUTABLE_STORAGE_ENCODING_SCHEME)[0]); + } /** * @return pair of byte arrays. The first part of the pair is the empty key value's column qualifier, and the second @@ -110,8 +120,8 @@ public class EncodedColumnsUtil { } public static boolean setQualifierRanges(PTable table) { - return table.getStorageScheme() != null - && table.getStorageScheme() == StorageScheme.ONE_CELL_PER_KEYVALUE_COLUMN + return table.getImmutableStorageScheme() != null + && table.getImmutableStorageScheme() == ImmutableStorageScheme.ONE_CELL_PER_COLUMN && usesEncodedColumnNames(table) && !table.isTransactional() && !ScanUtil.hasDynamicColumns(table); } @@ -160,4 +170,19 @@ public class EncodedColumnsUtil { } return null; } + + public static Expression[] createColumnExpressionArray(int maxEncodedColumnQualifier) { + // reserve the first position and offset maxEncodedColumnQualifier by ENCODED_CQ_COUNTER_INITIAL_VALUE (which is the minimum encoded column qualifier) + int numElements = maxEncodedColumnQualifier - QueryConstants.ENCODED_CQ_COUNTER_INITIAL_VALUE+2; + Expression[] colValues = new Expression[numElements]; + Arrays.fill(colValues, new DelegateExpression(LiteralExpression.newConstant(null)) { + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + return false; + } + }); + // 0 is a reserved position, set it to a non-null value so that we can represent absence of a value using a negative offset + colValues[0]=LiteralExpression.newConstant(QueryConstants.EMPTY_COLUMN_VALUE_BYTES); + return colValues; + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/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 00d355c..217c99e 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 @@ -60,10 +60,10 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.exception.SQLExceptionInfo; import org.apache.phoenix.execute.MutationState.RowMutationState; import org.apache.phoenix.execute.TupleProjector; -import org.apache.phoenix.expression.ArrayColumnExpression; import org.apache.phoenix.expression.Expression; import org.apache.phoenix.expression.KeyValueColumnExpression; import org.apache.phoenix.expression.RowKeyColumnExpression; +import org.apache.phoenix.expression.SingleCellColumnExpression; import org.apache.phoenix.expression.visitor.RowKeyExpressionVisitor; import org.apache.phoenix.hbase.index.ValueGetter; import org.apache.phoenix.hbase.index.covered.update.ColumnReference; @@ -83,8 +83,8 @@ import org.apache.phoenix.schema.KeyValueSchema; import org.apache.phoenix.schema.PColumn; import org.apache.phoenix.schema.PColumnFamily; import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTable.ImmutableStorageScheme; import org.apache.phoenix.schema.PTable.QualifierEncodingScheme; -import org.apache.phoenix.schema.PTable.StorageScheme; import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.schema.TableRef; @@ -434,14 +434,15 @@ public class IndexUtil { if (dataColumns != null && dataColumns.length != 0) { KeyValueSchema keyValueSchema = deserializeLocalIndexJoinSchemaFromScan(scan); boolean storeColsInSingleCell = scan.getAttribute(BaseScannerRegionObserver.COLUMNS_STORED_IN_SINGLE_CELL) != null; - QualifierEncodingScheme scheme = EncodedColumnsUtil.getEncodingScheme(scan); - Expression[] colExpressions = storeColsInSingleCell ? new ArrayColumnExpression[dataColumns.length] : new KeyValueColumnExpression[dataColumns.length]; + QualifierEncodingScheme encodingScheme = EncodedColumnsUtil.getQualifierEncodingScheme(scan); + ImmutableStorageScheme immutableStorageScheme = EncodedColumnsUtil.getImmutableStorageScheme(scan); + Expression[] colExpressions = storeColsInSingleCell ? new SingleCellColumnExpression[dataColumns.length] : new KeyValueColumnExpression[dataColumns.length]; for (int i = 0; i < dataColumns.length; i++) { byte[] family = dataColumns[i].getFamily(); byte[] qualifier = dataColumns[i].getQualifier(); Field field = keyValueSchema.getField(i); Expression dataColumnExpr = - storeColsInSingleCell ? new ArrayColumnExpression(field, family, qualifier, scheme) + storeColsInSingleCell ? new SingleCellColumnExpression(field, family, qualifier, encodingScheme) : new KeyValueColumnExpression(field, family, qualifier); colExpressions[i] = dataColumnExpr; } @@ -494,9 +495,9 @@ public class IndexUtil { ptr.set(indexRowKey, firstCell.getRowOffset() + offset, firstCell.getRowLength() - offset); byte[] dataRowKey = indexMaintainer.buildDataRowKey(ptr, viewConstants); Get get = new Get(dataRowKey); - StorageScheme storageScheme = indexMaintainer.getIndexStorageScheme(); + ImmutableStorageScheme storageScheme = indexMaintainer.getIndexStorageScheme(); for (int i = 0; i < dataColumns.length; i++) { - if (storageScheme == StorageScheme.ONE_CELL_PER_COLUMN_FAMILY) { + if (storageScheme == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS) { get.addFamily(dataColumns[i].getFamily()); } else { get.addColumn(dataColumns[i].getFamily(), dataColumns[i].getQualifier()); http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/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 964bacc..5534eae 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 @@ -71,7 +71,7 @@ import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.RowKeySchema; import org.apache.phoenix.schema.PTable.QualifierEncodingScheme; -import org.apache.phoenix.schema.PTable.StorageScheme; +import org.apache.phoenix.schema.PTable.ImmutableStorageScheme; import org.apache.phoenix.schema.RowKeySchema.RowKeySchemaBuilder; import org.apache.phoenix.schema.SaltingUtil; import org.apache.phoenix.schema.SortOrder; http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/phoenix-core/src/test/java/org/apache/phoenix/execute/CorrelatePlanTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/execute/CorrelatePlanTest.java b/phoenix-core/src/test/java/org/apache/phoenix/execute/CorrelatePlanTest.java index c2d02ec..896fd24 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/execute/CorrelatePlanTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/execute/CorrelatePlanTest.java @@ -65,7 +65,7 @@ import org.apache.phoenix.schema.PNameFactory; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTable.EncodedCQCounter; import org.apache.phoenix.schema.PTable.QualifierEncodingScheme; -import org.apache.phoenix.schema.PTable.StorageScheme; +import org.apache.phoenix.schema.PTable.ImmutableStorageScheme; import org.apache.phoenix.schema.PTableImpl; import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.TableRef; @@ -262,7 +262,7 @@ public class CorrelatePlanTest { PTableType.SUBQUERY, null, MetaDataProtocol.MIN_TABLE_TIMESTAMP, PTable.INITIAL_SEQ_NUM, null, null, columns, null, null, Collections.<PTable>emptyList(), false, Collections.<PName>emptyList(), null, null, false, false, false, null, - null, null, true, false, 0, 0L, Boolean.FALSE, null, false, StorageScheme.ONE_CELL_PER_KEYVALUE_COLUMN, QualifierEncodingScheme.NON_ENCODED_QUALIFIERS, EncodedCQCounter.NULL_COUNTER); + null, null, true, false, 0, 0L, Boolean.FALSE, null, false, ImmutableStorageScheme.ONE_CELL_PER_COLUMN, QualifierEncodingScheme.NON_ENCODED_QUALIFIERS, EncodedCQCounter.NULL_COUNTER); TableRef sourceTable = new TableRef(pTable); List<ColumnRef> sourceColumnRefs = Lists.<ColumnRef> newArrayList(); for (PColumn column : sourceTable.getTable().getColumns()) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/phoenix-core/src/test/java/org/apache/phoenix/execute/LiteralResultIteratorPlanTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/execute/LiteralResultIteratorPlanTest.java b/phoenix-core/src/test/java/org/apache/phoenix/execute/LiteralResultIteratorPlanTest.java index e8e42a6..df55379 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/execute/LiteralResultIteratorPlanTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/execute/LiteralResultIteratorPlanTest.java @@ -62,7 +62,7 @@ import org.apache.phoenix.schema.PTable.QualifierEncodingScheme; import org.apache.phoenix.schema.PTableImpl; import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.TableRef; -import org.apache.phoenix.schema.PTable.StorageScheme; +import org.apache.phoenix.schema.PTable.ImmutableStorageScheme; import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; import org.apache.phoenix.schema.tuple.Tuple; import org.junit.Test; @@ -183,7 +183,7 @@ public class LiteralResultIteratorPlanTest { PTable pTable = PTableImpl.makePTable(null, PName.EMPTY_NAME, PName.EMPTY_NAME, PTableType.SUBQUERY, null, MetaDataProtocol.MIN_TABLE_TIMESTAMP, PTable.INITIAL_SEQ_NUM, null, null, columns, null, null, Collections.<PTable> emptyList(), false, Collections.<PName> emptyList(), null, null, false, false, - false, null, null, null, true, false, 0, 0L, false, null, false, StorageScheme.ONE_CELL_PER_KEYVALUE_COLUMN, QualifierEncodingScheme.NON_ENCODED_QUALIFIERS, EncodedCQCounter.NULL_COUNTER); + false, null, null, null, true, false, 0, 0L, false, null, false, ImmutableStorageScheme.ONE_CELL_PER_COLUMN, QualifierEncodingScheme.NON_ENCODED_QUALIFIERS, EncodedCQCounter.NULL_COUNTER); TableRef sourceTable = new TableRef(pTable); List<ColumnRef> sourceColumnRefs = Lists.<ColumnRef> newArrayList(); for (PColumn column : sourceTable.getTable().getColumns()) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java b/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java index 276d946..8553b73 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java @@ -127,11 +127,11 @@ public class MutationStateTest { private void assertTable(String tableName1,List<KeyValue> keyValues1,String tableName2,List<KeyValue> keyValues2) { assertTrue("MUTATION_TEST1".equals(tableName1)); assertTrue(Bytes.equals(PUnsignedInt.INSTANCE.toBytes(111),CellUtil.cloneRow(keyValues1.get(0)))); - assertTrue("app1".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues1.get(0))))); + assertTrue("app1".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues1.get(1))))); assertTrue("MUTATION_TEST2".equals(tableName2)); assertTrue(Bytes.equals(PUnsignedInt.INSTANCE.toBytes(222),CellUtil.cloneRow(keyValues2.get(0)))); - assertTrue("app2".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues2.get(0))))); + assertTrue("app2".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues2.get(1))))); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/phoenix-core/src/test/java/org/apache/phoenix/expression/ArrayConstructorExpressionTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/expression/ArrayConstructorExpressionTest.java b/phoenix-core/src/test/java/org/apache/phoenix/expression/ArrayConstructorExpressionTest.java index a78e87e..ba36445 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/expression/ArrayConstructorExpressionTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/expression/ArrayConstructorExpressionTest.java @@ -18,8 +18,6 @@ package org.apache.phoenix.expression; import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import java.util.List; @@ -28,7 +26,6 @@ import org.apache.phoenix.expression.function.ArrayElemRefExpression; import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.tuple.Tuple; -import org.apache.phoenix.schema.types.PArrayDataType; import org.apache.phoenix.schema.types.PVarbinary; import org.apache.phoenix.util.ByteUtil; import org.junit.Test; @@ -37,10 +34,10 @@ import com.google.common.collect.Lists; public class ArrayConstructorExpressionTest { - private static final LiteralExpression CONSTANT_EXPRESSION = LiteralExpression.newConstant(QueryConstants.EMPTY_COLUMN_VALUE_BYTES); - private static final byte[] BYTE_ARRAY1 = new byte[]{1,2,3,4,5}; - private static final byte[] BYTE_ARRAY2 = new byte[]{6,7,8}; - private Expression FALSE_EVAL_EXPRESSION = new DelegateExpression(LiteralExpression.newConstant(null)) { + protected static final LiteralExpression CONSTANT_EXPRESSION = LiteralExpression.newConstant(QueryConstants.EMPTY_COLUMN_VALUE_BYTES); + protected static final byte[] BYTE_ARRAY1 = new byte[]{1,2,3,4,5}; + protected static final byte[] BYTE_ARRAY2 = new byte[]{6,7,8}; + protected Expression FALSE_EVAL_EXPRESSION = new DelegateExpression(LiteralExpression.newConstant(null)) { @Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { return false; @@ -48,27 +45,17 @@ public class ArrayConstructorExpressionTest { }; @Test - public void testLeadingNullsForSortableSerialization() throws Exception { - helpTestLeadingNulls(PArrayDataType.SORTABLE_SERIALIZATION_VERSION); - } - - @Test - public void testLeadingNullsForImmutableSerialization() throws Exception { - helpTestLeadingNulls(PArrayDataType.IMMUTABLE_SERIALIZATION_VERSION); - } - - public void helpTestLeadingNulls(byte serializationVersion) throws Exception { + public void testLeadingNulls() throws Exception { List<Expression> children = Lists.newArrayListWithExpectedSize(4); LiteralExpression nullExpression = LiteralExpression.newConstant(null); children.add(nullExpression); children.add(nullExpression); children.add(LiteralExpression.newConstant(BYTE_ARRAY1, PVarbinary.INSTANCE)); children.add(LiteralExpression.newConstant(BYTE_ARRAY2, PVarbinary.INSTANCE)); - ArrayConstructorExpression arrayConstructorExpression = new ArrayConstructorExpression(children, PVarbinary.INSTANCE, false, serializationVersion); + ArrayConstructorExpression arrayConstructorExpression = new ArrayConstructorExpression(children, PVarbinary.INSTANCE, false); ImmutableBytesPtr ptr = new ImmutableBytesPtr(); ArrayElemRefExpression arrayElemRefExpression = new ArrayElemRefExpression(Lists.<Expression>newArrayList(arrayConstructorExpression)); - arrayElemRefExpression.setIndex(1); arrayElemRefExpression.evaluate(null, ptr); assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptr.copyBytesIfNecessary()); @@ -83,81 +70,4 @@ public class ArrayConstructorExpressionTest { assertArrayEquals(BYTE_ARRAY2, ptr.copyBytesIfNecessary()); } - @Test - public void testWithExpressionsThatEvaluatetoFalse() throws Exception { - List<Expression> children = Lists.newArrayListWithExpectedSize(4); - children.add(CONSTANT_EXPRESSION); - children.add(FALSE_EVAL_EXPRESSION); - children.add(LiteralExpression.newConstant(BYTE_ARRAY1, PVarbinary.INSTANCE)); - children.add(FALSE_EVAL_EXPRESSION); - children.add(LiteralExpression.newConstant(BYTE_ARRAY2, PVarbinary.INSTANCE)); - ArrayConstructorExpression arrayConstructorExpression = new ArrayConstructorExpression(children, PVarbinary.INSTANCE, false, PArrayDataType.IMMUTABLE_SERIALIZATION_VERSION); - ImmutableBytesPtr ptr = new ImmutableBytesPtr(); - - ArrayElemRefExpression arrayElemRefExpression = new ArrayElemRefExpression(Lists.<Expression>newArrayList(arrayConstructorExpression)); - arrayElemRefExpression.setIndex(1); - assertTrue(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptr.copyBytesIfNecessary()); - arrayElemRefExpression.setIndex(2); - assertFalse(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptr.copyBytesIfNecessary()); - arrayElemRefExpression.setIndex(3); - assertTrue(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(BYTE_ARRAY1, ptr.copyBytesIfNecessary()); - arrayElemRefExpression.setIndex(4); - assertFalse(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptr.copyBytesIfNecessary()); - arrayElemRefExpression.setIndex(5); - assertTrue(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(BYTE_ARRAY2, ptr.copyBytesIfNecessary()); - } - - @Test - public void testWithMaxOffsetLargerThanShortMax() throws Exception { - int numElements = Short.MAX_VALUE+2; - List<Expression> children = Lists.newArrayListWithExpectedSize(numElements); - for (int i=0; i<numElements; ++i) { - children.add(CONSTANT_EXPRESSION); - } - ArrayConstructorExpression arrayConstructorExpression = new ArrayConstructorExpression(children, PVarbinary.INSTANCE, false, PArrayDataType.IMMUTABLE_SERIALIZATION_VERSION); - ArrayElemRefExpression arrayElemRefExpression = new ArrayElemRefExpression(Lists.<Expression>newArrayList(arrayConstructorExpression)); - ImmutableBytesPtr ptr = new ImmutableBytesPtr(); - - arrayElemRefExpression.setIndex(1); - assertTrue(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptr.copyBytesIfNecessary()); - - arrayElemRefExpression.setIndex(15000); - assertTrue(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptr.copyBytesIfNecessary()); - - arrayElemRefExpression.setIndex(numElements); - assertTrue(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptr.copyBytesIfNecessary()); - } - - @Test - public void testWithMaxOffsetSmallerThanShortMin() throws Exception { - int numElements = Short.MAX_VALUE+2; - List<Expression> children = Lists.newArrayListWithExpectedSize(numElements); - for (int i=1; i<numElements; i+=2) { - children.add(CONSTANT_EXPRESSION); - children.add(FALSE_EVAL_EXPRESSION); - } - ArrayConstructorExpression arrayConstructorExpression = new ArrayConstructorExpression(children, PVarbinary.INSTANCE, false, PArrayDataType.IMMUTABLE_SERIALIZATION_VERSION); - ArrayElemRefExpression arrayElemRefExpression = new ArrayElemRefExpression(Lists.<Expression>newArrayList(arrayConstructorExpression)); - ImmutableBytesPtr ptr = new ImmutableBytesPtr(); - - arrayElemRefExpression.setIndex(2); - assertFalse(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptr.copyBytesIfNecessary()); - - arrayElemRefExpression.setIndex(15000); - assertFalse(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptr.copyBytesIfNecessary()); - - arrayElemRefExpression.setIndex(numElements); - assertFalse(arrayElemRefExpression.evaluate(null, ptr)); - assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptr.copyBytesIfNecessary()); - } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/phoenix-core/src/test/java/org/apache/phoenix/schema/ImmutableStorageSchemeTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/ImmutableStorageSchemeTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/ImmutableStorageSchemeTest.java new file mode 100644 index 0000000..d8c5cdb --- /dev/null +++ b/phoenix-core/src/test/java/org/apache/phoenix/schema/ImmutableStorageSchemeTest.java @@ -0,0 +1,182 @@ +/* + * 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.schema; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.phoenix.expression.DelegateExpression; +import org.apache.phoenix.expression.Expression; +import org.apache.phoenix.expression.LiteralExpression; +import org.apache.phoenix.expression.SingleCellConstructorExpression; +import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; +import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.schema.PTable.ImmutableStorageScheme; +import org.apache.phoenix.schema.tuple.Tuple; +import org.apache.phoenix.schema.types.PVarbinary; +import org.apache.phoenix.util.ByteUtil; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +import com.google.common.collect.Lists; + +@RunWith(Parameterized.class) +public class ImmutableStorageSchemeTest { + + protected static final LiteralExpression CONSTANT_EXPRESSION = LiteralExpression.newConstant(QueryConstants.EMPTY_COLUMN_VALUE_BYTES); + protected static final byte[] BYTE_ARRAY1 = new byte[]{1,2,3,4,5}; + protected static final byte[] BYTE_ARRAY2 = new byte[]{6,7,8}; + protected Expression FALSE_EVAL_EXPRESSION = new DelegateExpression(LiteralExpression.newConstant(null)) { + @Override + public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { + return false; + } + }; + private ImmutableStorageScheme immutableStorageScheme; + + @Parameters(name="ImmutableStorageSchemeTest_immutableStorageScheme={0}}") // name is used by failsafe as file name in reports + public static ImmutableStorageScheme[] data() { + ImmutableStorageScheme[] values = ImmutableStorageScheme.values(); + // skip ONE_CELL_PER_COLUMN + return Arrays.copyOfRange(values, 1, values.length); + } + + public ImmutableStorageSchemeTest(ImmutableStorageScheme immutableStorageScheme) { + this.immutableStorageScheme = immutableStorageScheme; + } + + @Test + public void testWithExpressionsThatEvaluatetoFalse() throws Exception { + List<Expression> children = Lists.newArrayListWithExpectedSize(4); + children.add(CONSTANT_EXPRESSION); + children.add(FALSE_EVAL_EXPRESSION); + children.add(LiteralExpression.newConstant(BYTE_ARRAY1, PVarbinary.INSTANCE)); + children.add(FALSE_EVAL_EXPRESSION); + children.add(LiteralExpression.newConstant(BYTE_ARRAY2, PVarbinary.INSTANCE)); + SingleCellConstructorExpression singleCellConstructorExpression = new SingleCellConstructorExpression(immutableStorageScheme, children); + ImmutableBytesPtr ptr = new ImmutableBytesPtr(); + singleCellConstructorExpression.evaluate(null, ptr); + + ImmutableBytesPtr ptrCopy = new ImmutableBytesPtr(ptr); + ColumnValueDecoder decoder = immutableStorageScheme.getDecoder(); + assertTrue(decoder.decode(ptrCopy, 0)); + assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptrCopy.copyBytesIfNecessary()); + ptrCopy = new ImmutableBytesPtr(ptr); + assertFalse(decoder.decode(ptrCopy, 1)); + assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptrCopy.copyBytesIfNecessary()); + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, 2)); + assertArrayEquals(BYTE_ARRAY1, ptrCopy.copyBytesIfNecessary()); + ptrCopy = new ImmutableBytesPtr(ptr); + assertFalse(decoder.decode(ptrCopy, 3)); + assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptrCopy.copyBytesIfNecessary()); + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, 4)); + assertArrayEquals(BYTE_ARRAY2, ptrCopy.copyBytesIfNecessary()); + } + + @Test + public void testWithMaxOffsetLargerThanShortMax() throws Exception { + int numElements = Short.MAX_VALUE+2; + List<Expression> children = Lists.newArrayListWithExpectedSize(numElements); + for (int i=0; i<numElements; ++i) { + children.add(CONSTANT_EXPRESSION); + } + SingleCellConstructorExpression singleCellConstructorExpression = new SingleCellConstructorExpression(immutableStorageScheme, children); + ImmutableBytesPtr ptr = new ImmutableBytesPtr(); + singleCellConstructorExpression.evaluate(null, ptr); + + ImmutableBytesPtr ptrCopy = new ImmutableBytesPtr(ptr); + ColumnValueDecoder decoder = immutableStorageScheme.getDecoder(); + assertTrue(decoder.decode(ptrCopy, 0)); + assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptrCopy.copyBytesIfNecessary()); + + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, 14999)); + assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptrCopy.copyBytesIfNecessary()); + + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, numElements-1)); + assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptrCopy.copyBytesIfNecessary()); + } + + @Test + public void testWithMaxOffsetSmallerThanShortMin() throws Exception { + int numElements = Short.MAX_VALUE+2; + List<Expression> children = Lists.newArrayListWithExpectedSize(numElements); + for (int i=0; i<=numElements; i+=2) { + children.add(CONSTANT_EXPRESSION); + children.add(FALSE_EVAL_EXPRESSION); + } + SingleCellConstructorExpression singleCellConstructorExpression = new SingleCellConstructorExpression(immutableStorageScheme, children); + ImmutableBytesPtr ptr = new ImmutableBytesPtr(); + singleCellConstructorExpression.evaluate(null, ptr); + + ImmutableBytesPtr ptrCopy = new ImmutableBytesPtr(ptr); + ColumnValueDecoder decoder = immutableStorageScheme.getDecoder(); + assertTrue(decoder.decode(ptrCopy, 0)); + assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptrCopy.copyBytesIfNecessary()); + + ptrCopy = new ImmutableBytesPtr(ptr); + assertFalse(decoder.decode(ptrCopy, 1)); + assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptrCopy.copyBytesIfNecessary()); + + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, numElements-1)); + assertArrayEquals(QueryConstants.EMPTY_COLUMN_VALUE_BYTES, ptrCopy.copyBytesIfNecessary()); + + ptrCopy = new ImmutableBytesPtr(ptr); + assertFalse(decoder.decode(ptrCopy, numElements)); + assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptrCopy.copyBytesIfNecessary()); + } + + @Test + public void testLeadingNulls() throws Exception { + List<Expression> children = Lists.newArrayListWithExpectedSize(4); + LiteralExpression nullExpression = LiteralExpression.newConstant(null); + children.add(nullExpression); + children.add(nullExpression); + children.add(LiteralExpression.newConstant(BYTE_ARRAY1, PVarbinary.INSTANCE)); + children.add(LiteralExpression.newConstant(BYTE_ARRAY2, PVarbinary.INSTANCE)); + SingleCellConstructorExpression singleCellConstructorExpression = new SingleCellConstructorExpression(immutableStorageScheme, children); + ImmutableBytesPtr ptr = new ImmutableBytesPtr(); + singleCellConstructorExpression.evaluate(null, ptr); + + ImmutableBytesPtr ptrCopy = new ImmutableBytesPtr(ptr); + ColumnValueDecoder decoder = immutableStorageScheme.getDecoder(); + assertTrue(decoder.decode(ptrCopy, 0)); + assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptrCopy.copyBytesIfNecessary()); + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, 1)); + assertArrayEquals(ByteUtil.EMPTY_BYTE_ARRAY, ptrCopy.copyBytesIfNecessary()); + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, 2)); + assertArrayEquals(BYTE_ARRAY1, ptrCopy.copyBytesIfNecessary()); + ptrCopy = new ImmutableBytesPtr(ptr); + assertTrue(decoder.decode(ptrCopy, 3)); + assertArrayEquals(BYTE_ARRAY2, ptrCopy.copyBytesIfNecessary()); + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f3f7323/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeForArraysTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeForArraysTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeForArraysTest.java index 333fbf9..2aeeeb8 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeForArraysTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeForArraysTest.java @@ -324,7 +324,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -342,7 +342,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -365,7 +365,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -402,7 +402,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -423,7 +423,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -444,7 +444,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -464,7 +464,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -485,7 +485,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -506,7 +506,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -528,7 +528,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -548,7 +548,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -569,7 +569,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -590,7 +590,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -611,7 +611,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -632,7 +632,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -649,7 +649,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -667,7 +667,7 @@ public class PDataTypeForArraysTest { PVarchar.INSTANCE, strArr); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 1, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 1, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -688,7 +688,7 @@ public class PDataTypeForArraysTest { PLongArray.INSTANCE.toObject(arr, PLongArray.INSTANCE); byte[] bytes = PLongArray.INSTANCE.toBytes(arr); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 2, PLong.INSTANCE, PLong.INSTANCE.getByteSize()); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 2, PLong.INSTANCE, PLong.INSTANCE.getByteSize()); int offset = ptr.getOffset(); int length = ptr.getLength(); byte[] bs = ptr.get(); @@ -1196,7 +1196,7 @@ public class PDataTypeForArraysTest { PhoenixArray arr = new PhoenixArray(PVarchar.INSTANCE, objects); byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr, PVarchar.INSTANCE, SortOrder.DESC); ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes); - PArrayDataType.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, null); + PArrayDataTypeDecoder.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, null); String value = (String)PVarchar.INSTANCE.toObject(ptr, SortOrder.DESC); assertEquals(null, value); }
