You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/03/21 12:22:12 UTC

[GitHub] [orc] yuokada opened a new pull request #660: ORC-728: Support head command in Java Tools

yuokada opened a new pull request #660:
URL: https://github.com/apache/orc/pull/660


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. File a JIRA issue first and use it as a prefix of your PR title, e.g., `ORC-001: Fix ABC`.
     2. Use your PR title to summarize what this PR proposes instead of describing the problem.
     3. Make PR title and description complete because these will be the permanent commit log.
     4. If possible, provide a concise and reproducible example to reproduce the issue for a faster review.
     5. If the PR is unfinished, use GitHub PR Draft feature.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   


-- 
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:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on a change in pull request #660: ORC-728: Support head command in Java Tools

Posted by GitBox <gi...@apache.org>.
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 correctly 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:
users@infra.apache.org



[GitHub] [orc] yuokada commented on a change in pull request #660: ORC-728: Support head command in Java Tools

Posted by GitBox <gi...@apache.org>.
yuokada commented on a change in pull request #660:
URL: https://github.com/apache/orc/pull/660#discussion_r663448397



##########
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:
       @dongjoon-hyun Sorry for late response. I sent a new pull request for this issue.
   https://github.com/apache/orc/pull/737




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun merged pull request #660: ORC-728: Support head command in Java Tools

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun merged pull request #660:
URL: https://github.com/apache/orc/pull/660


   


-- 
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:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on a change in pull request #660: ORC-728: Support head command in Java Tools

Posted by GitBox <gi...@apache.org>.
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?
   ```
   $ 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}
   ________________________________________________________________________________________________________________________
   
   java:master $ 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:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on a change in pull request #660: ORC-728: Support head command in Java Tools

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on a change in pull request #660: ORC-728: Support head command in Java Tools

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org