You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pa...@apache.org on 2014/12/12 17:24:12 UTC
[06/10] drill git commit: DRILL-1843: Support per-batch schema change
at RecordBatchLoader
DRILL-1843: Support per-batch schema change at RecordBatchLoader
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/c587dff7
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/c587dff7
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/c587dff7
Branch: refs/heads/0.7.0
Commit: c587dff76ea93ae0db37185fa976f11fa08c1ad7
Parents: 9f74331
Author: Hanifi Gunes <hg...@maprtech.com>
Authored: Thu Dec 11 11:23:12 2014 -0800
Committer: Parth Chandra <pc...@maprtech.com>
Committed: Thu Dec 11 13:29:42 2014 -0800
----------------------------------------------------------------------
.../drill/exec/record/RecordBatchLoader.java | 22 ++++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/c587dff7/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchLoader.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchLoader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchLoader.java
index 97756e2..088630c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchLoader.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatchLoader.java
@@ -78,21 +78,25 @@ public class RecordBatchLoader implements VectorAccessible, Iterable<VectorWrapp
int bufOffset = 0;
for (SerializedField fmd : fields) {
MaterializedField fieldDef = MaterializedField.create(fmd);
- ValueVector v = oldFields.remove(fieldDef);
- if(v == null) {
- // if we arrive here, we didn't have a matching vector.
+ ValueVector vector = oldFields.remove(fieldDef);
+
+ if (vector == null) {
+ schemaChanged = true;
+ vector = TypeHelper.getNewVector(fieldDef, allocator);
+ } else if (!vector.getField().getType().equals(fieldDef.getType())) {
+ // clear previous vector
+ vector.clear();
schemaChanged = true;
- v = TypeHelper.getNewVector(fieldDef, allocator);
+ vector = TypeHelper.getNewVector(fieldDef, allocator);
}
+
if (fmd.getValueCount() == 0 && (!fmd.hasGroupCount() || fmd.getGroupCount() == 0)) {
-// v.clear();
-// v.load(fmd, allocator.buffer(8));
- AllocationHelper.allocate(v, 0, 0, 0);
+ AllocationHelper.allocate(vector, 0, 0, 0);
} else {
- v.load(fmd, buf.slice(bufOffset, fmd.getBufferLength()));
+ vector.load(fmd, buf.slice(bufOffset, fmd.getBufferLength()));
}
bufOffset += fmd.getBufferLength();
- newVectors.add(v);
+ newVectors.add(vector);
}
Preconditions.checkArgument(buf == null || bufOffset == buf.capacity());