You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a circular dependency between singleton fields in ColumnType and singleton fields in its implementations. This makes correct initialization impossible.
Observe the following peculiar behavior (using Scala REPL for ease of illustration; eq in Scala is == in Java, i.e. reference equality):
This fails because static init of ColumnType is called from within static init of DoubleColumnType, while DoubleColumnType.INSTANCE field is still null, so ColumnType.DOUBLE receives a new instance from here, instead of the singleton value that eventually ends up in DoubleColumnType.INSTANCE field.
Let's try the other way:
>import$ivy.`tech.tablesaw:tablesaw-core:0.43.1`> assert(tech.tablesaw.api.ColumnType.DOUBLE eq tech.tablesaw.columns.numbers.DoubleColumnType.instance())
// yay no error! but...> tech.tablesaw.columns.numbers.DoubleColumnType.DEFAULT_PARSER.columnType()
res2:ColumnType=null
Now static init of DoubleColumnType is called from within static init of ColumnType, while ColumnType.DOUBLE is still null, so we get null here.
This breaks tablesaw-parquet here because it's doing reference equality comparisons.
>import$ivy.`tech.tablesaw:tablesaw-core:0.43.1`>import$ivy.`net.tlabs-data:tablesaw_0.43.1-parquet:0.10.1`>valtable= tech.tablesaw.api.Table.create("t").addColumns(tech.tablesaw.api.DoubleColumn.create("c", 1, 2, 3))
>new net.tlabs.tablesaw.parquet.TablesawParquetWriter().write(table, net.tlabs.tablesaw.parquet.TablesawParquetWriteOptions.builder("test.parquet").build())
java.lang.NullPointerException:Cannot invoke "tech.tablesaw.api.DoubleColumn.getDouble(int)" because "this.doubleColumns[colIndex]" is null
net.tlabs.tablesaw.parquet.TableProxy.getDouble(TableProxy.java:225)
I am not sure what is the correct solution here. Should tablesaw-parquet not assume singleton instances and use equals instead of ==? I am guessing most things are generally working because in most cases DoubleColumnType.instance() will run first, causing DoubleColumnType.instance() and ColumnType.DOUBLE to have different instances, but nothing getting null value.
There is a circular dependency between singleton fields in ColumnType and singleton fields in its implementations. This makes correct initialization impossible.
Observe the following peculiar behavior (using Scala REPL for ease of illustration;
eq
in Scala is==
in Java, i.e. reference equality):This fails because static init of
ColumnType
is called from within static init ofDoubleColumnType
, whileDoubleColumnType.INSTANCE
field is still null, soColumnType.DOUBLE
receives a new instance from here, instead of the singleton value that eventually ends up inDoubleColumnType.INSTANCE
field.Let's try the other way:
Now static init of
DoubleColumnType
is called from within static init ofColumnType
, whileColumnType.DOUBLE
is still null, so we get null here.This breaks tablesaw-parquet here because it's doing reference equality comparisons.
I am not sure what is the correct solution here. Should tablesaw-parquet not assume singleton instances and use
equals
instead of==
? I am guessing most things are generally working because in most casesDoubleColumnType.instance()
will run first, causingDoubleColumnType.instance()
andColumnType.DOUBLE
to have different instances, but nothing getting null value.Possibly similar to #430.
The text was updated successfully, but these errors were encountered: