Repository: tajo Updated Branches: refs/heads/branch-0.11.0 dd7adfcc6 -> 5db0f7b0f
TAJO-1829: Fix DelimitedTextFileAppender NPE in negative tests. Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/5db0f7b0 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/5db0f7b0 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/5db0f7b0 Branch: refs/heads/branch-0.11.0 Commit: 5db0f7b0f1e65c0620472b27f0c91cf446334a0f Parents: dd7adfc Author: Jinho Kim <[email protected]> Authored: Wed Sep 9 12:49:27 2015 +0900 Committer: Jinho Kim <[email protected]> Committed: Wed Sep 9 12:49:27 2015 +0900 ---------------------------------------------------------------------- CHANGES | 2 + .../tajo/storage/text/DelimitedTextFile.java | 43 +++++++++++--------- 2 files changed, 26 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/5db0f7b0/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index d8c3fd2..b44f184 100644 --- a/CHANGES +++ b/CHANGES @@ -255,6 +255,8 @@ Release 0.11.0 - unreleased BUG FIXES + TAJO-1829: Fix DelimitedTextFileAppender NPE in negative tests. (jinho) + TAJO-1674: Validation of CTAS schema mismatch. (hyunsik) TAJO-1819: Cannot find existing tables when pgsql catalog starts up. http://git-wip-us.apache.org/repos/asf/tajo/blob/5db0f7b0/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java ---------------------------------------------------------------------- diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java index 650aa60..bc1d7ba 100644 --- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java +++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/DelimitedTextFile.java @@ -137,6 +137,22 @@ public class DelimitedTextFile { throw new FileNotFoundException(path.toString()); } + if (enabledStats) { + this.stats = new TableStatistics(this.schema); + } + + if(serializer != null) { + serializer.release(); + } + serializer = getLineSerde().createSerializer(schema, meta); + serializer.init(); + + bufferSize = conf.getInt(WRITE_BUFFER_SIZE, DEFAULT_BUFFER_SIZE); + if (os == null) { + os = new NonSyncByteArrayOutputStream(bufferSize); + } + os.reset(); + if (this.meta.containsOption(StorageConstants.COMPRESSION_CODEC)) { String codecName = this.meta.getOption(StorageConstants.COMPRESSION_CODEC); codecFactory = new CompressionCodecFactory(conf); @@ -163,19 +179,6 @@ public class DelimitedTextFile { outputStream = new DataOutputStream(new BufferedOutputStream(fos)); } - if (enabledStats) { - this.stats = new TableStatistics(this.schema); - } - - serializer = getLineSerde().createSerializer(schema, meta); - serializer.init(); - - bufferSize = conf.getInt(WRITE_BUFFER_SIZE, DEFAULT_BUFFER_SIZE); - if (os == null) { - os = new NonSyncByteArrayOutputStream(bufferSize); - } - - os.reset(); pos = fos.getPos(); bufferedBytes = 0; super.init(); @@ -219,20 +222,22 @@ public class DelimitedTextFile { @Override public void flush() throws IOException { - flushBuffer(); - outputStream.flush(); + if(inited) { + flushBuffer(); + outputStream.flush(); + } } @Override public void close() throws IOException { try { - serializer.release(); - - if(outputStream != null){ - flush(); + if(serializer != null) { + serializer.release(); } + flush(); + // Statistical section if (enabledStats) { stats.setNumBytes(getOffset());
