Skip to content

Commit

Permalink
More comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhuai committed Jul 16, 2014
1 parent 42d47a3 commit e495e4e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,52 @@ package object sql {
* Row(value1, value2, value3, ...)
* }}}
*
* A value of a row can be accessed through both generic access by ordinal,
* which will incur boxing overhead for primitives, as well as native primitive access.
* An example of generic access by ordinal:
* {{{
* import org.apache.spark.sql._
*
* val row = Row(1, true, "a string", null)
* // row: Row = [1,true,a string,null]
* val firstValue = row(0)
* // firstValue: Any = 1
* val fourthValue = row(3)
* // fourthValue: Any = null
* }}}
*
* For native primitive access, it is invalid to use the native primitive interface to retrieve
* a value that is null, instead a user must check `isNullAt` before attempting to retrieve a value
* that might be null.
* An example of native primitive access:
* {{{
* // using the row from the previous example.
* val firstValue = row.getInt(0)
* // firstValue: Int = 1
* val isNull = row.isNullAt(3)
* // isNull: Boolean = true
* }}}
*
* Interfaces related to native primitive access are:
*
* `isNullAt(i: Int): Boolean`
*
* `getInt(i: Int): Int`
*
* `getLong(i: Int): Long`
*
* `getDouble(i: Int): Double`
*
* `getFloat(i: Int): Float`
*
* `getBoolean(i: Int): Boolean`
*
* `getShort(i: Int): Short`
*
* `getByte(i: Int): Byte`
*
* `getString(i: Int): String`
*
* Fields in a [[Row]] object can be extracted in a pattern match. Example:
* {{{
* import org.apache.spark.sql._
Expand All @@ -60,6 +106,7 @@ package object sql {
* key -> value
* }
* }}}
*
* @group row
*/
@DeveloperApi
Expand Down

0 comments on commit e495e4e

Please sign in to comment.