From 3d9b603d5aba5c52e4740d6c0a65e706bec79502 Mon Sep 17 00:00:00 2001 From: Cristian Ferretti Date: Thu, 26 Aug 2021 17:28:26 -0400 Subject: [PATCH 1/3] Disambiguate DynamicTableWriter constructors taking an array from the point of view of jpy. --- .../db/v2/utils/AsyncErrorLogger.java | 19 +++++++++++--- .../db/v2/utils/DynamicTableWriter.java | 25 ++++++++----------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java b/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java index ad2dace6ad6..ced86e01f01 100644 --- a/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java +++ b/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java @@ -4,6 +4,9 @@ package io.deephaven.db.v2.utils; +import io.deephaven.qst.column.header.ColumnHeader; +import io.deephaven.qst.table.TableHeader; +import io.deephaven.qst.type.Type; import io.deephaven.tablelogger.RowSetter; import io.deephaven.db.tables.utils.DBDateTime; import io.deephaven.db.v2.DynamicTable; @@ -14,10 +17,18 @@ public class AsyncErrorLogger { private static final DynamicTableWriter tableWriter = new DynamicTableWriter( - new String[] {"Time", "EvaluationNumber", "OperationNumber", "Description", "SourceQueryEvaluationNumber", - "SourceQueryOperationNumber", "SourceQueryDescription", "Cause", "WorkerName", "HostName"}, - new Class[] {DBDateTime.class, int.class, int.class, String.class, int.class, int.class, String.class, - Exception.class, String.class, String.class}); + TableHeader.of( + ColumnHeader.ofInstant("Time"), + ColumnHeader.ofInt("EvaluationNumber"), + ColumnHeader.ofInt("OperationNumber"), + ColumnHeader.ofString("Description"), + ColumnHeader.ofInt("SourceQueryEvaluationNumber"), + ColumnHeader.ofInt("SourceQueryOperationNumber"), + ColumnHeader.ofString("SourceQueryDescription"), + ColumnHeader.of("Cause", Type.ofCustom(Exception.class)), + ColumnHeader.ofString("WorkerName"), + ColumnHeader.ofString("HostName") + )); private static final RowSetter timeSetter = tableWriter.getSetter("Time"); private static final RowSetter evaluationNumberSetter = tableWriter.getSetter("EvaluationNumber"); private static final RowSetter operationNumberSetter = tableWriter.getSetter("OperationNumber"); diff --git a/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java b/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java index 994b6954a17..2da5f8aa992 100644 --- a/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java +++ b/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java @@ -63,15 +63,12 @@ public DynamicTableWriter(final TableHeader header) { this(header, Collections.emptyMap()); } - /** - * Creates a TableWriter that produces an in-memory table using the provided column names and types. - * - * @param columnNames the names of the columns in the output table (and our input) - * @param columnTypes the types of the columns in the output table (must be compatible with the input) - * @param constantValues a Map of columns with constant values - */ + // This constructor is no longer public to simplify access from python: jpy cannot resolve + // calls with arguments of list type when there is more than one alternative with array element type + // on the java side. Prefer the constructor taking qst.table.TableHeader or an array of qst.type.Type + // objects. @SuppressWarnings("WeakerAccess") - public DynamicTableWriter( + DynamicTableWriter( final String[] columnNames, final Class[] columnTypes, final Map constantValues) { @@ -93,13 +90,11 @@ public DynamicTableWriter( this(columnNames, (int i) -> columnTypes[i].clazz(), constantValues); } - /** - * Creates a TableWriter that produces an in-memory table using the provided column names and types. - * - * @param columnNames the names of the columns in the output table (and our input) - * @param columnTypes the types of the columns in the output table (must be compatible with the input) - */ - public DynamicTableWriter(final String[] columnNames, final Class[] columnTypes) { + // This constructor is no longer public to simplify access from python: jpy cannot resolve + // calls with arguments of list type when there is more than one alternative with array element type + // on the java side. Prefer the constructor taking qst.table.TableHeader or an array of qst.type.Type + // objects. + DynamicTableWriter(final String[] columnNames, final Class[] columnTypes) { this(columnNames, columnTypes, Collections.emptyMap()); } From 5facf4e3471c4618110882339bed9a4f9ec6132d Mon Sep 17 00:00:00 2001 From: Cristian Ferretti Date: Thu, 26 Aug 2021 17:41:19 -0400 Subject: [PATCH 2/3] Followup to review comments. --- .../main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java b/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java index ced86e01f01..3e143a05637 100644 --- a/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java +++ b/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java @@ -6,7 +6,6 @@ import io.deephaven.qst.column.header.ColumnHeader; import io.deephaven.qst.table.TableHeader; -import io.deephaven.qst.type.Type; import io.deephaven.tablelogger.RowSetter; import io.deephaven.db.tables.utils.DBDateTime; import io.deephaven.db.v2.DynamicTable; @@ -18,14 +17,14 @@ public class AsyncErrorLogger { private static final DynamicTableWriter tableWriter = new DynamicTableWriter( TableHeader.of( - ColumnHeader.ofInstant("Time"), + ColumnHeader.of("Time", DBDateTime.class), ColumnHeader.ofInt("EvaluationNumber"), ColumnHeader.ofInt("OperationNumber"), ColumnHeader.ofString("Description"), ColumnHeader.ofInt("SourceQueryEvaluationNumber"), ColumnHeader.ofInt("SourceQueryOperationNumber"), ColumnHeader.ofString("SourceQueryDescription"), - ColumnHeader.of("Cause", Type.ofCustom(Exception.class)), + ColumnHeader.of("Cause", Exception.class), ColumnHeader.ofString("WorkerName"), ColumnHeader.ofString("HostName") )); From 92bb67dc09be8f2c0a20f90af5b9d7a7163778d6 Mon Sep 17 00:00:00 2001 From: Cristian Ferretti Date: Thu, 26 Aug 2021 17:58:21 -0400 Subject: [PATCH 3/3] Spotlessfy. --- .../main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java | 3 +-- .../java/io/deephaven/db/v2/utils/DynamicTableWriter.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java b/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java index 3e143a05637..85f01c41f85 100644 --- a/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java +++ b/DB/src/main/java/io/deephaven/db/v2/utils/AsyncErrorLogger.java @@ -26,8 +26,7 @@ public class AsyncErrorLogger { ColumnHeader.ofString("SourceQueryDescription"), ColumnHeader.of("Cause", Exception.class), ColumnHeader.ofString("WorkerName"), - ColumnHeader.ofString("HostName") - )); + ColumnHeader.ofString("HostName"))); private static final RowSetter timeSetter = tableWriter.getSetter("Time"); private static final RowSetter evaluationNumberSetter = tableWriter.getSetter("EvaluationNumber"); private static final RowSetter operationNumberSetter = tableWriter.getSetter("OperationNumber"); diff --git a/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java b/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java index 2da5f8aa992..52101b32511 100644 --- a/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java +++ b/DB/src/main/java/io/deephaven/db/v2/utils/DynamicTableWriter.java @@ -65,7 +65,7 @@ public DynamicTableWriter(final TableHeader header) { // This constructor is no longer public to simplify access from python: jpy cannot resolve // calls with arguments of list type when there is more than one alternative with array element type - // on the java side. Prefer the constructor taking qst.table.TableHeader or an array of qst.type.Type + // on the java side. Prefer the constructor taking qst.table.TableHeader or an array of qst.type.Type // objects. @SuppressWarnings("WeakerAccess") DynamicTableWriter( @@ -92,7 +92,7 @@ public DynamicTableWriter( // This constructor is no longer public to simplify access from python: jpy cannot resolve // calls with arguments of list type when there is more than one alternative with array element type - // on the java side. Prefer the constructor taking qst.table.TableHeader or an array of qst.type.Type + // on the java side. Prefer the constructor taking qst.table.TableHeader or an array of qst.type.Type // objects. DynamicTableWriter(final String[] columnNames, final Class[] columnTypes) { this(columnNames, columnTypes, Collections.emptyMap());