You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2014/05/15 22:05:35 UTC
[03/14] git commit: DRILL-749: Zero-fill the Offset Vectors buffer
contents
DRILL-749: Zero-fill the Offset Vectors buffer contents
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/98edd626
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/98edd626
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/98edd626
Branch: refs/heads/master
Commit: 98edd62697b52906562599a468c41a77615f1ce5
Parents: 616cc5e
Author: Aditya Kishore <ad...@maprtech.com>
Authored: Wed May 14 17:43:10 2014 -0700
Committer: Aditya Kishore <ad...@maprtech.com>
Committed: Wed May 14 19:17:33 2014 -0700
----------------------------------------------------------------------
.../main/codegen/templates/FixedValueVectors.java | 15 +++++++++++----
.../codegen/templates/NullableValueVectors.java | 9 ++++++++-
.../codegen/templates/RepeatedValueVectors.java | 5 ++++-
.../codegen/templates/VariableLengthVectors.java | 4 ++--
.../org/apache/drill/exec/vector/BitVector.java | 16 ++++++++++------
.../apache/drill/exec/vector/FixedWidthVector.java | 5 +++++
6 files changed, 40 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/98edd626/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java b/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
index 7193c29..ca96e32 100644
--- a/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
+++ b/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
@@ -94,16 +94,23 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements F
return true;
}
- /**
- * Allocate a new buffer that supports setting at least the provided number of values. May actually be sized bigger depending on underlying buffer rounding size. Must be called prior to using the ValueVector.
- * @param valueCount
+ /**
+ * Allocate a new buffer that supports setting at least the provided number of values. May actually be sized bigger depending on underlying buffer rounding size. Must be called prior to using the ValueVector.
+ * @param valueCount
*/
public void allocateNew(int valueCount) {
clear();
this.data = allocator.buffer(valueCount * ${type.width});
this.data.readerIndex(0);
}
-
+
+ /**
+ * {@inheritDoc}
+ */
+ public void zeroVector() {
+ data.setZero(0, data.capacity());
+ }
+
@Override
public SerializedField getMetadata() {
return getMetadataBuilder()
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/98edd626/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java b/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
index 08eea6e..6086c60 100644
--- a/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
+++ b/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
@@ -176,7 +176,14 @@ public final class ${className} extends BaseValueVector implements <#if type.maj
mutator.reset();
accessor.reset();
}
-
+
+ /**
+ * {@inheritDoc}
+ */
+ public void zeroVector() {
+ this.values.zeroVector();
+ }
+
@Override
public int load(int valueCount, ByteBuf buf){
clear();
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/98edd626/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java b/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java
index cac87c5..6570113 100644
--- a/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java
+++ b/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java
@@ -164,6 +164,7 @@ package org.apache.drill.exec.vector;
public boolean allocateNewSafe(){
if(!offsets.allocateNewSafe()) return false;
+ offsets.zeroVector();
if(!values.allocateNewSafe()) return false;
mutator.reset();
accessor.reset();
@@ -173,6 +174,7 @@ package org.apache.drill.exec.vector;
public void allocateNew() {
offsets.allocateNew();
+ offsets.zeroVector();
values.allocateNew();
mutator.reset();
accessor.reset();
@@ -192,7 +194,7 @@ package org.apache.drill.exec.vector;
public void allocateNew(int totalBytes, int parentValueCount, int childValueCount) {
offsets.allocateNew(parentValueCount+1);
- offsets.getMutator().set(0,0);
+ offsets.zeroVector();
values.allocateNew(totalBytes, childValueCount);
mutator.reset();
accessor.reset();
@@ -235,6 +237,7 @@ package org.apache.drill.exec.vector;
public void allocateNew(int parentValueCount, int childValueCount) {
clear();
offsets.allocateNew(parentValueCount+1);
+ offsets.zeroVector();
values.allocateNew(childValueCount);
mutator.reset();
accessor.reset();
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/98edd626/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java b/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java
index c2effbd..990ae1d 100644
--- a/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java
+++ b/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java
@@ -238,7 +238,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements V
if(!offsetVector.allocateNewSafe()){
return false;
}
- offsetVector.getMutator().set(0,0);
+ offsetVector.zeroVector();
return true;
}
@@ -248,7 +248,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements V
data = allocator.buffer(totalBytes);
data.readerIndex(0);
offsetVector.allocateNew(valueCount+1);
- offsetVector.getMutator().set(0,0);
+ offsetVector.zeroVector();
}
public Accessor getAccessor(){
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/98edd626/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java
index 597b0f1..323eae7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java
@@ -84,9 +84,7 @@ public final class BitVector extends BaseDataValueVector implements FixedWidthVe
int valueSize = getSizeFromCount(allocationValueCount);
data = allocator.buffer(valueSize);
if(data == null) return false;
- for (int i = 0; i < valueSize; i++) {
- data.setByte(i, 0);
- }
+ zeroVector();
return true;
}
@@ -101,9 +99,15 @@ public final class BitVector extends BaseDataValueVector implements FixedWidthVe
valueCapacity = valueCount;
int valueSize = getSizeFromCount(valueCount);
data = allocator.buffer(valueSize);
- for (int i = 0; i < valueSize; i++) {
- data.setByte(i, 0);
- }
+ zeroVector();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void zeroVector() {
+ data.setZero(0, data.capacity());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/98edd626/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java
index d085a0b..c5e1ae7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java
@@ -38,4 +38,9 @@ public interface FixedWidthVector extends ValueVector{
public abstract Mutator getMutator();
+
+ /**
+ * Zero out the underlying buffer backing this vector.
+ */
+ public void zeroVector();
}