Extract table values
Deephaven tables have methods to extract values from tables into the native programming language. Generally, this isn't necessary for Deephaven queries but may be useful for debugging and logging purposes, and other specific use cases such as using listeners.
ColumnVectors (positional index access)
The recommended way to extract values from a table by positional index is using ColumnVectors. This provides random access to column data by row position.
For different data types, use the appropriate ColumnVectors method:
ColumnVectors.ofInt()forintcolumnsColumnVectors.ofLong()forlongcolumnsColumnVectors.ofDouble()fordoublecolumnsColumnVectors.ofFloat()forfloatcolumnsColumnVectors.ofObject()for object columns
Warning
Random access via ColumnVectors.get(position) is less efficient than bulk iteration. Use iteration when processing multiple values.
table.getColumnSource() (row key access)
The getColumnSource method returns a ColumnSource that provides access to column data by row key, not positional index.
[!IMPORTANT] >
ColumnSourcemethods likeget(rowKey)use row keys, not positional indices. Row keys are the internal identifiers for rows and may not match positional indices, especially in filtered or modified tables.
For primitive columns, use type-specific methods for better performance:
Type-specific ColumnSource methods:
getInt(rowKey)forintcolumnsgetLong(rowKey)forlongcolumnsgetDouble(rowKey)fordoublecolumnsgetFloat(rowKey)forfloatcolumnsget(rowKey)for object columns
table.columnIterator()
To loop over all values in a column, use columnIterator. This is the most efficient way to process all values.