Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11435#discussion_r54936755
  
    --- Diff: 
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVectorUtils.java
 ---
    @@ -41,6 +43,58 @@ public static String toString(ColumnVector.Array a) {
       }
     
       /**
    +   * Populates the entire `col` with `row[fieldIdx]`
    +   */
    +  public static void populate(ColumnVector col, InternalRow row, int 
fieldIdx) {
    +    int capacity = col.capacity;
    +    DataType t = col.dataType();
    +
    +    if (row.isNullAt(fieldIdx)) {
    +      col.putNulls(0, capacity);
    +    } else {
    +      if (t == DataTypes.BooleanType) {
    +        col.putBooleans(0, capacity, row.getBoolean(fieldIdx));
    +      } else if (t == DataTypes.ByteType) {
    +        col.putBytes(0, capacity, row.getByte(fieldIdx));
    +      } else if (t == DataTypes.ShortType) {
    +        col.putShorts(0, capacity, row.getShort(fieldIdx));
    +      } else if (t == DataTypes.IntegerType) {
    +        col.putInts(0, capacity, row.getInt(fieldIdx));
    +      } else if (t == DataTypes.LongType) {
    +        col.putLongs(0, capacity, row.getLong(fieldIdx));
    +      } else if (t == DataTypes.FloatType) {
    +        col.putFloats(0, capacity, row.getFloat(fieldIdx));
    +      } else if (t == DataTypes.DoubleType) {
    +        col.putDoubles(0, capacity, row.getDouble(fieldIdx));
    +      } else if (t == DataTypes.StringType) {
    +        UTF8String v = row.getUTF8String(fieldIdx);
    +        for (int i = 0; i < capacity; i++) {
    +          col.putByteArray(i, v.getBytes());
    --- End diff --
    
    If row is UnsafeRow, `v.getBytes()` will copy the bytes, we should pull 
that out of the loop.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to