diff --git a/std-bits/table/src/main/java/org/enso/table/data/column/storage/MixedStorage.java b/std-bits/table/src/main/java/org/enso/table/data/column/storage/MixedStorage.java index c5286c82729d..ce0e7ef854bd 100644 --- a/std-bits/table/src/main/java/org/enso/table/data/column/storage/MixedStorage.java +++ b/std-bits/table/src/main/java/org/enso/table/data/column/storage/MixedStorage.java @@ -114,7 +114,8 @@ public StorageType inferPreciseTypeShrunk() { return AnyObjectType.INSTANCE; } - // If we are able to get a more specialized storage for more specific type - we delegate to its own shrinking logic. + // If we are able to get a more specialized storage for more specific type - we delegate to its + // own shrinking logic. return specialized.inferPreciseTypeShrunk(); } diff --git a/std-bits/table/src/main/java/org/enso/table/data/column/storage/Storage.java b/std-bits/table/src/main/java/org/enso/table/data/column/storage/Storage.java index b5862940cbd7..adc67afcb558 100644 --- a/std-bits/table/src/main/java/org/enso/table/data/column/storage/Storage.java +++ b/std-bits/table/src/main/java/org/enso/table/data/column/storage/Storage.java @@ -40,13 +40,13 @@ public StorageType inferPreciseType() { } /** - * Returns the smallest type (according to Column.auto_value_type rules) that may still fit all values in this - * column. - *

- * It is a sibling of `inferPreciseType` that allows some further shrinking. It is kept separate, because - * `inferPreciseType` should be quick to compute (cached if needed) as it is used in typechecking of lots of - * operations. This one however, is only used in a specific `auto_value_type` use-case and rarely will need to be - * computed more than once. + * Returns the smallest type (according to Column.auto_value_type rules) that may still fit all + * values in this column. + * + *

It is a sibling of `inferPreciseType` that allows some further shrinking. It is kept + * separate, because `inferPreciseType` should be quick to compute (cached if needed) as it is + * used in typechecking of lots of operations. This one however, is only used in a specific + * `auto_value_type` use-case and rarely will need to be computed more than once. */ public StorageType inferPreciseTypeShrunk() { return getType(); diff --git a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/AbstractLongStorage.java b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/AbstractLongStorage.java index cb25574b4836..04a00bf8b00b 100644 --- a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/AbstractLongStorage.java +++ b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/AbstractLongStorage.java @@ -1,5 +1,6 @@ package org.enso.table.data.column.storage.numeric; +import java.util.BitSet; import org.enso.table.data.column.builder.Builder; import org.enso.table.data.column.builder.NumericBuilder; import org.enso.table.data.column.operation.map.MapOperationProblemBuilder; @@ -25,8 +26,6 @@ import org.enso.table.data.column.storage.type.StorageType; import org.graalvm.polyglot.Context; -import java.util.BitSet; - public abstract class AbstractLongStorage extends NumericStorage { public abstract long getItem(int idx); @@ -87,17 +86,15 @@ public StorageType inferPreciseType() { @Override public StorageType inferPreciseTypeShrunk() { - // If the type is already smallest possible, we return it unchanged (we will return 8-bit columns as-is, although + // If the type is already smallest possible, we return it unchanged (we will return 8-bit + // columns as-is, although // we will not shrink 16-bit columns to 8-bits even if it were possible). if (getType().bits().toInteger() <= 16) { return getType(); } - IntegerType[] possibleTypes = new IntegerType[] { - IntegerType.INT_16, - IntegerType.INT_32, - IntegerType.INT_64 - }; + IntegerType[] possibleTypes = + new IntegerType[] {IntegerType.INT_16, IntegerType.INT_32, IntegerType.INT_64}; int currentTypeIdx = 0; int n = size(); diff --git a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/BigIntegerStorage.java b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/BigIntegerStorage.java index 76626b54126a..be5cb195df3a 100644 --- a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/BigIntegerStorage.java +++ b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/BigIntegerStorage.java @@ -120,7 +120,8 @@ public StorageType inferPreciseType() { } } - inferredType = (allFitInLong && visitedCount > 0) ? IntegerType.INT_64 : BigIntegerType.INSTANCE; + inferredType = + (allFitInLong && visitedCount > 0) ? IntegerType.INT_64 : BigIntegerType.INSTANCE; } return inferredType; @@ -143,17 +144,18 @@ private StorageType findSmallestIntegerTypeThatFits() { final BigIntegerStorage parent = this; // We create a Long storage that gets values by converting our storage. - ComputedNullableLongStorage longAdapter = new ComputedNullableLongStorage(size) { - @Override - protected Long computeItem(int idx) { - BigInteger bigInteger = parent.getItem(idx); - if (bigInteger == null) { - return null; - } - - return bigInteger.longValueExact(); - } - }; + ComputedNullableLongStorage longAdapter = + new ComputedNullableLongStorage(size) { + @Override + protected Long computeItem(int idx) { + BigInteger bigInteger = parent.getItem(idx); + if (bigInteger == null) { + return null; + } + + return bigInteger.longValueExact(); + } + }; // And rely on its shrinking logic. return longAdapter.inferPreciseTypeShrunk(); diff --git a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/ComputedNullableLongStorage.java b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/ComputedNullableLongStorage.java index 731bf2eaf669..835c41972553 100644 --- a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/ComputedNullableLongStorage.java +++ b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/ComputedNullableLongStorage.java @@ -1,5 +1,7 @@ package org.enso.table.data.column.storage.numeric; +import java.util.BitSet; +import java.util.List; import org.enso.table.data.column.storage.Storage; import org.enso.table.data.column.storage.type.IntegerType; import org.enso.table.data.index.Index; @@ -7,13 +9,11 @@ import org.enso.table.data.mask.SliceRange; import org.graalvm.polyglot.Context; -import java.util.BitSet; -import java.util.List; - /** * Implements a storage that computes the ith stored value using some function. * - *

This storage allows for missing values. Prefer {@link ComputedLongStorage} for non-nullable case. + *

This storage allows for missing values. Prefer {@link ComputedLongStorage} for non-nullable + * case. */ public abstract class ComputedNullableLongStorage extends AbstractLongStorage { protected final int size; diff --git a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/DoubleStorage.java b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/DoubleStorage.java index 5d3aba45996e..8159aac377dc 100644 --- a/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/DoubleStorage.java +++ b/std-bits/table/src/main/java/org/enso/table/data/column/storage/numeric/DoubleStorage.java @@ -435,18 +435,20 @@ private StorageType findSmallestIntegerTypeThatFits() { final DoubleStorage parent = this; // We create a Long storage that gets values by converting our storage. - ComputedNullableLongStorage longAdapter = new ComputedNullableLongStorage(size) { - @Override - protected Long computeItem(int idx) { - if (parent.isNa(idx)) { - return null; - } - - double value = parent.getItem(idx); - assert value % 1.0 == 0.0 : "The value " + value + " should be a whole number (guaranteed by checks)."; - return (long) value; - } - }; + ComputedNullableLongStorage longAdapter = + new ComputedNullableLongStorage(size) { + @Override + protected Long computeItem(int idx) { + if (parent.isNa(idx)) { + return null; + } + + double value = parent.getItem(idx); + assert value % 1.0 == 0.0 + : "The value " + value + " should be a whole number (guaranteed by checks)."; + return (long) value; + } + }; // And rely on its shrinking logic. return longAdapter.inferPreciseTypeShrunk();