@@ -51,6 +51,52 @@ package object sql {
5151 * Row(value1, value2, value3, ...)
5252 * }}}
5353 *
54+ * A value of a row can be accessed through both generic access by ordinal,
55+ * which will incur boxing overhead for primitives, as well as native primitive access.
56+ * An example of generic access by ordinal:
57+ * {{{
58+ * import org.apache.spark.sql._
59+ *
60+ * val row = Row(1, true, "a string", null)
61+ * // row: Row = [1,true,a string,null]
62+ * val firstValue = row(0)
63+ * // firstValue: Any = 1
64+ * val fourthValue = row(3)
65+ * // fourthValue: Any = null
66+ * }}}
67+ *
68+ * For native primitive access, it is invalid to use the native primitive interface to retrieve
69+ * a value that is null, instead a user must check `isNullAt` before attempting to retrieve a value
70+ * that might be null.
71+ * An example of native primitive access:
72+ * {{{
73+ * // using the row from the previous example.
74+ * val firstValue = row.getInt(0)
75+ * // firstValue: Int = 1
76+ * val isNull = row.isNullAt(3)
77+ * // isNull: Boolean = true
78+ * }}}
79+ *
80+ * Interfaces related to native primitive access are:
81+ *
82+ * `isNullAt(i: Int): Boolean`
83+ *
84+ * `getInt(i: Int): Int`
85+ *
86+ * `getLong(i: Int): Long`
87+ *
88+ * `getDouble(i: Int): Double`
89+ *
90+ * `getFloat(i: Int): Float`
91+ *
92+ * `getBoolean(i: Int): Boolean`
93+ *
94+ * `getShort(i: Int): Short`
95+ *
96+ * `getByte(i: Int): Byte`
97+ *
98+ * `getString(i: Int): String`
99+ *
54100 * Fields in a [[Row ]] object can be extracted in a pattern match. Example:
55101 * {{{
56102 * import org.apache.spark.sql._
@@ -60,6 +106,7 @@ package object sql {
60106 * key -> value
61107 * }
62108 * }}}
109+ *
63110 * @group row
64111 */
65112 @ DeveloperApi
0 commit comments