Uploaded image for project: 'ORC'
  1. ORC
  2. ORC-168

Documentation Writer Example: batch.size++ has a wrong possition

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Critical
    • Resolution: Not A Problem
    • None
    • None
    • documentation, Java
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              citrullin Philipp Blum
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: