Skip to content

Commit

Permalink
Basically complete.
Browse files Browse the repository at this point in the history
Still to rename back getBoxed and getPrimitive.
Failing 10 tests.
Rebase next.
  • Loading branch information
jdunkerley committed Jan 24, 2025
1 parent be0e32d commit 66e54f1
Show file tree
Hide file tree
Showing 35 changed files with 130 additions and 187 deletions.
2 changes: 1 addition & 1 deletion distribution/lib/Standard/Table/0.0.0-dev/src/Column.enso
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ type Column
to_js_object self =
name = self.java_column.getName
storage = self.java_column.getStorage
storage_proxy = Array_Proxy.new storage.size i-> storage.getBoxed i
storage_proxy = Array_Proxy.new storage.getSize i-> storage.getBoxed i
storage_json = Vector.from_polyglot_array storage_proxy
JS_Object.from_pairs [["name", name], ["data", storage_json]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ map_over_storage : Column -> (Any -> Text) -> (Integer -> Any) -> Boolean -> Pro
map_over_storage input_column function builder skip_nothing=True on_problems:Problem_Behavior=..Report_Warning =
problem_builder = Problem_Builder.new
input_storage = input_column.java_column.getStorage
num_input_rows = input_storage.size
num_input_rows = input_storage.getSize
output_storage_builder = builder num_input_rows
0.up_to num_input_rows . each i->
input_value = input_storage.getBoxed i
Expand All @@ -33,12 +33,12 @@ map_2_over_storage : Column -> Column -> (Any -> Any -> Text) -> (Integer -> Any
map_2_over_storage input_column_0 input_column_1 function builder skip_nothing=True =
input_storage_0 = input_column_0.java_column.getStorage
input_storage_1 = input_column_1.java_column.getStorage
case input_storage_0.size != input_storage_1.size of
case input_storage_0.getSize != input_storage_1.getSize of
True ->
msg = "Column lengths differ: " + input_storage_0.size.to_text + " != " + input_storage_1.size.to_text
msg = "Column lengths differ: " + input_storage_0.getSize.to_text + " != " + input_storage_1.getSize.to_text
Error.throw (Illegal_Argument.Error msg)
False ->
num_input_rows = input_storage_0.size
num_input_rows = input_storage_0.getSize
output_storage_builder = builder num_input_rows
ok = 0.up_to num_input_rows . each_propagate i->
input_value_0 = input_storage_0.getBoxed i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fan_out_to_rows_and_columns table input_column_id function column_names at_least
fan_out_to_rows_and_columns_fixed : Any -> (Any -> Vector (Vector Any)) -> Boolean -> Vector Text -> (Integer -> Any) -> Problem_Builder -> Vector
fan_out_to_rows_and_columns_fixed input_storage function at_least_one_row:Boolean column_names:Vector column_builder problem_builder =
num_output_columns = column_names.length
num_input_rows = input_storage.size
num_input_rows = input_storage.getSize

# Accumulates the outputs of the function.
output_column_builders = Vector.new num_output_columns _-> column_builder num_input_rows
Expand Down Expand Up @@ -176,7 +176,7 @@ fan_out_to_rows_and_columns_dynamic input_storage function at_least_one_row colu
output_column_builders = Builder.new

# Guess that most of the time, we'll get at least one value for each input.
num_input_rows = input_storage.size
num_input_rows = input_storage.getSize

# Column Builder add function
add_column n current_length =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ make_long_builder initial_size bits java_problem_aggregator=(Missing_Argument.en
make_string_builder : Integer -> Value_Type -> Builder
make_string_builder initial_size value_type=Value_Type.Char =
storage_type = Storage.from_value_type_strict value_type
Builder.getForType storage_type initial_size Nothing
Builder.getForText initial_size storage_type

## PRIVATE
make_inferred_builder : Integer -> ProblemAggregator -> Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public static Table runReport(

var builders = new Builder[dimensions.size() + metrics.size()];
for (int i = 0; i < dimensions.size() + metrics.size(); i++) {
builders[i] = Builder.getForType(TextType.VARIABLE_LENGTH, rowCount, null);
builders[i] = Builder.getForText(rowCount, TextType.VARIABLE_LENGTH);
}

// Load the data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public Sum(String name, Column column) {
public Builder makeBuilder(int size, ProblemAggregator problemAggregator) {
return switch (inputType) {
case IntegerType integerType -> new InferredIntegerBuilder(size, problemAggregator);
case BigIntegerType bigIntegerType -> Builder.getForType(
bigIntegerType, size, problemAggregator);
case BigIntegerType bigIntegerType -> Builder.getForBigInteger(size, problemAggregator);
case FloatType floatType -> Builder.getForDouble(floatType, size, problemAggregator);
default -> throw new IllegalStateException(
"Unexpected input type for Sum aggregate: " + inputType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Builder retypeTo(StorageType type) {
return res;
}
case BigDecimalType _ -> {
var res = Builder.getForType(type, data.length, problemAggregator);
var res = Builder.getForBigDecimal(data.length);
for (int i = 0; i < currentSize; i++) {
if (data[i] == null) {
res.appendNulls(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ private void initBuilderFor(Object o) {
} else if (NumericConverter.isFloatLike(o)) {
newBuilder = new InferredDoubleBuilder(initialCapacity, problemAggregator);
} else if (o instanceof String) {
newBuilder = Builder.getForType(TextType.VARIABLE_LENGTH, initialCapacity, problemAggregator);
newBuilder = Builder.getForText(initialCapacity, TextType.VARIABLE_LENGTH);
} else if (o instanceof BigInteger) {
newBuilder = Builder.getForType(BigIntegerType.INSTANCE, initialCapacity, problemAggregator);
newBuilder = Builder.getForBigInteger(initialCapacity, problemAggregator);
} else if (o instanceof BigDecimal) {
newBuilder = Builder.getForType(BigDecimalType.INSTANCE, initialCapacity, problemAggregator);
newBuilder = Builder.getForBigDecimal(initialCapacity);
} else if (o instanceof LocalDate) {
newBuilder =
allowDateToDateTimeConversion
? new DateBuilder(initialCapacity, true)
: Builder.getForType(DateType.INSTANCE, initialCapacity, problemAggregator);
: Builder.getForDate(initialCapacity);
} else if (o instanceof ZonedDateTime) {
newBuilder =
allowDateToDateTimeConversion
? new DateTimeBuilder(initialCapacity, true)
: Builder.getForType(DateTimeType.INSTANCE, initialCapacity, problemAggregator);
: Builder.getForDateTime(initialCapacity);
} else if (o instanceof LocalTime) {
newBuilder = Builder.getForType(TimeOfDayType.INSTANCE, initialCapacity, problemAggregator);
newBuilder = Builder.getForTime(initialCapacity);
} else {
newBuilder = Builder.getForType(AnyObjectType.INSTANCE, initialCapacity, problemAggregator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public boolean canRetypeTo(StorageType type) {
@Override
public Builder retypeTo(StorageType type) {
if (type instanceof BigDecimalType) {
Builder res = Builder.getForType(BigDecimalType.INSTANCE, data.length, null);
Builder res = Builder.getForBigDecimal(data.length);
for (int i = 0; i < currentSize; i++) {
if (isNothing.get(i)) {
res.appendNulls(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.enso.table.data.column.storage.type.FloatType;
import org.enso.table.data.column.storage.type.IntegerType;
import org.enso.table.error.UnexpectedTypeException;
import org.enso.table.problems.BlackholeProblemAggregator;
import org.graalvm.polyglot.Context;

/** An operation expecting a numeric argument and returning a numeric column. */
Expand Down Expand Up @@ -276,7 +277,7 @@ protected Storage<BigInteger> runBigIntegerZip(
Context context = Context.getCurrent();
int n = a.size();
int m = Math.min(a.size(), b.size());
var builder = Builder.getForBigInteger(n, null);
var builder = Builder.getForBigInteger(n, BlackholeProblemAggregator.INSTANCE);
for (int i = 0; i < m; i++) {
BigInteger x = a.getItem(i);
BigInteger y = b.getItem(i);
Expand All @@ -297,7 +298,7 @@ protected Storage<BigInteger> runBigIntegerMap(
BigIntegerArrayAdapter a, BigInteger b, MapOperationProblemAggregator problemAggregator) {
Context context = Context.getCurrent();
int n = a.size();
var builder = Builder.getForBigInteger(n, null);
var builder = Builder.getForBigInteger(n, BlackholeProblemAggregator.INSTANCE);
for (int i = 0; i < n; i++) {
BigInteger x = a.getItem(i);
if (x == null || b == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.enso.table.data.column.storage.Storage;
import org.enso.table.data.column.storage.numeric.AbstractLongStorage;
import org.enso.table.data.column.storage.numeric.BigIntegerStorage;
import org.enso.table.problems.BlackholeProblemAggregator;

public interface BigIntegerArrayAdapter {
BigInteger getItem(int i);
Expand All @@ -14,7 +15,7 @@ public interface BigIntegerArrayAdapter {

default Storage<BigInteger> intoStorage() {
int n = size();
var builder = Builder.getForBigInteger(n, null);
var builder = Builder.getForBigInteger(n, BlackholeProblemAggregator.INSTANCE);
for (int i = 0; i < n; i++) {
builder.append(getItem(i));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.enso.table.data.column.storage.numeric.BigIntegerStorage;
import org.enso.table.data.column.storage.numeric.DoubleStorage;
import org.enso.table.data.column.storage.type.FloatType;
import org.enso.table.problems.BlackholeProblemAggregator;

public interface DoubleArrayAdapter {
double getItemAsDouble(int i);
Expand All @@ -19,7 +20,7 @@ public interface DoubleArrayAdapter {

default Storage<Double> intoStorage() {
int n = size();
var builder = Builder.getForDouble(FloatType.FLOAT_64, n, null);
var builder = Builder.getForDouble(FloatType.FLOAT_64, n, BlackholeProblemAggregator.INSTANCE);
for (int i = 0; i < n; i++) {
if (isNothing(i)) {
builder.appendNulls(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public CoalescingStringStringOp(String name) {
}

@Override
public Storage<?> runBinaryMap(
public Storage<String> runBinaryMap(
SpecializedStorage<String> storage,
Object arg,
MapOperationProblemAggregator problemAggregator) {
Expand Down Expand Up @@ -45,7 +45,7 @@ public Storage<?> runBinaryMap(
}

@Override
public Storage<?> runZip(
public Storage<String> runZip(
SpecializedStorage<String> storage,
Storage<?> arg,
MapOperationProblemAggregator problemAggregator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.enso.table.data.column.operation.map.MapOperationProblemAggregator;
import org.enso.table.data.column.storage.ColumnStorage;
import org.enso.table.data.column.storage.type.DateTimeType;
import org.enso.table.data.column.storage.type.DateType;

public class DateTruncateOperation extends AbstractUnaryOperation {
public static String TRUNCATE = "truncate";
Expand All @@ -24,7 +23,7 @@ public boolean canApply(ColumnStorage<?> storage) {
@Override
protected Builder createBuilder(
ColumnStorage<?> storage, MapOperationProblemAggregator problemAggregator) {
return Builder.getForType(DateType.INSTANCE, storage.getSize(), problemAggregator);
return Builder.getForDate(storage.getSize());
}

@Override
Expand Down
Loading

0 comments on commit 66e54f1

Please sign in to comment.