Skip to content

Add KDocs for DataRowApi functions #1999

Description

@zaleslaw

Add KDocs for DataRowApi functions

The file core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataRowApi.kt is partially documented. Add concise KDocs for the non-deprecated members that still lack them, excluding deprecated / @AccessApiOverload overloads.

Already documented (leave as-is)

  • diff (all 4 overloads) and diffOrNull (all 4) — shared anchors DiffDocs / DiffOrNullDocs.
  • prev(), next().

⚠️ Bug to fix while here: the next() KDoc @return line is wrong — it says "Returns the previous [DataRow] … or null if the current row is the last" (copy-pasted from prev()). Correct it to "next".

Scope — not documented (grouped)

  • Row valuesvaluesOf<R>(), namedValues(), namedValuesOf<R>(), getValue<T>(columnName), getValueOrNull<T>(columnName).
  • NameValuePair schema — the NameValuePair data class and the name / value accessor properties on ColumnsContainer<NameValuePair<*>> / DataRow<NameValuePair<*>>.
  • MembershipcontainsKey(columnName), contains(column) operator.
  • Row metadatacolumnsCount(), columnNames(), columnTypes().
  • Navigation / windowingrelative(Iterable<Int>), relative(IntRange), movingAverage(k, expression).

Out of scope: deprecated isEmpty / isNotEmpty, the deprecated getRow / getRows / getRowOrNull shortcuts, and all deprecated ColumnReference / KProperty overloads of getValue / getValueOrNull / containsKey / contains.

KDocs should explain

  • getValue vs getValueOrNull: both look up a value by column name and cast to T; getValue throws if the column is missing, getValueOrNull returns null. Note the unchecked cast to T.
  • valuesOf vs namedValues / namedValuesOf: valuesOf<R>() returns the row's values filtered to type R; namedValues() returns all (name, value) pairs as NameValuePair<Any?>; namedValuesOf<R>() returns only the pairs whose value is R.
  • NameValuePair: it is the result schema of transpose / namedValues*; document the name / value accessors and why they exist (so row.transpose().name / .value resolve).
  • Metadata accessors: columnsCount / columnNames / columnTypes describe the owning DataFrame's columns as seen from the row.
  • relative: returns a sub-DataFrame of rows at offsets relative to the current row index, clamped to valid bounds (out-of-range offsets are dropped). movingAverage(k, ...) averages the expression over the current and previous k-1 rows.

Recommendations — make these KDocs genuinely useful (for users and for agents reading the source)

  1. First sentence states the contract, standalone — what it returns and the key condition; it's what IDE quick-doc and an agent's context both read first.
  2. Always give @throws / explicit-null behavior — pair getValue (throws) with getValueOrNull (returns null) so the reader picks the right one without reading the body.
  3. Disambiguate the value-listing trio (valuesOf / namedValues / namedValuesOf) by what is filtered and what is returned; one line each beats generic prose.
  4. Cross-link with @see the pairs and relatives: getValuegetValueOrNull, prevnext, relativemovingAverage, namedValuestranspose/NameValuePair.
  5. One minimal example per family using a canonical df row (e.g. df[0].getValue<Int>("age")), showing the resulting type in a comment.
  6. Name concrete types with links ([NameValuePair], [DataRow], [KType]) rather than "a value"/"a pair".
  7. Call out non-obvious edges the signature hides: the unchecked as T cast in getValue*; relative clamping/dropping out-of-range offsets; movingAverage dividing by the actual count near the start of the frame.
  8. Don't restate the signature — add the semantics types can't express.

Acceptance criteria

  • All members listed under Scope have concise KDocs; the already-documented diff / diffOrNull / prev / next are preserved.
  • The next() @return copy-paste bug is fixed.
  • getValue / getValueOrNull document throw-vs-null and the unchecked cast; the value-listing trio is clearly disambiguated.
  • Related members are @see-linked.
  • No documentation is added for deprecated / @AccessApiOverload overloads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    KDocsImprovements or additions to KDocs

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions