From 810bf2696c43bd4f70e606a35961aaac1f87b0a8 Mon Sep 17 00:00:00 2001 From: mikebender Date: Thu, 18 Jan 2024 10:19:01 -0500 Subject: [PATCH 1/3] fix: Reject instead of returning a null table - Returning a `null` instead of an actual table is weird. Throw to indicate the key could not be found. --- .../java/io/deephaven/web/client/api/JsPartitionedTable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java index 5eca478264d..3cfa64e0741 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java @@ -169,8 +169,8 @@ public Promise getTable(Object key) { } final List keyList = Js.>uncheckedCast(key).asList(); if (!knownKeys.contains(keyList)) { - // key doesn't even exist, just hand back a null table - return Promise.resolve((JsTable) null); + // key doesn't even exist + return Promise.reject("Key not found"); } final String[] columnNames = descriptor.getKeyColumnNamesList().asArray(new String[0]); final String[] columnTypes = keyColumnTypes.toArray(new String[0]); From efcbe5025e23878ed5ec1093db0f674d2aa829ef Mon Sep 17 00:00:00 2001 From: mikebender Date: Wed, 14 Feb 2024 11:06:50 -0500 Subject: [PATCH 2/3] Revert "fix: Reject instead of returning a null table" This reverts commit 810bf2696c43bd4f70e606a35961aaac1f87b0a8. --- .../java/io/deephaven/web/client/api/JsPartitionedTable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java index 3cfa64e0741..5eca478264d 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java @@ -169,8 +169,8 @@ public Promise getTable(Object key) { } final List keyList = Js.>uncheckedCast(key).asList(); if (!knownKeys.contains(keyList)) { - // key doesn't even exist - return Promise.reject("Key not found"); + // key doesn't even exist, just hand back a null table + return Promise.resolve((JsTable) null); } final String[] columnNames = descriptor.getKeyColumnNamesList().asArray(new String[0]); final String[] columnTypes = keyColumnTypes.toArray(new String[0]); From 18aaa32e493c66fb58b053fea39bc6bf6a52d620 Mon Sep 17 00:00:00 2001 From: mikebender Date: Wed, 14 Feb 2024 11:08:29 -0500 Subject: [PATCH 3/3] Add @Nullable notation to return result --- .../io/deephaven/web/client/api/JsPartitionedTable.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java index 5eca478264d..6c4b9368a7a 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java @@ -24,6 +24,7 @@ import io.deephaven.web.shared.data.RangeSet; import jsinterop.annotations.JsIgnore; import jsinterop.annotations.JsMethod; +import jsinterop.annotations.JsNullable; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; import jsinterop.base.Js; @@ -157,12 +158,12 @@ private void handleKeys(Event update) { } /** - * Fetch the table with the given key. + * Fetch the table with the given key. If the key does not exist, returns `null`. * * @param key The key to fetch. An array of values for each key column, in the same order as the key columns are. - * @return Promise of dh.Table + * @return Promise of dh.Table, or `null` if the key does not exist. */ - public Promise getTable(Object key) { + public Promise<@JsNullable JsTable> getTable(Object key) { // Wrap non-arrays in an array so we are consistent with how we track keys if (!JsArray.isArray(key)) { key = JsArray.of(key);