phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject [41/50] [abbrv] phoenix git commit: PHOENIX-1686 Data length should be checked in KeyValueSchema.next() and maxOffset should be set correctly by the caller
Date Wed, 04 Mar 2015 22:41:16 GMT
PHOENIX-1686 Data length should be checked in KeyValueSchema.next() and maxOffset should be
set correctly by the caller


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

Branch: refs/heads/calcite
Commit: 93f560575319b7f26f5fc5db618bc2d8a09be930
Parents: 569469a
Author: maryannxue <wei.xue@intel.com>
Authored: Fri Feb 27 16:43:13 2015 -0500
Committer: maryannxue <wei.xue@intel.com>
Committed: Fri Feb 27 16:43:13 2015 -0500

----------------------------------------------------------------------
 .../phoenix/expression/ProjectedColumnExpression.java |  2 +-
 .../org/apache/phoenix/schema/KeyValueSchema.java     | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/93f56057/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
index d090203..97d1aff 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
@@ -106,9 +106,9 @@ public class ProjectedColumnExpression extends ColumnExpression {
         try {
             KeyValueSchema schema = getSchema();
             TupleProjector.decodeProjectedValue(tuple, ptr);
-            int maxOffset = ptr.getOffset() + ptr.getLength();
             bitSet.clear();
             bitSet.or(ptr);
+            int maxOffset = ptr.getOffset() + ptr.getLength() - bitSet.getEstimatedLength();
             schema.iterator(ptr, position, bitSet);
             Boolean hasValue = schema.next(ptr, position, maxOffset, bitSet);
             if (hasValue == null || !hasValue.booleanValue())

http://git-wip-us.apache.org/repos/asf/phoenix/blob/93f56057/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
index 595103f..1ab8c86 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
@@ -22,6 +22,8 @@ import java.util.List;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.io.WritableUtils;
 import org.apache.http.annotation.Immutable;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.schema.tuple.Tuple;
 import org.apache.phoenix.schema.types.PDataType;
@@ -203,12 +205,14 @@ public class KeyValueSchema extends ValueSchema {
         ptr.set(ptr.get(), ptr.getOffset() + ptr.getLength(), 0);
         if (!isNull(position, valueSet)) {
             Field field = this.getField(position);
-            if (field.getDataType().isFixedWidth()) {
-                ptr.set(ptr.get(),ptr.getOffset(), field.getByteSize());
-            } else {
-                int length = ByteUtil.vintFromBytes(ptr);
-                ptr.set(ptr.get(),ptr.getOffset(),length);
+            int length = field.getDataType().isFixedWidth() ? 
+                    field.getByteSize() : ByteUtil.vintFromBytes(ptr);
+            if (ptr.getOffset() + length > maxOffset) {
+                throw new RuntimeException(new SQLExceptionInfo.Builder(SQLExceptionCode.ILLEGAL_DATA)
+                    .setMessage("Expected length of at least " + length + " bytes, but had
" + (maxOffset
+                                    - ptr.getOffset())).build().buildException());
             }
+            ptr.set(ptr.get(),ptr.getOffset(),length);
             return ptr.getLength() > 0;
         }
         return false;


Mime
View raw message