spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dongjoon-hyun <...@git.apache.org>
Subject [GitHub] spark pull request #20438: [SPARK-23272][SQL] add calendar interval type sup...
Date Tue, 30 Jan 2018 16:50:38 GMT
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20438#discussion_r164806777
  
    --- Diff: sql/core/src/main/java/org/apache/spark/sql/vectorized/ColumnVector.java ---
    @@ -236,9 +238,29 @@ public MapData getMap(int ordinal) {
       public abstract byte[] getBinary(int rowId);
     
       /**
    -   * Returns the ordinal's child column vector.
    +   * Returns the calendar interval type value for rowId.
    +   *
    +   * In Spark, calendar interval type value is basically an integer value representing
the number of
    +   * months in this interval, and a long value representing the number of microseconds
in this
    +   * interval. An interval type vector is the same as a struct type vector with 2 fields:
`months`
    +   * and `microseconds`.
    +   *
    +   * To support interval type, implementations must implement {@link #getChild(int)}
and define 2
    +   * child vectors: the first child vector is an int type vector, containing all the
month values of
    +   * all the interval values in this vector. The second child vector is a long type vector,
    +   * containing all the microsecond values of all the interval values in this vector.
    +   */
    +  public final CalendarInterval getInterval(int rowId) {
    +    if (isNullAt(rowId)) return null;
    +    final int months = getChild(0).getInt(rowId);
    +    final long microseconds = getChild(1).getLong(rowId);
    +    return new CalendarInterval(months, microseconds);
    +  }
    +
    +  /**
    +   * @return child [[ColumnVector]] at the given ordinal.
        */
    -  public abstract ColumnVector getChild(int ordinal);
    +  protected abstract ColumnVector getChild(int ordinal);
    --- End diff --
    
    Oh, I see. Now, it became `protected`.


---

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


Mime
View raw message