DRILL-2875: Show record number relative to beginning of file in JsonRecordReader
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/16ef6285 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/16ef6285 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/16ef6285 Branch: refs/heads/master Commit: 16ef62851403cf5eb9984671b332d93912c61f0c Parents: 80e3f74 Author: Steven Phillips <[email protected]> Authored: Wed May 13 20:37:00 2015 -0700 Committer: Steven Phillips <[email protected]> Committed: Thu May 14 17:16:10 2015 -0700 ---------------------------------------------------------------------- .../drill/exec/store/easy/json/JSONRecordReader.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/16ef6285/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader.java index 3d789eb..0df6227 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader.java @@ -55,6 +55,7 @@ public class JSONRecordReader extends AbstractRecordReader { private final DrillFileSystem fileSystem; private JsonProcessor jsonReader; private int recordCount; + private long runningRecordCount = 0; private final FragmentContext fragmentContext; private OperatorContext operatorContext; private final boolean enableAllTextMode; @@ -154,12 +155,16 @@ public class JSONRecordReader extends AbstractRecordReader { if (columnNr > 0) { exceptionBuilder.pushContext("Column ", columnNr); } - exceptionBuilder.pushContext("Record ", recordCount + 1) + exceptionBuilder.pushContext("Record ", currentRecordNumberInFile()) .pushContext("File ", hadoopPath.toUri().getPath()); throw exceptionBuilder.build(); } + private long currentRecordNumberInFile() { + return runningRecordCount + recordCount + 1; + } + @Override public int next() { writer.allocate(); @@ -189,6 +194,7 @@ public class JSONRecordReader extends AbstractRecordReader { // p.stop(); // System.out.println(String.format("Wrote %d records in %dms.", recordCount, p.elapsed(TimeUnit.MILLISECONDS))); + updateRunningCount(); return recordCount; @@ -199,6 +205,10 @@ public class JSONRecordReader extends AbstractRecordReader { return 0; } + private void updateRunningCount() { + runningRecordCount += recordCount; + } + @Override public void cleanup() { try {
