dongjoon-hyun commented on a change in pull request #660:
URL: https://github.com/apache/orc/pull/660#discussion_r606706120



##########
File path: java/tools/src/java/org/apache/orc/tools/PrintData.java
##########
@@ -195,42 +200,82 @@ static void printRow(JSONWriter writer,
   }
 
   static void printJsonData(PrintStream printStream,
-                            Reader reader) throws IOException, JSONException {
-    OutputStreamWriter out = new OutputStreamWriter(printStream, "UTF-8");
+          Reader reader, Optional<Integer> numberOfRows) throws IOException, 
JSONException {
+    OutputStreamWriter out = new OutputStreamWriter(printStream, 
StandardCharsets.UTF_8);
     RecordReader rows = reader.rows();
     try {
       TypeDescription schema = reader.getSchema();
       VectorizedRowBatch batch = schema.createRowBatch();
+      Integer counter = 0;
       while (rows.nextBatch(batch)) {
-        for(int r=0; r < batch.size; ++r) {
+        for (int r=0; r < batch.size; ++r) {
           JSONWriter writer = new JSONWriter(out);
           printRow(writer, batch, schema, r);

Review comment:
       Hi, @yuokada . Sorry, but I missed that this doesn't work correct in 
some files. Could you check this once more?
   
   **WORKING**
   ```
   $ java -jar tools/target/orc-tools-1.7.0-SNAPSHOT-uber.jar data -n 1 
../examples/orc_no_format.orc 
   log4j:WARN No appenders could be found for logger 
(org.apache.hadoop.util.Shell).
   log4j:WARN Please initialize the log4j system properly.
   log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for 
more info.
   Processing data file ../examples/orc_no_format.orc [length: 745]
   
{"_col0":["Java\/C++\/Linux,4306:Bob\/4307:Jack,Bob\/90"],"_col1":null,"_col2":null}
   
________________________________________________________________________________________________________________________
   ```
   **NOT WORKING***
   ```
   $ java -jar tools/target/orc-tools-1.7.0-SNAPSHOT-uber.jar data -n 1 
../examples/orc-file-11-format.orc 
   log4j:WARN No appenders could be found for logger 
(org.apache.hadoop.util.Shell).
   log4j:WARN Please initialize the log4j system properly.
   log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for 
more info.
   Processing data file ../examples/orc-file-11-format.orc [length: 373336]
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
{"boolean1":false,"byte1":1,"short1":1024,"int1":65536,"long1":9223372036854775807,"float1":1,"double1":-15,"bytes1":[0,1,2,3,4],"string1":"hi","middle":{"list":[{"int1":1,"string1":"bye"},{"int1":2,"string1":"sigh"}]},"list":[{"int1":3,"string1":"good"},{"int1":4,"string1":"bad"}],"map":[],"ts":"2000-03-12
 15:00:00.0","decimal1":"12345678.6547456"}
   
________________________________________________________________________________________________________________________
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to