You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by ji...@apache.org on 2014/07/23 02:48:20 UTC
[4/7] git commit: TAJO-666: java.nio.BufferOverflowException occurs
when the query includes an order by clause on a TEXT column. (Mai Hai Thanh
via jihoon)
TAJO-666: java.nio.BufferOverflowException occurs when the query includes an order by clause on a TEXT column. (Mai Hai Thanh via jihoon)
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/2a6b38e8
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/2a6b38e8
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/2a6b38e8
Branch: refs/heads/index_support
Commit: 2a6b38e8460a048ce09d18aefb8786627473fbf7
Parents: 862435b
Author: Jihoon Son <ji...@apache.org>
Authored: Tue Jul 22 14:25:03 2014 +0900
Committer: Jihoon Son <ji...@apache.org>
Committed: Tue Jul 22 14:25:03 2014 +0900
----------------------------------------------------------------------
CHANGES | 3 ++
.../org/apache/tajo/storage/RowStoreUtil.java | 40 +++++++++++++++++++-
2 files changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/2a6b38e8/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8208fd7..8a1aae6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -97,6 +97,9 @@ Release 0.9.0 - unreleased
BUG FIXES
+ TAJO-666: java.nio.BufferOverflowException occurs when the query includes an order by
+ clause on a TEXT column. (Mai Hai Thanh via jihoon)
+
TAJO-939: Refactoring the column resolver in LogicalPlan. (hyunsik)
TAJO-965: Upgrade Bytes class and move some methods to others. (hyunsik)
http://git-wip-us.apache.org/repos/asf/tajo/blob/2a6b38e8/tajo-storage/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
----------------------------------------------------------------------
diff --git a/tajo-storage/src/main/java/org/apache/tajo/storage/RowStoreUtil.java b/tajo-storage/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
index 5140a63..dc453a9 100644
--- a/tajo-storage/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
+++ b/tajo-storage/src/main/java/org/apache/tajo/storage/RowStoreUtil.java
@@ -174,7 +174,7 @@ public class RowStoreUtil {
}
public byte [] toBytes(Tuple tuple) {
nullFlags.clear();
- int size = 4096; // 4kb
+ int size = estimateTupleDataSize(tuple);
ByteBuffer bb = ByteBuffer.allocate(size + headerSize);
bb.position(headerSize);
Column col;
@@ -236,6 +236,44 @@ public class RowStoreUtil {
return buf;
}
+ // Note that, NULL values are treated separately
+ private int estimateTupleDataSize(Tuple tuple) {
+ int size = 0;
+ Column col;
+
+ for (int i = 0; i < schema.size(); i++) {
+ if (tuple.isNull(i)) {
+ continue;
+ }
+
+ col = schema.getColumn(i);
+ switch (col.getDataType().getType()) {
+ case BOOLEAN:
+ case BIT:
+ case CHAR: size += 1; break;
+ case INT2: size += 2; break;
+ case DATE:
+ case INT4:
+ case FLOAT4: size += 4; break;
+ case TIME:
+ case TIMESTAMP:
+ case INT8:
+ case FLOAT8: size += 8; break;
+ case INTERVAL: size += 12; break;
+ case TEXT:
+ case BLOB: size += (4 + tuple.get(i).asByteArray().length); break;
+ case INET4:
+ case INET6: size += tuple.get(i).asByteArray().length; break;
+ default:
+ size += 4;
+ }
+ }
+
+ size += 100; // optimistic reservation
+
+ return size;
+ }
+
public Schema getSchema() {
return schema;
}