Skip to content

Commit

Permalink
Rebase fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdunkerley committed Jan 25, 2025
1 parent 8ad8adc commit f95c03a
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void appendBulkStorage(Storage<?> storage) {
+ ". This is a bug in the Table library.");
}
} else if (storage.getType() instanceof NullType) {
appendNulls(storage.size());
appendNulls(Math.toIntExact(storage.getSize()));
} else {
throw new StorageTypeMismatchException(getType(), storage.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void appendBulkStorage(Storage<?> storage) {
+ ". This is a bug in the Table library.");
}
} else if (storage.getType() instanceof NullType) {
appendNulls(storage.size());
appendNulls(Math.toIntExact(storage.getSize()));
} else {
throw new StorageTypeMismatchException(getType(), storage.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void appendNulls(int count) {
@Override
public void appendBulkStorage(Storage<?> storage) {
if (storage.getType() instanceof NullType) {
appendNulls(storage.size());
appendNulls(Math.toIntExact(storage.getSize()));
} else {
for (long i = 0; i < storage.getSize(); i++) {
append(storage.getBoxed(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void appendNulls(int count) {
@Override
public void appendBulkStorage(Storage<?> storage) {
if (storage.getType() instanceof NullType) {
appendNulls(storage.size());
appendNulls(Math.toIntExact(storage.getSize()));
} else {
for (long i = 0; i < storage.getSize(); i++) {
append(storage.getBoxed(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void appendBulkStorage(Storage<?> storage) {
+ ". This is a bug in the Table library.");
}
} else if (storage.getType() instanceof NullType) {
appendNulls(storage.size());
appendNulls(Math.toIntExact(storage.getSize()));
} else {
throw new StorageTypeMismatchException(getType(), storage.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public void appendNulls(int count) {
public void appendBulkStorage(Storage<?> storage) {
// For any storage that is not all-null, check if non-null values are present
if (!(storage.getType() instanceof NullType)) {
for (int i = 0; i < storage.size(); i++) {
for (long i = 0; i < storage.getSize(); i++) {
if (!storage.isNothing(i)) {
throw new IllegalArgumentException(
"NullBuilder can only append nulls, but got " + storage.getItemBoxed(i));
"NullBuilder can only append nulls, but got " + storage.getBoxed(i));
}
}
}

length += storage.size();
length += Math.toIntExact(storage.getSize());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void appendBulkStorage(Storage<?> storage) {
System.arraycopy(specializedStorage.getData(), 0, data, currentSize, toCopy);
currentSize += toCopy;
} else if (storage.getType() instanceof NullType) {
appendNulls(storage.size());
appendNulls(Math.toIntExact(storage.getSize()));
} else {
long n = storage.getSize();
for (long i = 0; i < n; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void appendBulkStorage(Storage<?> storage) {
+ ". This is a bug in the Table library.");
}
} else if (storage.getType() instanceof NullType) {
appendNulls(storage.size());
appendNulls(Math.toIntExact(storage.getSize()));
} else {
throw new StorageTypeMismatchException(getType(), storage.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static long compute(ColumnStorage<?> storage, long sampleSize, Context co
if (sampleSize < size) {
var rng = new Random(RANDOM_SEED);
for (int i = 0; i < sampleSize; i++) {
long idx = rng.nextInt(Math.toIntExact(size));
long idx = rng.nextLong(size);
var val = storage.getBoxed(idx);
if (val instanceof String str && Text_Utils.has_leading_trailing_whitespace(str)) {
count++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ private NotOperation() {
@Override
public boolean canApply(ColumnStorage<?> storage) {
return storage.getType() instanceof BooleanType || storage.getType() instanceof NullType;
public boolean canApply(ColumnStorage storage) {
return storage.getType() instanceof BooleanType || storage.getType() instanceof NullType;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

/** A specialized storage that can be used by columns that contain only null values. */
public class NullStorage extends Storage<Void> {
private final int size;
private final long size;
private final MapOperationStorage<Void, NullStorage> ops = buildOps();

public NullStorage(int size) {
public NullStorage(long size) {
this.size = size;
}

@Override
public int size() {
public long getSize() {
return size;
}

Expand All @@ -39,7 +39,7 @@ public boolean isNothing(long index) {
}

@Override
public Void getItemBoxed(int idx) {
public Void getBoxed(long idx) {
return null;
}

Expand Down Expand Up @@ -170,7 +170,8 @@ public CoalescingNullOp(String name) {
@Override
public Storage<?> runBinaryMap(
NullStorage storage, Object arg, MapOperationProblemAggregator problemAggregator) {
return Storage.fromRepeatedItem(Value.asValue(arg), storage.size(), problemAggregator);
int checkedSize = Builder.checkSize(storage.getSize());
return Storage.fromRepeatedItem(Value.asValue(arg), checkedSize, problemAggregator);
}

@Override
Expand All @@ -191,10 +192,11 @@ public BoolAndNullOp(String name) {
public Storage<?> runBinaryMap(
NullStorage storage, Object arg, MapOperationProblemAggregator problemAggregator) {
if (arg == null) {
return new NullStorage(storage.size());
return new NullStorage(storage.getSize());
} else if (arg instanceof Boolean b) {
int checkedSize = Builder.checkSize(storage.getSize());
return Storage.fromRepeatedItem(
Value.asValue(doBool(b)), storage.size(), problemAggregator);
Value.asValue(doBool(b)), checkedSize, problemAggregator);
} else {
throw new UnexpectedTypeException("Boolean", arg.toString());
}
Expand All @@ -203,14 +205,14 @@ public Storage<?> runBinaryMap(
@Override
public Storage<?> runZip(
NullStorage storage, Storage<?> arg, MapOperationProblemAggregator problemAggregator) {
BuilderForBoolean builder = Builder.getForBoolean(storage.size());
for (int i = 0; i < storage.size(); i++) {
BuilderForBoolean builder = Builder.getForBoolean(storage.getSize());
for (long i = 0; i < storage.getSize(); i++) {
if (arg.isNothing(i)) {
builder.appendNulls(1);
} else if (arg.getItemBoxed(i) instanceof Boolean bool) {
} else if (arg.getBoxed(i) instanceof Boolean bool) {
builder.append(doBool(bool));
} else {
throw new UnexpectedTypeException("Boolean", arg.getItemBoxed(i).toString());
throw new UnexpectedTypeException("Boolean", arg.getBoxed(i).toString());
}
}
return builder.seal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.enso.table.data.column.operation.cast.CastProblemAggregator;
import org.enso.table.data.column.operation.cast.StorageConverter;
import org.enso.table.data.column.operation.map.MapOperationProblemAggregator;
import org.enso.table.data.column.storage.numeric.LongConstantStorage;
import org.enso.table.data.column.storage.type.IntegerType;
import org.enso.table.data.column.storage.type.StorageType;
import org.enso.table.data.mask.OrderMask;
Expand All @@ -20,9 +21,6 @@

/** An abstract representation of a data column. */
public abstract class Storage<T> implements ColumnStorage<T> {
/** A constant representing the index of a missing value in a column. */
public static final int NOT_FOUND_INDEX = -1;

@Override
public abstract long getSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public Storage<Long> applyMask(OrderMask mask) {
Context context = Context.getCurrent();
for (int i = 0; i < mask.length(); i++) {
int position = mask.get(i);
if (position == Storage.NOT_FOUND_INDEX || isNothing(position)) {
if (position == OrderMask.NOT_FOUND_INDEX || isNothing(position)) {
builder.appendNulls(1);
} else {
builder.appendLong(getPrimitive(position));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public Storage<?> parseColumn(

// If there are no values, the Auto parser would guess some random type (the first one that is
// checked). Instead, we return a Null-type column.
boolean hasNoValues = (sourceStorage.size() == 0) || CountNothing.allNothing(sourceStorage);
boolean hasNoValues = (sourceStorage.getSize() == 0) || CountNothing.allNothing(sourceStorage);
if (hasNoValues) {
return new NullStorage(sourceStorage.size());
return new NullStorage(Math.toIntExact(sourceStorage.getSize()));
}

Context context = Context.getCurrent();
Expand Down

0 comments on commit f95c03a

Please sign in to comment.