Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add key column and column properties to JsPartitionedTable #4789

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.TypedTicket;
import io.deephaven.web.client.api.barrage.WebBarrageUtils;
import io.deephaven.web.client.api.barrage.def.ColumnDefinition;
import io.deephaven.web.client.api.barrage.def.InitialTableDefinition;
import io.deephaven.web.client.api.lifecycle.HasLifecycle;
import io.deephaven.web.client.api.subscription.SubscriptionTableData;
import io.deephaven.web.client.api.subscription.TableSubscription;
Expand Down Expand Up @@ -64,6 +65,10 @@ public class JsPartitionedTable extends HasLifecycle implements ServerObject {
*/
private final Map<List<Object>, JsLazy<Promise<ClientTableState>>> tables = new HashMap<>();

private Column[] keyColumns;

private Column[] columns;


@JsIgnore
public JsPartitionedTable(WorkerConnection connection, JsWidget widget) {
Expand All @@ -83,12 +88,18 @@ public Promise<JsPartitionedTable> refetch() {
descriptor = PartitionedTableDescriptor.deserializeBinary(w.getDataAsU8());

keyColumnTypes = new ArrayList<>();
InitialTableDefinition tableDefinition = WebBarrageUtils.readTableDefinition(
WebBarrageUtils.readSchemaMessage(descriptor.getConstituentDefinitionSchema_asU8()));
ColumnDefinition[] columnDefinitions = WebBarrageUtils.readColumnDefinitions(
georgecwan marked this conversation as resolved.
Show resolved Hide resolved
WebBarrageUtils.readSchemaMessage(descriptor.getConstituentDefinitionSchema_asU8()));
for (int i = 0; i < columnDefinitions.length; i++) {
ColumnDefinition columnDefinition = columnDefinitions[i];
columns = new Column[0];
keyColumns = new Column[0];
for (ColumnDefinition columnDefinition : columnDefinitions) {
georgecwan marked this conversation as resolved.
Show resolved Hide resolved
Column column = columnDefinition.makeJsColumn(columns.length, tableDefinition.getColumnsByName());
columns[columns.length] = column;
if (descriptor.getKeyColumnNamesList().indexOf(columnDefinition.getName()) != -1) {
keyColumnTypes.add(columnDefinition.getType());
keyColumns[keyColumns.length] = column;
}
}
georgecwan marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -248,6 +259,26 @@ public int size() {
return tables.size();
}

/**
* An array of all the key columns used by the table
georgecwan marked this conversation as resolved.
Show resolved Hide resolved
*
* @return Array of Column
*/
@JsProperty
public Column[] getKeyColumns() {
return keyColumns;
}

/**
* An array of all the columns used by the table
georgecwan marked this conversation as resolved.
Show resolved Hide resolved
*
* @return Array of Column
*/
@JsProperty
public Column[] getColumns() {
return columns;
}

/**
* Indicates that this PartitionedTable will no longer be used, removing subcriptions to updated keys, etc. This
* will not affect tables in use.
Expand Down
Loading