orc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omalley <...@git.apache.org>
Subject [GitHub] orc issue #104: Core documentation fixes
Date Thu, 13 Apr 2017 21:30:20 GMT
Github user omalley commented on the issue:

    https://github.com/apache/orc/pull/104
  
    As a double check, I tried the two variants:
    
    ```java
        TypeDescription schema = TypeDescription.fromString("struct<x:int,y:int>");
        Writer writer = OrcFile.createWriter(testFilePath,
            OrcFile.writerOptions(conf)
                .setSchema(schema));
        VectorizedRowBatch batch = schema.createRowBatch(10);
        LongColumnVector x = (LongColumnVector) batch.cols[0];
        LongColumnVector y = (LongColumnVector) batch.cols[1];
        for(int r=0; r < 15; ++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 (batch.size != 0) {
          writer.addRowBatch(batch);
          batch.reset();
        }
        writer.close();
    ```
    
    and
    
    ```java
        TypeDescription schema = TypeDescription.fromString("struct<x:int,y:int>");
        Writer writer = OrcFile.createWriter(testFilePath,
            OrcFile.writerOptions(conf)
                .setSchema(schema));
        VectorizedRowBatch batch = schema.createRowBatch(10);
        LongColumnVector x = (LongColumnVector) batch.cols[0];
        LongColumnVector y = (LongColumnVector) batch.cols[1];
        for(int r=0; r < 15; ++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++;
        }
        if (batch.size != 0) {
          writer.addRowBatch(batch);
          batch.reset();
        }
        writer.close();
    ```
    
    The first generated the expected output and the second got an array out of bounds exception.
The correct output is:
    
    ```json
    {"x": 0, "y": 0}
    {"x": 1, "y": 3}
    {"x": 2, "y": 6}
    {"x": 3, "y": 9}
    {"x": 4, "y": 12}
    {"x": 5, "y": 15}
    {"x": 6, "y": 18}
    {"x": 7, "y": 21}
    {"x": 8, "y": 24}
    {"x": 9, "y": 27}
    {"x": 10, "y": 30}
    {"x": 11, "y": 33}
    {"x": 12, "y": 36}
    {"x": 13, "y": 39}
    {"x": 14, "y": 42}
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message