DRILL-903: Cleanup exising ValueVectors before allocating new ones in StringOutputRecordWriter.updateSchema.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/21a32838 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/21a32838 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/21a32838 Branch: refs/heads/master Commit: 21a32838af08480ac470745f2e73e9d1041f4b74 Parents: 6c8ce4f Author: vkorukanti <[email protected]> Authored: Thu Jun 5 09:05:10 2014 -0700 Committer: Jacques Nadeau <[email protected]> Committed: Thu Jun 5 09:34:54 2014 -0700 ---------------------------------------------------------------------- .../codegen/templates/StringOutputRecordWriter.java | 12 ++++++++++-- .../drill/exec/physical/impl/writer/TestWriter.java | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/21a32838/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java b/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java index 7357246..9f0d701 100644 --- a/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java +++ b/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java @@ -52,6 +52,7 @@ public abstract class StringOutputRecordWriter implements RecordWriter { } public void updateSchema(BatchSchema schema) throws IOException { + cleanupColumnVectors(); columnVectors = new ValueVector[schema.getFieldCount()]; List<String> columnNames = Lists.newArrayList(); @@ -129,9 +130,16 @@ public abstract class StringOutputRecordWriter implements RecordWriter { </#list> public void cleanup() throws IOException { + cleanupColumnVectors(); + } + + private void cleanupColumnVectors() { if (columnVectors != null){ - for(ValueVector vector : columnVectors) - if (vector != null) vector.clear(); + for(ValueVector vector : columnVectors){ + if(vector!=null){ + vector.clear(); + } + } } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/21a32838/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java index 2a6eb39..65843a6 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java @@ -53,7 +53,6 @@ public class TestWriter extends BaseTestQuery { fs = FileSystem.get(conf); } - @Ignore("DRILL-903") @Test public void simpleCsv() throws Exception { // before executing the test deleting the existing CSV files in /tmp/csvtest
