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 3 commits
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
@@ -1,6 +1,7 @@
package io.deephaven.web.client.api;

import elemental2.core.JsArray;
import elemental2.core.JsObject;
import elemental2.core.JsSet;
import elemental2.dom.CustomEvent;
import elemental2.dom.CustomEventInit;
Expand All @@ -12,6 +13,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 +66,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,14 +89,22 @@ public Promise<JsPartitionedTable> refetch() {
descriptor = PartitionedTableDescriptor.deserializeBinary(w.getDataAsU8());

keyColumnTypes = new ArrayList<>();
ColumnDefinition[] columnDefinitions = WebBarrageUtils.readColumnDefinitions(
InitialTableDefinition tableDefinition = WebBarrageUtils.readTableDefinition(
WebBarrageUtils.readSchemaMessage(descriptor.getConstituentDefinitionSchema_asU8()));
ColumnDefinition[] columnDefinitions = tableDefinition.getColumns();
Column[] columns = new Column[0];
Column[] keyColumns = new Column[0];
for (int i = 0; i < columnDefinitions.length; i++) {
ColumnDefinition columnDefinition = columnDefinitions[i];
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
this.columns = JsObject.freeze(columns);
this.keyColumns = JsObject.freeze(keyColumns);

return w.getExportedObjects()[0].fetch();
}).then(result -> {
Expand Down Expand Up @@ -248,6 +262,37 @@ public int size() {
return tables.size();
}

/**
* An array of all the key columns that the tables are partitioned by.
*
* @return Array of Column
*/
@JsProperty
public Column[] getKeyColumns() {
return keyColumns;
}

/**
* An array of the columns in the tables that can be retrieved from this partitioned table, including both key and
* non-key columns.
*
* @return Array of Column
*/
@JsProperty
public Column[] getColumns() {
return columns;
}

/**
* A Table object containing all currently known keys used for this partitioned table.
*
* @return Table
*/
@JsProperty
public JsTable getKeyTable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not safe to return - what are you trying to do with this as an api consumer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new UI being implemented for Partitioned Tables (spec) need to be able to display the table containing all the possible keys.

return keys;
}

/**
* 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