Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ private boolean handle(Key key) {
jumpCol(totalCols - 1);
yield true;
}
case Key.Char c when c.value() == 'g' -> {
case Key.Char(var value) when value == 'g' -> {
jumpRow(0);
yield true;
}
case Key.Char c when c.value() == 'G' -> {
case Key.Char(var value) when value == 'G' -> {
jumpRow(totalRows - 1);
yield true;
}
case Key.Char c when c.value() == 'q' -> false;
case Key.Char(var value) when value == 'q' -> false;
case Key.Escape _ -> false;
case Key.Eof _ -> false;
default -> true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private static boolean isMaskable(DType dt) {
// Bool nullable not yet wired (no Bool inner encoding on MaskedEncoding fallback).
return switch (dt) {
case DType.Primitive p -> p.nullable();
case DType.Utf8 u -> u.nullable();
case DType.Utf8(var nullable) -> nullable;
default -> false;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ private PredicateEvaluator() {
/// @return `true` if the value at `i` satisfies `predicate`
static boolean evaluate(Array array, long i, Predicate predicate) {
return switch (predicate) {
case Predicate.Eq eq -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), eq.value(), array.dtype()) == 0;
case Predicate.Neq neq -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), neq.value(), array.dtype()) != 0;
case Predicate.Lt lt -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), lt.value(), array.dtype()) < 0;
case Predicate.Gt gt -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), gt.value(), array.dtype()) > 0;
case Predicate.Lte lte -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), lte.value(), array.dtype()) <= 0;
case Predicate.Gte gte -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), gte.value(), array.dtype()) >= 0;
case Predicate.Eq(var value) -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), value, array.dtype()) == 0;
case Predicate.Neq(var value) -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), value, array.dtype()) != 0;
case Predicate.Lt(var value) -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), value, array.dtype()) < 0;
case Predicate.Gt(var value) -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), value, array.dtype()) > 0;
case Predicate.Lte(var value) -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), value, array.dtype()) <= 0;
case Predicate.Gte(var value) -> !Values.isNullAt(array, i)
&& Compare.values(Values.valueAt(array, i), value, array.dtype()) >= 0;
case Predicate.Between between -> evaluateBetween(array, i, between);
case Predicate.IsNull _ -> Values.isNullAt(array, i);
case Predicate.IsNotNull _ -> !Values.isNullAt(array, i);
case Predicate.And and -> evaluate(array, i, and.left()) && evaluate(array, i, and.right());
case Predicate.Or or -> evaluate(array, i, or.left()) || evaluate(array, i, or.right());
case Predicate.And(var left, var right) -> evaluate(array, i, left) && evaluate(array, i, right);
case Predicate.Or(var left, var right) -> evaluate(array, i, left) || evaluate(array, i, right);
};
}

