deephaven.experimental.data_index

This module provides the ability to create, check, and retrieve DataIndex objects from Deephaven tables.

class DataIndex(j_data_index)[source]

Bases: JObjectWrapper

A DataIndex is an index used to improve the speed of data access operations for a Deephaven table. The index applies to one or more indexed (key) column(s) of a Deephaven table.

Note that a DataIndex itself is backed by a table.

j_object_type

alias of DataIndex

property keys

The names of the columns indexed by the DataIndex.

property table

The backing table of the DataIndex. Accessing it creates the table if needed, after which operations such as where can use the DataIndex.

data_index(table, key_cols, create_if_absent=True)[source]

Gets the DataIndex for the given key columns on the provided table. When the DataIndex already exists, returns it. When the DataIndex doesn’t already exist, if create_if_absent is True, creates the DataIndex first then returns it; otherwise returns None.

The returned DataIndex’s backing table may not have been created yet; it is created when first accessed through the DataIndex’s table property. Operations such as where use only data indexes whose backing tables already exist, and do not create them. To have such operations use the returned DataIndex, access its table property, and keep a reference to the DataIndex for as long as they should use it.

Parameters:
  • table (Table) – the table to index

  • key_cols (Sequence[str]) – the names of the key columns to index

  • create_if_absent (bool) – if True, create the DataIndex if it does not already exist, default is True

Return type:

DataIndex | None

Returns:

a DataIndex or None

Raises:

DHError –

has_data_index(table, key_cols)[source]

Checks if a table currently has a DataIndex for the given key columns.

Parameters:
  • table (Table) – the table to check

  • key_cols (Sequence[str]) – the names of the key columns indexed

Returns:

True if the table has a DataIndex, False otherwise

Return type:

bool