[ 
https://issues.apache.org/jira/browse/ORC-168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15968213#comment-15968213
 ] 

ASF GitHub Bot commented on ORC-168:
------------------------------------

Github user asfgit closed the pull request at:

    https://github.com/apache/orc/pull/104


> Documentation Writer Example: batch.size++ has a wrong possition
> ----------------------------------------------------------------
>
>                 Key: ORC-168
>                 URL: https://issues.apache.org/jira/browse/ORC-168
>             Project: ORC
>          Issue Type: Improvement
>          Components: documentation, Java
>            Reporter: Philipp Blum
>            Priority: Critical
>
> There's one little mistake in the Java Core Example. The for loops starts 
> with a batch.size++:
> for(int r=0; r < 10000; ++r) {
>   int row = batch.size++;
>   x.vector[row] = r;
>   y.vector[row] = r * 3;
>   // If the batch is full, write it out and start over.
>   if (batch.size == batch.getMaxSize()) {
>     writer.addRowBatch(batch);
>     batch.reset();
>   }
> }
> If you start with a batch.size++ the first index will be 1, so the first 
> entry in the orc file will be empty.
> Correct is:
> for(int r=0; r < 10000; ++r) {
>   int row = batch.size;
>   x.vector[row] = r;
>   y.vector[row] = r * 3;
>   // If the batch is full, write it out and start over.
>   if (batch.size == batch.getMaxSize()) {
>     writer.addRowBatch(batch);
>     batch.reset();
>   }
>  batch.size++;
> }
> Already tested it in scala.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to