From 8685f0ddd690f3994a6e1270565ee06c581d52e2 Mon Sep 17 00:00:00 2001 From: Arman Farhangi Date: Thu, 7 Mar 2024 13:40:15 -0800 Subject: [PATCH 01/11] Generalize Python InputTable class --- py/server/deephaven/table_factory.py | 99 +++++++++++++++------------- 1 file changed, 52 insertions(+), 47 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index ee2a0e59d23..cc51a7c7a44 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -231,49 +231,13 @@ def write_row(self, *values: Any) -> None: class InputTable(Table): - """InputTable is a subclass of Table that allows the users to dynamically add/delete/modify data in it. There are two - types of InputTable - append-only and keyed. + """InputTable is a subclass of Table that allows the users to dynamically add/delete/modify data in it.""" - The append-only input table is not keyed, all rows are added to the end of the table, and deletions and edits are - not permitted. - - The keyed input tablet has keys for each row and supports addition/deletion/modification of rows by the keys. - """ - - def __init__(self, col_defs: Dict[str, DType] = None, init_table: Table = None, - key_cols: Union[str, Sequence[str]] = None): - """Creates an InputTable instance from either column definitions or initial table. When key columns are - provided, the InputTable will be keyed, otherwise it will be append-only. - - Args: - col_defs (Dict[str, DType]): the column definitions - init_table (Table): the initial table - key_cols (Union[str, Sequence[str]): the name(s) of the key column(s) - - Raises: - DHError - """ - try: - if col_defs is None and init_table is None: - raise ValueError("either column definitions or init table should be provided.") - elif col_defs and init_table: - raise ValueError("both column definitions and init table are provided.") - - if col_defs: - j_arg_1 = _JTableDefinition.of( - [Column(name=n, data_type=t).j_column_definition for n, t in col_defs.items()]) - else: - j_arg_1 = init_table.j_table - - key_cols = to_sequence(key_cols) - if key_cols: - super().__init__(_JKeyedArrayBackedInputTable.make(j_arg_1, key_cols)) - else: - super().__init__(_JAppendOnlyArrayBackedInputTable.make(j_arg_1)) - self.j_input_table = self.j_table.getAttribute(_J_INPUT_TABLE_ATTRIBUTE) - self.key_columns = key_cols - except Exception as e: - raise DHError(e, "failed to create a InputTable.") from e + def __init__(self, source_table: Table): + super().__init__(source_table) + self.j_input_table = self.j_table.getAttribute(_J_INPUT_TABLE_ATTRIBUTE) + if not self.j_input_table: + raise DHError("the provided table input is not suitable for input tables.") def add(self, table: Table) -> None: """Writes rows from the provided table to this input table. If this is a keyed input table, added rows with keys @@ -292,7 +256,7 @@ def add(self, table: Table) -> None: def delete(self, table: Table) -> None: """Deletes the keys contained in the provided table from this keyed input table. If this method is called on an - append-only input table, a PermissionError will be raised. + append-only input table, an error will be raised. Args: table (Table): the table with the keys to delete @@ -301,18 +265,38 @@ def delete(self, table: Table) -> None: DHError """ try: - if not self.key_columns: - raise PermissionError("deletion on an append-only input table is not allowed.") self.j_input_table.delete(table.j_table) except Exception as e: raise DHError(e, "delete data in the InputTable failed.") from e + def get_key_names(self): + """Gets the names of the key columns. + + Returns: + a list with the names of the key columns of this input table + """ + return self.j_input_table.getKeyNames() + + def get_value_names(self): + """Gets the names of the value columns. By default, any column not marked as a key column is a value column. + + Returns: a list with the names of the value columns of this input table + """ + return self.j_input_table.getValueNames() + def input_table(col_defs: Dict[str, DType] = None, init_table: Table = None, key_cols: Union[str, Sequence[str]] = None) -> InputTable: - """Creates an InputTable from either column definitions or initial table. When key columns are + """Creates an in-memory InputTable from either column definitions or initial table. When key columns are provided, the InputTable will be keyed, otherwise it will be append-only. + There are two types of in-memory InputTable - append-only and keyed. + + The append-only input table is not keyed, all rows are added to the end of the table, and deletions and edits are + not permitted. + + The keyed input table has keys for each row and supports addition/deletion/modification of rows by the keys. + Args: col_defs (Dict[str, DType]): the column definitions init_table (Table): the initial table @@ -324,7 +308,28 @@ def input_table(col_defs: Dict[str, DType] = None, init_table: Table = None, Raises: DHError """ - return InputTable(col_defs=col_defs, init_table=init_table, key_cols=key_cols) + + try: + if col_defs is None and init_table is None: + raise ValueError("either column definitions or init table should be provided.") + elif col_defs and init_table: + raise ValueError("both column definitions and init table are provided.") + + if col_defs: + j_arg_1 = _JTableDefinition.of( + [Column(name=n, data_type=t).j_column_definition for n, t in col_defs.items()]) + else: + j_arg_1 = init_table.j_table + + key_cols = to_sequence(key_cols) + if key_cols: + source_table = _JKeyedArrayBackedInputTable.make(j_arg_1, key_cols) + else: + source_table = _JAppendOnlyArrayBackedInputTable.make(j_arg_1) + except Exception as e: + raise DHError(e, "failed to create an in-memory InputTable.") from e + + return InputTable(source_table) def ring_table(parent: Table, capacity: int, initialize: bool = True) -> Table: From 425c8035b9c32c3c0d2c22c5b9c8e9d97e7aaf5e Mon Sep 17 00:00:00 2001 From: Arman Farhangi Date: Fri, 8 Mar 2024 10:56:25 -0800 Subject: [PATCH 02/11] Add async methods --- py/server/deephaven/table_factory.py | 37 ++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index cc51a7c7a44..908fc3b8d5f 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -33,6 +33,7 @@ _JRingTableTools = jpy.get_type("io.deephaven.engine.table.impl.sources.ring.RingTableTools") _JSupplier = jpy.get_type('java.util.function.Supplier') _JFunctionGeneratedTableFactory = jpy.get_type("io.deephaven.engine.table.impl.util.FunctionGeneratedTableFactory") +_JInputTableStatusListener = jpy.get_type("io.deephaven.engine.util.input.InputTableStatusListener") def empty_table(size: int) -> Table: @@ -240,7 +241,7 @@ def __init__(self, source_table: Table): raise DHError("the provided table input is not suitable for input tables.") def add(self, table: Table) -> None: - """Writes rows from the provided table to this input table. If this is a keyed input table, added rows with keys + """Synchronously writes rows from the provided table to this input table. If this is a keyed input table, added rows with keys that match existing rows will replace those rows. Args: @@ -254,8 +255,24 @@ def add(self, table: Table) -> None: except Exception as e: raise DHError(e, "add to InputTable failed.") from e + def add_async(self, table: Table, j_listener: jpy.JType = _JInputTableStatusListener.DEFAULT) -> None: + """Asynchronously writes rows from the provided table to this input table. If this is a keyed input table, added rows with keys + that match existing rows will replace those rows. + + Args: + table (Table): the table that provides the rows to write + j_listener (jpy.JType): the listener for asynchronous results + + Raises: + DHError + """ + try: + self.j_input_table.addAsync(table.j_table, j_listener) + except Exception as e: + raise DHError(e, "addAsync to InputTable failed.") from e + def delete(self, table: Table) -> None: - """Deletes the keys contained in the provided table from this keyed input table. If this method is called on an + """Synchronously deletes the keys contained in the provided table from this keyed input table. If this method is called on an append-only input table, an error will be raised. Args: @@ -269,6 +286,22 @@ def delete(self, table: Table) -> None: except Exception as e: raise DHError(e, "delete data in the InputTable failed.") from e + def delete_async(self, table: Table, j_listener: jpy.JType = _JInputTableStatusListener.DEFAULT) -> None: + """Asynchronously deletes the keys contained in the provided table from this keyed input table. If this method is called on an + append-only input table, an error will be raised. + + Args: + table (Table): the table with the keys to delete + j_listener (jpy.JType): The listener for asynchronous results + + Raises: + DHError + """ + try: + self.j_input_table.deleteAsync(table.j_table, j_listener) + except Exception as e: + raise DHError(e, "delete data in the InputTable failed.") from e + def get_key_names(self): """Gets the names of the key columns. From 6d05923163c920d12dd8c615721c8289e1bfb4dd Mon Sep 17 00:00:00 2001 From: Arman Farhangi Date: Mon, 11 Mar 2024 09:21:22 -0700 Subject: [PATCH 03/11] Remove async methods --- py/server/deephaven/table_factory.py | 32 ---------------------------- 1 file changed, 32 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index 908fc3b8d5f..90ecee2de75 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -255,22 +255,6 @@ def add(self, table: Table) -> None: except Exception as e: raise DHError(e, "add to InputTable failed.") from e - def add_async(self, table: Table, j_listener: jpy.JType = _JInputTableStatusListener.DEFAULT) -> None: - """Asynchronously writes rows from the provided table to this input table. If this is a keyed input table, added rows with keys - that match existing rows will replace those rows. - - Args: - table (Table): the table that provides the rows to write - j_listener (jpy.JType): the listener for asynchronous results - - Raises: - DHError - """ - try: - self.j_input_table.addAsync(table.j_table, j_listener) - except Exception as e: - raise DHError(e, "addAsync to InputTable failed.") from e - def delete(self, table: Table) -> None: """Synchronously deletes the keys contained in the provided table from this keyed input table. If this method is called on an append-only input table, an error will be raised. @@ -286,22 +270,6 @@ def delete(self, table: Table) -> None: except Exception as e: raise DHError(e, "delete data in the InputTable failed.") from e - def delete_async(self, table: Table, j_listener: jpy.JType = _JInputTableStatusListener.DEFAULT) -> None: - """Asynchronously deletes the keys contained in the provided table from this keyed input table. If this method is called on an - append-only input table, an error will be raised. - - Args: - table (Table): the table with the keys to delete - j_listener (jpy.JType): The listener for asynchronous results - - Raises: - DHError - """ - try: - self.j_input_table.deleteAsync(table.j_table, j_listener) - except Exception as e: - raise DHError(e, "delete data in the InputTable failed.") from e - def get_key_names(self): """Gets the names of the key columns. From b50d2e8d5c81049bbe8109f6f25709934f6a4eff Mon Sep 17 00:00:00 2001 From: arman-ddl <122062464+arman-ddl@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:23:53 -0700 Subject: [PATCH 04/11] Improve col name getters Per jmao-denver Co-authored-by: Jianfeng Mao <4297243+jmao-denver@users.noreply.github.com> --- py/server/deephaven/table_factory.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index 908fc3b8d5f..c23b1519d6f 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -302,20 +302,20 @@ def delete_async(self, table: Table, j_listener: jpy.JType = _JInputTableStatusL except Exception as e: raise DHError(e, "delete data in the InputTable failed.") from e - def get_key_names(self): + def get_key_names(self) -> List[str]: """Gets the names of the key columns. Returns: a list with the names of the key columns of this input table """ - return self.j_input_table.getKeyNames() + return j_list_to_list(self.j_input_table.getKeyNames()) - def get_value_names(self): + def get_value_names(self) -> List[str]: """Gets the names of the value columns. By default, any column not marked as a key column is a value column. Returns: a list with the names of the value columns of this input table """ - return self.j_input_table.getValueNames() + return j_list_to_list(self.j_input_table.getValueNames()) def input_table(col_defs: Dict[str, DType] = None, init_table: Table = None, From ae7134ce8b75ef1ef0209c8c2f9ea229575729e7 Mon Sep 17 00:00:00 2001 From: Arman Farhangi Date: Mon, 11 Mar 2024 13:28:39 -0700 Subject: [PATCH 05/11] Add tests; polish --- py/server/deephaven/table_factory.py | 3 +-- py/server/tests/test_table_factory.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index ada9d33d7c1..beee78a95c2 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -16,8 +16,7 @@ from deephaven.column import InputColumn, Column from deephaven.dtypes import DType, Duration, Instant from deephaven.execution_context import ExecutionContext -from deephaven.jcompat import j_lambda -from deephaven.jcompat import to_sequence +from deephaven.jcompat import j_lambda, j_list_to_list, to_sequence from deephaven.table import Table from deephaven.update_graph import auto_locking_ctx diff --git a/py/server/tests/test_table_factory.py b/py/server/tests/test_table_factory.py index 3045f5bae6a..836a186563f 100644 --- a/py/server/tests/test_table_factory.py +++ b/py/server/tests/test_table_factory.py @@ -327,12 +327,16 @@ def test_input_table(self): col_defs = {c.name: c.data_type for c in t.columns} with self.subTest("from table definition"): append_only_input_table = input_table(col_defs=col_defs) + self.assertEqual(append_only_input_table.get_key_names(), []) + self.assertEqual(append_only_input_table.get_value_names(), [col.name for col in cols]) append_only_input_table.add(t) self.assertEqual(append_only_input_table.size, 2) append_only_input_table.add(t) self.assertEqual(append_only_input_table.size, 4) keyed_input_table = input_table(col_defs=col_defs, key_cols="String") + self.assertEqual(keyed_input_table.get_key_names(), ["String"]) + self.assertEqual(keyed_input_table.get_value_names(), [col.name for col in cols if col.name != "String"]) keyed_input_table.add(t) self.assertEqual(keyed_input_table.size, 2) keyed_input_table.add(t) @@ -340,11 +344,15 @@ def test_input_table(self): with self.subTest("from init table"): append_only_input_table = input_table(init_table=t) + self.assertEqual(append_only_input_table.get_key_names(), []) + self.assertEqual(append_only_input_table.get_value_names(), [col.name for col in cols]) self.assertEqual(append_only_input_table.size, 2) append_only_input_table.add(t) self.assertEqual(append_only_input_table.size, 4) keyed_input_table = input_table(init_table=t, key_cols="String") + self.assertEqual(keyed_input_table.get_key_names(), ["String"]) + self.assertEqual(keyed_input_table.get_value_names(), [col.name for col in cols if col.name != "String"]) self.assertEqual(keyed_input_table.size, 2) keyed_input_table.add(t) self.assertEqual(keyed_input_table.size, 2) @@ -355,9 +363,11 @@ def test_input_table(self): append_only_input_table = input_table(init_table=t) with self.assertRaises(DHError) as cm: append_only_input_table.delete(t) - self.assertIn("not allowed.", str(cm.exception)) + self.assertIn("doesn\'t support delete operation", str(cm.exception)) keyed_input_table = input_table(init_table=t, key_cols=["String", "Double"]) + self.assertEqual(keyed_input_table.get_key_names(), ["String", "Double"]) + self.assertEqual(keyed_input_table.get_value_names(), [col.name for col in cols if col.name != "String" and col.name != "Double"]) self.assertEqual(keyed_input_table.size, 2) keyed_input_table.delete(t.select(["String", "Double"])) self.assertEqual(keyed_input_table.size, 0) From 0ff048d924e1630fef70ef4f005e24305cbe5750 Mon Sep 17 00:00:00 2001 From: Arman Farhangi Date: Mon, 11 Mar 2024 14:34:23 -0700 Subject: [PATCH 06/11] Improve type hints and doc --- py/server/deephaven/table_factory.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index beee78a95c2..7b75063adda 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -231,10 +231,13 @@ def write_row(self, *values: Any) -> None: class InputTable(Table): - """InputTable is a subclass of Table that allows the users to dynamically add/delete/modify data in it.""" + """InputTable is a subclass of Table that allows the users to dynamically add/delete/modify data in it. - def __init__(self, source_table: Table): - super().__init__(source_table) + Users should always create InputTables through factory methods rather than directly from the constructor. + """ + + def __init__(self, j_table: jpy.JType): + super().__init__(j_table) self.j_input_table = self.j_table.getAttribute(_J_INPUT_TABLE_ATTRIBUTE) if not self.j_input_table: raise DHError("the provided table input is not suitable for input tables.") @@ -323,13 +326,13 @@ def input_table(col_defs: Dict[str, DType] = None, init_table: Table = None, key_cols = to_sequence(key_cols) if key_cols: - source_table = _JKeyedArrayBackedInputTable.make(j_arg_1, key_cols) + j_table = _JKeyedArrayBackedInputTable.make(j_arg_1, key_cols) else: - source_table = _JAppendOnlyArrayBackedInputTable.make(j_arg_1) + j_table = _JAppendOnlyArrayBackedInputTable.make(j_arg_1) except Exception as e: raise DHError(e, "failed to create an in-memory InputTable.") from e - return InputTable(source_table) + return InputTable(j_table) def ring_table(parent: Table, capacity: int, initialize: bool = True) -> Table: From c58fbe902be35f1d4e6cb655031e8037f30d42d1 Mon Sep 17 00:00:00 2001 From: arman-ddl <122062464+arman-ddl@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:05:52 -0700 Subject: [PATCH 07/11] Change getters to properties Per jmao Co-authored-by: Jianfeng Mao <4297243+jmao-denver@users.noreply.github.com> --- py/server/deephaven/table_factory.py | 12 +++++------- py/server/tests/test_table_factory.py | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index 7b75063adda..e6ff1bbe72f 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -272,18 +272,16 @@ def delete(self, table: Table) -> None: except Exception as e: raise DHError(e, "delete data in the InputTable failed.") from e + @property def get_key_names(self) -> List[str]: - """Gets the names of the key columns. - - Returns: - a list with the names of the key columns of this input table + """The names of the key columns of the InputTable. """ return j_list_to_list(self.j_input_table.getKeyNames()) - def get_value_names(self) -> List[str]: - """Gets the names of the value columns. By default, any column not marked as a key column is a value column. + @property + def value_names(self) -> List[str]: + """The names of the value columns. By default, any column not marked as a key column is a value column. - Returns: a list with the names of the value columns of this input table """ return j_list_to_list(self.j_input_table.getValueNames()) diff --git a/py/server/tests/test_table_factory.py b/py/server/tests/test_table_factory.py index 836a186563f..6dae98802e7 100644 --- a/py/server/tests/test_table_factory.py +++ b/py/server/tests/test_table_factory.py @@ -327,8 +327,8 @@ def test_input_table(self): col_defs = {c.name: c.data_type for c in t.columns} with self.subTest("from table definition"): append_only_input_table = input_table(col_defs=col_defs) - self.assertEqual(append_only_input_table.get_key_names(), []) - self.assertEqual(append_only_input_table.get_value_names(), [col.name for col in cols]) + self.assertEqual(append_only_input_table.key_names, []) + self.assertEqual(append_only_input_table.value_names, [col.name for col in cols]) append_only_input_table.add(t) self.assertEqual(append_only_input_table.size, 2) append_only_input_table.add(t) From 5838bb2a810aa9335928468fbbdde71d5e8f3e19 Mon Sep 17 00:00:00 2001 From: Arman Farhangi Date: Mon, 11 Mar 2024 19:26:32 -0700 Subject: [PATCH 08/11] Refactor property usage --- py/server/deephaven/table_factory.py | 2 +- py/server/tests/test_table_factory.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index e6ff1bbe72f..c5f62bd2eb1 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -273,7 +273,7 @@ def delete(self, table: Table) -> None: raise DHError(e, "delete data in the InputTable failed.") from e @property - def get_key_names(self) -> List[str]: + def key_names(self) -> List[str]: """The names of the key columns of the InputTable. """ return j_list_to_list(self.j_input_table.getKeyNames()) diff --git a/py/server/tests/test_table_factory.py b/py/server/tests/test_table_factory.py index 6dae98802e7..9771fdf24c8 100644 --- a/py/server/tests/test_table_factory.py +++ b/py/server/tests/test_table_factory.py @@ -335,8 +335,8 @@ def test_input_table(self): self.assertEqual(append_only_input_table.size, 4) keyed_input_table = input_table(col_defs=col_defs, key_cols="String") - self.assertEqual(keyed_input_table.get_key_names(), ["String"]) - self.assertEqual(keyed_input_table.get_value_names(), [col.name for col in cols if col.name != "String"]) + self.assertEqual(keyed_input_table.key_names, ["String"]) + self.assertEqual(keyed_input_table.value_names, [col.name for col in cols if col.name != "String"]) keyed_input_table.add(t) self.assertEqual(keyed_input_table.size, 2) keyed_input_table.add(t) @@ -344,15 +344,15 @@ def test_input_table(self): with self.subTest("from init table"): append_only_input_table = input_table(init_table=t) - self.assertEqual(append_only_input_table.get_key_names(), []) - self.assertEqual(append_only_input_table.get_value_names(), [col.name for col in cols]) + self.assertEqual(append_only_input_table.key_names, []) + self.assertEqual(append_only_input_table.value_names, [col.name for col in cols]) self.assertEqual(append_only_input_table.size, 2) append_only_input_table.add(t) self.assertEqual(append_only_input_table.size, 4) keyed_input_table = input_table(init_table=t, key_cols="String") - self.assertEqual(keyed_input_table.get_key_names(), ["String"]) - self.assertEqual(keyed_input_table.get_value_names(), [col.name for col in cols if col.name != "String"]) + self.assertEqual(keyed_input_table.key_names, ["String"]) + self.assertEqual(keyed_input_table.value_names, [col.name for col in cols if col.name != "String"]) self.assertEqual(keyed_input_table.size, 2) keyed_input_table.add(t) self.assertEqual(keyed_input_table.size, 2) @@ -366,8 +366,8 @@ def test_input_table(self): self.assertIn("doesn\'t support delete operation", str(cm.exception)) keyed_input_table = input_table(init_table=t, key_cols=["String", "Double"]) - self.assertEqual(keyed_input_table.get_key_names(), ["String", "Double"]) - self.assertEqual(keyed_input_table.get_value_names(), [col.name for col in cols if col.name != "String" and col.name != "Double"]) + self.assertEqual(keyed_input_table.key_names, ["String", "Double"]) + self.assertEqual(keyed_input_table.value_names, [col.name for col in cols if col.name != "String" and col.name != "Double"]) self.assertEqual(keyed_input_table.size, 2) keyed_input_table.delete(t.select(["String", "Double"])) self.assertEqual(keyed_input_table.size, 0) From 940f7d7f8420b12d689153397876d0f3bd05f131 Mon Sep 17 00:00:00 2001 From: jianfengmao Date: Tue, 12 Mar 2024 08:25:06 -0600 Subject: [PATCH 09/11] Set the correct object type for InputTable --- py/server/deephaven/table.py | 4 ++-- py/server/deephaven/table_factory.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/py/server/deephaven/table.py b/py/server/deephaven/table.py index 526e0819e31..2eca7ae3417 100644 --- a/py/server/deephaven/table.py +++ b/py/server/deephaven/table.py @@ -30,7 +30,7 @@ from deephaven.updateby import UpdateByOperation # Table -_J_Table = jpy.get_type("io.deephaven.engine.table.Table") +_JTable = jpy.get_type("io.deephaven.engine.table.Table") _JAttributeMap = jpy.get_type("io.deephaven.engine.table.AttributeMap") _JTableTools = jpy.get_type("io.deephaven.engine.util.TableTools") _JColumnName = jpy.get_type("io.deephaven.api.ColumnName") @@ -426,7 +426,7 @@ class Table(JObjectWrapper): data ingestion operations, queries, aggregations, joins, etc. """ - j_object_type = _J_Table + j_object_type = _JTable def __init__(self, j_table: jpy.JType): self.j_table = jpy.cast(j_table, self.j_object_type) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index c5f62bd2eb1..e7c12a06480 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -23,6 +23,7 @@ _JTableFactory = jpy.get_type("io.deephaven.engine.table.TableFactory") _JTableTools = jpy.get_type("io.deephaven.engine.util.TableTools") _JDynamicTableWriter = jpy.get_type("io.deephaven.engine.table.impl.util.DynamicTableWriter") +_JBaseArrayBackedInputTable = jpy.get_type("io.deephaven.engine.table.impl.util.BaseArrayBackedInputTable") _JAppendOnlyArrayBackedInputTable = jpy.get_type( "io.deephaven.engine.table.impl.util.AppendOnlyArrayBackedInputTable") _JKeyedArrayBackedInputTable = jpy.get_type("io.deephaven.engine.table.impl.util.KeyedArrayBackedInputTable") @@ -32,7 +33,6 @@ _JRingTableTools = jpy.get_type("io.deephaven.engine.table.impl.sources.ring.RingTableTools") _JSupplier = jpy.get_type('java.util.function.Supplier') _JFunctionGeneratedTableFactory = jpy.get_type("io.deephaven.engine.table.impl.util.FunctionGeneratedTableFactory") -_JInputTableStatusListener = jpy.get_type("io.deephaven.engine.util.input.InputTableStatusListener") def empty_table(size: int) -> Table: @@ -235,6 +235,7 @@ class InputTable(Table): Users should always create InputTables through factory methods rather than directly from the constructor. """ + j_object_type = _JBaseArrayBackedInputTable def __init__(self, j_table: jpy.JType): super().__init__(j_table) From f511609fe611a9ec2f3e909c4e8b66a39dbc2c2d Mon Sep 17 00:00:00 2001 From: arman-ddl <122062464+arman-ddl@users.noreply.github.com> Date: Tue, 12 Mar 2024 08:57:08 -0700 Subject: [PATCH 10/11] Polish pydoc Per Chip Co-authored-by: Chip Kent <5250374+chipkent@users.noreply.github.com> --- py/server/deephaven/table_factory.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index e7c12a06480..c9689b84c77 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -275,21 +275,18 @@ def delete(self, table: Table) -> None: @property def key_names(self) -> List[str]: - """The names of the key columns of the InputTable. - """ + """The names of the key columns of the InputTable.""" return j_list_to_list(self.j_input_table.getKeyNames()) @property def value_names(self) -> List[str]: - """The names of the value columns. By default, any column not marked as a key column is a value column. - - """ + """The names of the value columns. By default, any column not marked as a key column is a value column.""" return j_list_to_list(self.j_input_table.getValueNames()) def input_table(col_defs: Dict[str, DType] = None, init_table: Table = None, key_cols: Union[str, Sequence[str]] = None) -> InputTable: - """Creates an in-memory InputTable from either column definitions or initial table. When key columns are + """Creates an in-memory InputTable from either column definitions or an initial table. When key columns are provided, the InputTable will be keyed, otherwise it will be append-only. There are two types of in-memory InputTable - append-only and keyed. From 53a2e3383e83eb4dabc516753a30649a786fda1c Mon Sep 17 00:00:00 2001 From: Arman Farhangi Date: Tue, 12 Mar 2024 08:57:45 -0700 Subject: [PATCH 11/11] Remove unnecessary jpy --- py/server/deephaven/table_factory.py | 1 - 1 file changed, 1 deletion(-) diff --git a/py/server/deephaven/table_factory.py b/py/server/deephaven/table_factory.py index c5f62bd2eb1..33fd6d7c483 100644 --- a/py/server/deephaven/table_factory.py +++ b/py/server/deephaven/table_factory.py @@ -32,7 +32,6 @@ _JRingTableTools = jpy.get_type("io.deephaven.engine.table.impl.sources.ring.RingTableTools") _JSupplier = jpy.get_type('java.util.function.Supplier') _JFunctionGeneratedTableFactory = jpy.get_type("io.deephaven.engine.table.impl.util.FunctionGeneratedTableFactory") -_JInputTableStatusListener = jpy.get_type("io.deephaven.engine.util.input.InputTableStatusListener") def empty_table(size: int) -> Table: