You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by nongli <gi...@git.apache.org> on 2016/01/26 01:38:36 UTC

[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

GitHub user nongli opened a pull request:

    https://github.com/apache/spark/pull/10908

    [SPARK-12992][SQL]: Update parquet reader to support more types when decoding to ColumnarBatch.

    This patch implements support for more types when doing the vectorized decode. There are
    a few more types remaining but they should be very straightforward after this. This code
    has a few copy and paste pieces but they are difficult to eliminate due to performance
    considerations.
    
    Specifically, this patch adds support for:
      - String, Long, Byte types
      - Dictionary encoding for those types.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nongli/spark spark-12992

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/10908.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #10908
    
----
commit 518d9bc64fd687204b157b1b36816620482716bf
Author: Nong Li <no...@databricks.com>
Date:   2016-01-05T04:39:31Z

    [WIP] [SPARK-12854][SQL] Implement complex types support in ColumnarBatch.
    
    WIP: this patch adds some random row generation. The test code needs to be cleaned up as it
    duplicates functionality from else where. The non-test code should be good to review.
    
    This patch adds support for complex types for ColumnarBatch. ColumnarBatch supports structs
    and arrays. There is a simple mapping between the richer catalyst types to these two. Strings
    are treated as an array of bytes.
    
    ColumnarBatch will contain a column for each node of the schema. Non-complex schemas consists
    of just leaf nodes. Structs represent an internal node with one child for each field. Arrays
    are internal nodes with one child. Structs just contain nullability. Arrays contain offsets
    and lengths into the child array. This structure is able to handle arbitrary nesting. It has
    the key property that we maintain columnar throughout and that primitive types are only stored
    in the leaf nodes and contiguous across rows. For example, if the schema is array<array<int>>,
    all of the int data is stored consecutively.
    
    As part of this, this patch adds append APIs in addition to the Put APIs (e.g. putLong(rowid, v)
    vs appendLong(v)). These APIs are necessary when the batch contains variable length elements.
    The vectors are not fixed length and will grow as necessary. This should make the usage a lot
    simpler for the writer.

commit f579889413c3978355fb0fb0d0ac02719803cb30
Author: Nong Li <no...@databricks.com>
Date:   2016-01-25T22:37:07Z

    Updates

commit ea1f406ef9c73c7344128dca23efb1c9ac29a0f0
Author: Nong Li <no...@databricks.com>
Date:   2016-01-20T01:46:29Z

    [SPARK-12992][SQL]: Update parquet reader to support more types when decoding to ColumnarBatch.
    
    This patch implements support for more types when doing the vectorized decode. There are
    a few more types remaining but they should be very straightfoward after this. This code
    has a few copy and paste pieces but they are difficult to eliminate due to performance
    considerations.
    
    Specifically, this patch adds support for:
      - String, Long, Byte types
      - Dictionary encoding for those types.

----


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-174751460
  
    **[Test build #50047 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/50047/consoleFull)** for PR 10908 at commit [`ea1f406`](https://github.com/apache/spark/commit/ea1f406ef9c73c7344128dca23efb1c9ac29a0f0).


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-178179904
  
    **[Test build #50499 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/50499/consoleFull)** for PR 10908 at commit [`2ea2d54`](https://github.com/apache/spark/commit/2ea2d547c908aa4be289959c461b06fbbc0f9f63).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/10908


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-175455355
  
    **[Test build #50174 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/50174/consoleFull)** for PR 10908 at commit [`2c8aaad`](https://github.com/apache/spark/commit/2c8aaadc691f792016b745c22b39b9e96111662a).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-175455498
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/50174/
    Test PASSed.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-178179979
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/50499/
    Test FAILed.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51025095
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedRleValuesReader.java ---
    @@ -180,6 +188,152 @@ public void readIntegers(int total, ColumnVector c, int rowId, int level,
         }
       }
     
    +  // TODO: can this code duplication be removed without a perf penalty?
    +  public void readBytes(int total, ColumnVector c,
    +                        int rowId, int level, VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readBytes(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putByte(rowId + i, data.readByte());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readLongs(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readLongs(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putLong(rowId + i, data.readLong());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readBinarys(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            c.putNotNulls(rowId, n);
    +            data.readBinary(n, c, rowId);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putNotNull(rowId + i);
    +              data.readBinary(1, c, rowId);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +
    +  // This is used for decoding dictionary IDs (as opposed to definition levels).
    +  @Override
    +  public void readIntegers(int total, ColumnVector c, int rowId) {
    +    int left = total;
    +    while (left > 0) {
    +    if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    --- End diff --
    
    Should we have a defensive check to ensure that `currentCount > 0`?


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51028949
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedPlainValuesReader.java ---
    @@ -52,15 +55,49 @@ public void skip(int n) {
       }
     
       @Override
    -  public void readIntegers(int total, ColumnVector c, int rowId) {
    +  public final void readIntegers(int total, ColumnVector c, int rowId) {
         c.putIntsLittleEndian(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
         offset += 4 * total;
       }
     
       @Override
    -  public int readInteger() {
    +  public final void readLongs(int total, ColumnVector c, int rowId) {
    +    c.putLongsLittleEndian(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
    +    offset += 8 * total;
    +  }
    +
    +  @Override
    +  public final void readBytes(int total, ColumnVector c, int rowId) {
    +    c.putBytes(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
    +    offset += total;
    +  }
    +
    +  @Override
    +  public final int readInteger() {
         int v = Platform.getInt(buffer, offset);
         offset += 4;
         return v;
       }
    +
    +  @Override
    +  public final long readLong() {
    +    long v = Platform.getLong(buffer, offset);
    +    offset += 8;
    +    return v;
    +  }
    +
    +  @Override
    +  public final byte readByte() {
    +    return (byte)readInteger();
    --- End diff --
    
    Will a byte take 1 or 4 bytes?


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-174790914
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/50047/
    Test FAILed.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-178179976
  
    Merged build finished. Test FAILed.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51024721
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedRleValuesReader.java ---
    @@ -180,6 +188,152 @@ public void readIntegers(int total, ColumnVector c, int rowId, int level,
         }
       }
     
    +  // TODO: can this code duplication be removed without a perf penalty?
    +  public void readBytes(int total, ColumnVector c,
    +                        int rowId, int level, VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readBytes(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putByte(rowId + i, data.readByte());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readLongs(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readLongs(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putLong(rowId + i, data.readLong());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readBinarys(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            c.putNotNulls(rowId, n);
    +            data.readBinary(n, c, rowId);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putNotNull(rowId + i);
    +              data.readBinary(1, c, rowId);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +
    +  // This is used for decoding dictionary IDs (as opposed to definition levels).
    +  @Override
    +  public void readIntegers(int total, ColumnVector c, int rowId) {
    +    int left = total;
    +    while (left > 0) {
    +    if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          c.putInts(rowId, n, currentValue);
    +          break;
    +        case PACKED:
    +          c.putInts(rowId, n, currentBuffer, currentBufferIdx);
    +          currentBufferIdx += n;
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  @Override
    +  public byte readByte() {
    +    throw new UnsupportedOperationException("only readInts is valid.");
    --- End diff --
    
    readInts -> readBytes


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by nongli <gi...@git.apache.org>.
Github user nongli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51462281
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedRleValuesReader.java ---
    @@ -180,6 +188,152 @@ public void readIntegers(int total, ColumnVector c, int rowId, int level,
         }
       }
     
    +  // TODO: can this code duplication be removed without a perf penalty?
    +  public void readBytes(int total, ColumnVector c,
    +                        int rowId, int level, VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readBytes(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putByte(rowId + i, data.readByte());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readLongs(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readLongs(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putLong(rowId + i, data.readLong());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readBinarys(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            c.putNotNulls(rowId, n);
    +            data.readBinary(n, c, rowId);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putNotNull(rowId + i);
    +              data.readBinary(1, c, rowId);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +
    +  // This is used for decoding dictionary IDs (as opposed to definition levels).
    +  @Override
    +  public void readIntegers(int total, ColumnVector c, int rowId) {
    +    int left = total;
    +    while (left > 0) {
    +    if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          c.putInts(rowId, n, currentValue);
    +          break;
    +        case PACKED:
    +          c.putInts(rowId, n, currentBuffer, currentBufferIdx);
    +          currentBufferIdx += n;
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  @Override
    +  public byte readByte() {
    +    throw new UnsupportedOperationException("only readInts is valid.");
    --- End diff --
    
    This should be readInts. The only valid read* APIs that doesn't also decode definition levels is used to decode dictionary ids, which are always ints. I updated the comment for readIntegers() to try to capture this.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-175455496
  
    Merged build finished. Test PASSed.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-175419378
  
    **[Test build #50174 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/50174/consoleFull)** for PR 10908 at commit [`2c8aaad`](https://github.com/apache/spark/commit/2c8aaadc691f792016b745c22b39b9e96111662a).


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51031167
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/UnsafeRowParquetRecordReader.java ---
    @@ -237,7 +233,8 @@ private void initializeInternal() throws IOException {
     
           // TODO: Be extremely cautious in what is supported. Expand this.
           if (originalTypes[i] != null && originalTypes[i] != OriginalType.DECIMAL &&
    -          originalTypes[i] != OriginalType.UTF8 && originalTypes[i] != OriginalType.DATE) {
    +          originalTypes[i] != OriginalType.UTF8 && originalTypes[i] != OriginalType.DATE &&
    +          originalTypes[i] != OriginalType.INT_8 && originalTypes[i] != OriginalType.INT_16) {
    --- End diff --
    
    Do we support ShortType (INT_16)?


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-178913769
  
    LGTM, merging this into master, thanks!


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-178168455
  
    **[Test build #50499 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/50499/consoleFull)** for PR 10908 at commit [`2ea2d54`](https://github.com/apache/spark/commit/2ea2d547c908aa4be289959c461b06fbbc0f9f63).


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by nongli <gi...@git.apache.org>.
Github user nongli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51462376
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedPlainValuesReader.java ---
    @@ -52,15 +55,49 @@ public void skip(int n) {
       }
     
       @Override
    -  public void readIntegers(int total, ColumnVector c, int rowId) {
    +  public final void readIntegers(int total, ColumnVector c, int rowId) {
         c.putIntsLittleEndian(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
         offset += 4 * total;
       }
     
       @Override
    -  public int readInteger() {
    +  public final void readLongs(int total, ColumnVector c, int rowId) {
    +    c.putLongsLittleEndian(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
    +    offset += 8 * total;
    +  }
    +
    +  @Override
    +  public final void readBytes(int total, ColumnVector c, int rowId) {
    +    c.putBytes(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
    +    offset += total;
    +  }
    +
    +  @Override
    +  public final int readInteger() {
         int v = Platform.getInt(buffer, offset);
         offset += 4;
         return v;
       }
    +
    +  @Override
    +  public final long readLong() {
    +    long v = Platform.getLong(buffer, offset);
    +    offset += 8;
    +    return v;
    +  }
    +
    +  @Override
    +  public final byte readByte() {
    +    return (byte)readInteger();
    --- End diff --
    
    4. Parquet only has 2 integers physical types: int32 and int64 and relies on encodings to compress bytes/shorts.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-178901804
  
    **[Test build #2493 has finished](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/2493/consoleFull)** for PR 10908 at commit [`2ea2d54`](https://github.com/apache/spark/commit/2ea2d547c908aa4be289959c461b06fbbc0f9f63).
     * This patch passes all tests.
     * This patch **does not merge cleanly**.
     * This patch adds no public classes.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-174790913
  
    Merged build finished. Test FAILed.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-174790728
  
    **[Test build #50047 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/50047/consoleFull)** for PR 10908 at commit [`ea1f406`](https://github.com/apache/spark/commit/ea1f406ef9c73c7344128dca23efb1c9ac29a0f0).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51025669
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedRleValuesReader.java ---
    @@ -180,6 +188,152 @@ public void readIntegers(int total, ColumnVector c, int rowId, int level,
         }
       }
     
    +  // TODO: can this code duplication be removed without a perf penalty?
    +  public void readBytes(int total, ColumnVector c,
    +                        int rowId, int level, VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readBytes(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putByte(rowId + i, data.readByte());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readLongs(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readLongs(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putLong(rowId + i, data.readLong());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readBinarys(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            c.putNotNulls(rowId, n);
    +            data.readBinary(n, c, rowId);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putNotNull(rowId + i);
    +              data.readBinary(1, c, rowId);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +
    +  // This is used for decoding dictionary IDs (as opposed to definition levels).
    +  @Override
    +  public void readIntegers(int total, ColumnVector c, int rowId) {
    +    int left = total;
    +    while (left > 0) {
    +    if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    --- End diff --
    
    nvm, readNextGroup() can make sure that.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51024828
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedRleValuesReader.java ---
    @@ -180,6 +188,152 @@ public void readIntegers(int total, ColumnVector c, int rowId, int level,
         }
       }
     
    +  // TODO: can this code duplication be removed without a perf penalty?
    +  public void readBytes(int total, ColumnVector c,
    +                        int rowId, int level, VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readBytes(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putByte(rowId + i, data.readByte());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readLongs(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            data.readLongs(n, c, rowId);
    +            c.putNotNulls(rowId, n);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putLong(rowId + i, data.readLong());
    +              c.putNotNull(rowId + i);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +  public void readBinarys(int total, ColumnVector c, int rowId, int level,
    +                        VectorizedValuesReader data) {
    +    int left = total;
    +    while (left > 0) {
    +      if (this.currentCount == 0) this.readNextGroup();
    +      int n = Math.min(left, this.currentCount);
    +      switch (mode) {
    +        case RLE:
    +          if (currentValue == level) {
    +            c.putNotNulls(rowId, n);
    +            data.readBinary(n, c, rowId);
    +          } else {
    +            c.putNulls(rowId, n);
    +          }
    +          break;
    +        case PACKED:
    +          for (int i = 0; i < n; ++i) {
    +            if (currentBuffer[currentBufferIdx++] == level) {
    +              c.putNotNull(rowId + i);
    +              data.readBinary(1, c, rowId);
    +            } else {
    +              c.putNull(rowId + i);
    +            }
    +          }
    +          break;
    +      }
    +      rowId += n;
    +      left -= n;
    +      currentCount -= n;
    +    }
    +  }
    +
    +
    +  // This is used for decoding dictionary IDs (as opposed to definition levels).
    +  @Override
    +  public void readIntegers(int total, ColumnVector c, int rowId) {
    +    int left = total;
    +    while (left > 0) {
    +    if (this.currentCount == 0) this.readNextGroup();
    --- End diff --
    
    indent


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10908#discussion_r51031983
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedPlainValuesReader.java ---
    @@ -52,15 +55,49 @@ public void skip(int n) {
       }
     
       @Override
    -  public void readIntegers(int total, ColumnVector c, int rowId) {
    +  public final void readIntegers(int total, ColumnVector c, int rowId) {
         c.putIntsLittleEndian(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
         offset += 4 * total;
       }
     
       @Override
    -  public int readInteger() {
    +  public final void readLongs(int total, ColumnVector c, int rowId) {
    +    c.putLongsLittleEndian(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
    +    offset += 8 * total;
    +  }
    +
    +  @Override
    +  public final void readBytes(int total, ColumnVector c, int rowId) {
    +    c.putBytes(rowId, total, buffer, offset - Platform.BYTE_ARRAY_OFFSET);
    --- End diff --
    
    ByteType should be INT32 in parquet, 4 bytes per SQL Byte


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-12992][SQL]: Update parquet reader to s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/10908#issuecomment-178836160
  
    **[Test build #2493 has started](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/2493/consoleFull)** for PR 10908 at commit [`2ea2d54`](https://github.com/apache/spark/commit/2ea2d547c908aa4be289959c461b06fbbc0f9f63).


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org