Expand Down
40 changes: 20 additions & 20 deletions writer/src/main/java/io/github/dfa1/vortex/writer/VortexWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,44 +300,44 @@ private static int serializeDType(FbsBuilder fbb, DType dtype) {
int inner = io.github.dfa1.vortex.core.fbs.FbsNull.endFbsNull(fbb);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsNull, inner);
}
case DType.Bool b -> {
int inner = io.github.dfa1.vortex.core.fbs.FbsBool.createFbsBool(fbb, b.nullable());
case DType.Bool(var nullable) -> {
int inner = io.github.dfa1.vortex.core.fbs.FbsBool.createFbsBool(fbb, nullable);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsBool, inner);
}
case DType.Primitive p -> {
case DType.Primitive(var ptype, var nullable) -> {
int inner = io.github.dfa1.vortex.core.fbs.FbsPrimitive.createFbsPrimitive(
fbb, p.ptype().ordinal(), p.nullable());
fbb, ptype.ordinal(), nullable);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsPrimitive, inner);
}
case DType.Struct s -> {
case DType.Struct(var fieldNames, var fieldTypes, var nullable) -> {
// Build child DType tables first (FlatBuffers bottom-up requirement)
int[] fieldOffsets = new int[s.fieldTypes().size()];
int[] fieldOffsets = new int[fieldTypes.size()];
for (int i = 0; i < fieldOffsets.length; i++) {
fieldOffsets[i] = serializeDType(fbb, s.fieldTypes().get(i));
fieldOffsets[i] = serializeDType(fbb, fieldTypes.get(i));
}
int[] nameOffsets = new int[s.fieldNames().size()];
int[] nameOffsets = new int[fieldNames.size()];
for (int i = 0; i < nameOffsets.length; i++) {
nameOffsets[i] = fbb.createString(s.fieldNames().get(i).value());
nameOffsets[i] = fbb.createString(fieldNames.get(i).value());
}
int namesVec = io.github.dfa1.vortex.core.fbs.FbsStruct_.createNamesVector(fbb, nameOffsets);
int dtypesVec = io.github.dfa1.vortex.core.fbs.FbsStruct_.createDtypesVector(fbb, fieldOffsets);
int inner = io.github.dfa1.vortex.core.fbs.FbsStruct_.createFbsStruct_(
fbb, namesVec, dtypesVec, s.nullable());
fbb, namesVec, dtypesVec, nullable);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsStruct_, inner);
}
case DType.Utf8 u -> {
int inner = io.github.dfa1.vortex.core.fbs.FbsUtf8.createFbsUtf8(fbb, u.nullable());
case DType.Utf8(var nullable) -> {
int inner = io.github.dfa1.vortex.core.fbs.FbsUtf8.createFbsUtf8(fbb, nullable);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsUtf8, inner);
}
case DType.List l -> {
int elemTypeOff = serializeDType(fbb, l.elementType());
int inner = io.github.dfa1.vortex.core.fbs.FbsList.createFbsList(fbb, elemTypeOff, l.nullable());
case DType.List(var elementType, var nullable) -> {
int elemTypeOff = serializeDType(fbb, elementType);
int inner = io.github.dfa1.vortex.core.fbs.FbsList.createFbsList(fbb, elemTypeOff, nullable);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsList, inner);
}
case DType.FixedSizeList fsl -> {
int elemTypeOff = serializeDType(fbb, fsl.elementType());
case DType.FixedSizeList(var elementType, var fixedSize, var nullable) -> {
int elemTypeOff = serializeDType(fbb, elementType);
int inner = io.github.dfa1.vortex.core.fbs.FbsFixedSizeList.createFbsFixedSizeList(
fbb, elemTypeOff, fsl.fixedSize(), fsl.nullable());
fbb, elemTypeOff, fixedSize, nullable);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsFixedSizeList, inner);
}
case DType.Extension e -> {
Expand All @@ -351,8 +351,8 @@ private static int serializeDType(FbsBuilder fbb, DType dtype) {
int inner = FbsExtension.createFbsExtension(fbb, idOff, storageDtypeOff, metaOff);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsExtension, inner);
}
case DType.Variant v -> {
int inner = io.github.dfa1.vortex.core.fbs.FbsVariant.createFbsVariant(fbb, v.nullable());
case DType.Variant(var nullable) -> {
int inner = io.github.dfa1.vortex.core.fbs.FbsVariant.createFbsVariant(fbb, nullable);
yield io.github.dfa1.vortex.core.fbs.FbsDType.createFbsDType(fbb, FbsType.FbsVariant, inner);
}
default -> throw new UnsupportedOperationException("unsupported DType: " + dtype);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public CascadingCompressor(List<EncodingEncoder> encodings) {

private static int dataLength(Object data) {
return switch (data) {
case StructData sd -> sd.fieldArrays().isEmpty() ? 0 : dataLength(sd.fieldArrays().getFirst());
case StructData(var fieldArrays) -> fieldArrays.isEmpty() ? 0 : dataLength(fieldArrays.getFirst());
case byte[] a -> a.length;
case short[] a -> a.length;
case int[] a -> a.length;
Expand All @@ -48,8 +48,8 @@ private static int dataLength(Object data) {
/// Falls back to first-N when the data is short enough for one stride to span it.
private static Object stratifiedSample(Object data, int sampleSize, long seed) {
return switch (data) {
case StructData sd -> {
List<Object> sliced = sd.fieldArrays().stream()
case StructData(var fieldArrays) -> {
List<Object> sliced = fieldArrays.stream()
.map(f -> stratifiedSample(f, sampleSize, seed)).toList();
yield new StructData(sliced);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public boolean accepts(DType dtype) {

@Override
public EncodeResult encode(DType dtype, Object data, EncodeContext ctx) {
if (!(data instanceof NullableData nd)) {
if (!(data instanceof NullableData(var values, var validity))) {
throw new VortexException(EncodingId.VORTEX_MASKED,
"expected NullableData, got " + (data == null ? "null" : data.getClass().getName()));
}
DType nonNullable = dtype.withNullable(false);
EncodingEncoder inner = pickInner(nonNullable);
EncodeResult valuesResult = inner.encode(nonNullable, nd.values(), ctx);
EncodeResult validityResult = new BoolEncodingEncoder().encode(DType.BOOL, nd.validity(), ctx);
EncodeResult valuesResult = inner.encode(nonNullable, values, ctx);
EncodeResult validityResult = new BoolEncodingEncoder().encode(DType.BOOL, validity, ctx);

int valuesBufCount = valuesResult.buffers().size();
EncodeNode validityNode = EncodeNode.remapBufferIndices(validityResult.rootNode(), valuesBufCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ private static EncodeNode encodeShredded(VariantData data, EncodeContext ctx, Li
/// Converts a shreddable scalar dtype to its protobuf form for `ProtoVariantMetadata`.
private static io.github.dfa1.vortex.core.proto.ProtoDType toProtoDtype(DType dtype) {
return switch (dtype) {
case DType.Primitive p -> io.github.dfa1.vortex.core.proto.ProtoDType.ofPrimitive(
case DType.Primitive(var ptype, var nullable) -> io.github.dfa1.vortex.core.proto.ProtoDType.ofPrimitive(
new io.github.dfa1.vortex.core.proto.ProtoPrimitive(
io.github.dfa1.vortex.core.proto.ProtoPType.fromValue(p.ptype().ordinal()), p.nullable()));
case DType.Bool b -> io.github.dfa1.vortex.core.proto.ProtoDType.ofBool(
new io.github.dfa1.vortex.core.proto.ProtoBool(b.nullable()));
case DType.Utf8 u -> io.github.dfa1.vortex.core.proto.ProtoDType.ofUtf8(
new io.github.dfa1.vortex.core.proto.ProtoUtf8(u.nullable()));
case DType.Binary bin -> io.github.dfa1.vortex.core.proto.ProtoDType.ofBinary(
new io.github.dfa1.vortex.core.proto.ProtoBinary(bin.nullable()));
io.github.dfa1.vortex.core.proto.ProtoPType.fromValue(ptype.ordinal()), nullable));
case DType.Bool(var nullable) -> io.github.dfa1.vortex.core.proto.ProtoDType.ofBool(
new io.github.dfa1.vortex.core.proto.ProtoBool(nullable));
case DType.Utf8(var nullable) -> io.github.dfa1.vortex.core.proto.ProtoDType.ofUtf8(
new io.github.dfa1.vortex.core.proto.ProtoUtf8(nullable));
case DType.Binary(var nullable) -> io.github.dfa1.vortex.core.proto.ProtoDType.ofBinary(
new io.github.dfa1.vortex.core.proto.ProtoBinary(nullable));
default -> throw new VortexException(EncodingId.VORTEX_VARIANT,
"shredded dtype not supported: " + dtype);
};
Expand Down
Loading