Skip to content

Commit 05b4a31

Browse files
committed
target version java 11
1 parent 2a46922 commit 05b4a31

File tree

5 files changed

+112
-56
lines changed

5 files changed

+112
-56
lines changed

java/build.gradle.kts

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ allprojects {
6262

6363
tasks.withType<JavaCompile> {
6464
options.errorprone.disable("UnusedVariable")
65-
options.compilerArgs.add("--enable-preview")
65+
// options.compilerArgs.add("--enable-preview")
66+
options.release = 11
6667

6768
// Needed to make sure that the barista-annotations emits to the correct directory
6869
options.generatedSourceOutputDirectory = projectDir.resolve("generated_src")

java/vortex-jni/src/main/java/dev/vortex/api/DType.java

+54-29
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,20 @@ enum TimeUnit {
6565
;
6666

6767
public static TimeUnit from(byte unit) {
68-
return switch (unit) {
69-
case 0 -> NANOSECONDS;
70-
case 1 -> MICROSECONDS;
71-
case 2 -> MILLISECONDS;
72-
case 3 -> SECONDS;
73-
case 4 -> DAYS;
74-
default -> throw new IllegalArgumentException("Unknown TimeUnit: " + unit);
75-
};
68+
switch (unit) {
69+
case 0:
70+
return NANOSECONDS;
71+
case 1:
72+
return MICROSECONDS;
73+
case 2:
74+
return MILLISECONDS;
75+
case 3:
76+
return SECONDS;
77+
case 4:
78+
return DAYS;
79+
default:
80+
throw new IllegalArgumentException("Unknown TimeUnit: " + unit);
81+
}
7682
}
7783
}
7884

@@ -98,27 +104,46 @@ enum Variant {
98104
;
99105

100106
public static Variant from(byte variant) {
101-
return switch (variant) {
102-
case 0 -> NULL;
103-
case 1 -> BOOL;
104-
case 2 -> PRIMITIVE_U8;
105-
case 3 -> PRIMITIVE_U16;
106-
case 4 -> PRIMITIVE_U32;
107-
case 5 -> PRIMITIVE_U64;
108-
case 6 -> PRIMITIVE_I8;
109-
case 7 -> PRIMITIVE_I16;
110-
case 8 -> PRIMITIVE_I32;
111-
case 9 -> PRIMITIVE_I64;
112-
case 10 -> PRIMITIVE_F16;
113-
case 11 -> PRIMITIVE_F32;
114-
case 12 -> PRIMITIVE_F64;
115-
case 13 -> UTF8;
116-
case 14 -> BINARY;
117-
case 15 -> STRUCT;
118-
case 16 -> LIST;
119-
case 17 -> EXTENSION;
120-
default -> throw new IllegalArgumentException("Unknown DType variant: " + variant);
121-
};
107+
switch (variant) {
108+
case 0:
109+
return NULL;
110+
case 1:
111+
return BOOL;
112+
case 2:
113+
return PRIMITIVE_U8;
114+
case 3:
115+
return PRIMITIVE_U16;
116+
case 4:
117+
return PRIMITIVE_U32;
118+
case 5:
119+
return PRIMITIVE_U64;
120+
case 6:
121+
return PRIMITIVE_I8;
122+
case 7:
123+
return PRIMITIVE_I16;
124+
case 8:
125+
return PRIMITIVE_I32;
126+
case 9:
127+
return PRIMITIVE_I64;
128+
case 10:
129+
return PRIMITIVE_F16;
130+
case 11:
131+
return PRIMITIVE_F32;
132+
case 12:
133+
return PRIMITIVE_F64;
134+
case 13:
135+
return UTF8;
136+
case 14:
137+
return BINARY;
138+
case 15:
139+
return STRUCT;
140+
case 16:
141+
return LIST;
142+
case 17:
143+
return EXTENSION;
144+
default:
145+
throw new IllegalArgumentException("Unknown DType variant: " + variant);
146+
}
122147
}
123148
}
124149
}

java/vortex-spark/src/main/java/dev/vortex/spark/SparkTypes.java

+35-21
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,34 @@ private SparkTypes() {}
3333
* Convert a STRUCT Vortex type to a Spark {@link DataType}.
3434
*/
3535
public static DataType toDataType(DType dType) {
36-
return switch (dType.getVariant()) {
37-
case NULL -> DataTypes.NullType;
38-
case BOOL -> DataTypes.BooleanType;
39-
case PRIMITIVE_U8, PRIMITIVE_I8 -> DataTypes.ByteType;
40-
case PRIMITIVE_U16, PRIMITIVE_I16 -> DataTypes.ShortType;
41-
case PRIMITIVE_U32, PRIMITIVE_I32 -> DataTypes.IntegerType;
42-
case PRIMITIVE_U64, PRIMITIVE_I64 -> DataTypes.LongType;
43-
case PRIMITIVE_F16 -> {
36+
switch (dType.getVariant()) {
37+
case NULL:
38+
return DataTypes.NullType;
39+
case BOOL:
40+
return DataTypes.BooleanType;
41+
case PRIMITIVE_U8:
42+
case PRIMITIVE_I8:
43+
return DataTypes.ByteType;
44+
case PRIMITIVE_U16:
45+
case PRIMITIVE_I16:
46+
return DataTypes.ShortType;
47+
case PRIMITIVE_U32:
48+
case PRIMITIVE_I32:
49+
return DataTypes.IntegerType;
50+
case PRIMITIVE_U64:
51+
case PRIMITIVE_I64:
52+
return DataTypes.LongType;
53+
case PRIMITIVE_F16:
4454
throw new IllegalArgumentException("Spark does not support f16");
45-
}
46-
case PRIMITIVE_F32 -> DataTypes.FloatType;
47-
case PRIMITIVE_F64 -> DataTypes.DoubleType;
48-
case UTF8 -> DataTypes.StringType;
49-
case BINARY -> DataTypes.BinaryType;
50-
case STRUCT -> {
55+
case PRIMITIVE_F32:
56+
return DataTypes.FloatType;
57+
case PRIMITIVE_F64:
58+
return DataTypes.DoubleType;
59+
case UTF8:
60+
return DataTypes.StringType;
61+
case BINARY:
62+
return DataTypes.BinaryType;
63+
case STRUCT:
5164
// For each of the inner struct fields, we capture them together here.
5265
var struct = new StructType();
5366

@@ -58,10 +71,10 @@ public static DataType toDataType(DType dType) {
5871
dType.getFieldNames().stream(),
5972
dType.getFieldTypes().stream(),
6073
(name, type) -> struct.add(name, toDataType(type)));
61-
yield struct;
62-
}
63-
case LIST -> DataTypes.createArrayType(toDataType(dType.getElementType()), dType.isNullable());
64-
case EXTENSION -> {
74+
return struct;
75+
case LIST:
76+
return DataTypes.createArrayType(toDataType(dType.getElementType()), dType.isNullable());
77+
case EXTENSION:
6578
/*
6679
* Spark does not have a direct equivalent for many of the temporal types we support in Vortex or Arrow.
6780
* Notably, there is no DATE type, and timestamps can have at most µs-level precision.
@@ -79,13 +92,14 @@ public static DataType toDataType(DType dType) {
7992
}
8093

8194
if (dType.isDate() || dType.isTimestamp()) {
82-
yield TimestampType$.MODULE$;
95+
return TimestampType$.MODULE$;
8396
}
8497

8598
// TODO(aduffy): temporal types
8699
throw new IllegalArgumentException("Unsupported non-temporal extension type");
87-
}
88-
};
100+
default:
101+
throw new IllegalArgumentException("unreachable");
102+
}
89103
}
90104

91105
/**

java/vortex-spark/src/main/java/dev/vortex/spark/read/VortexScan.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,27 @@
2525
/**
2626
* Spark V2 {@link Scan} over a table of Vortex files.
2727
*/
28-
public record VortexScan(ImmutableList<String> paths, ImmutableList<Column> readColumns) implements Scan {
28+
public final class VortexScan implements Scan {
29+
30+
private final ImmutableList<String> paths;
31+
private final ImmutableList<Column> readColumns;
32+
33+
public VortexScan(ImmutableList<String> paths, ImmutableList<Column> readColumns) {
34+
this.paths = paths;
35+
this.readColumns = readColumns;
36+
}
37+
2938
@Override
3039
public StructType readSchema() {
31-
return CatalogV2Util.v2ColumnsToStructType(readColumns().toArray(new Column[0]));
40+
return CatalogV2Util.v2ColumnsToStructType(readColumns.toArray(new Column[0]));
3241
}
3342

3443
/**
3544
* Logging-friendly readable description of the scan source.
3645
*/
3746
@Override
3847
public String description() {
39-
return String.format("VortexScan{paths=%s, columns=%s}", paths(), readColumns());
48+
return String.format("VortexScan{paths=%s, columns=%s}", paths, readColumns);
4049
}
4150

4251
@Override

java/vortex-spark/src/main/java/dev/vortex/spark/read/VortexTable.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
/**
2727
* Spark V2 {@link Table} of Vortex files.
2828
*/
29-
public record VortexTable(ImmutableList<String> paths, ImmutableList<Column> readColumns)
30-
implements Table, SupportsRead {
29+
public final class VortexTable implements Table, SupportsRead {
3130
private static final String SHORT_NAME = "vortex";
3231

32+
private final ImmutableList<String> paths;
33+
private final ImmutableList<Column> readColumns;
34+
35+
public VortexTable(ImmutableList<String> paths, ImmutableList<Column> readColumns) {
36+
this.paths = paths;
37+
this.readColumns = readColumns;
38+
}
39+
3340
@Override
3441
public ScanBuilder newScanBuilder(CaseInsensitiveStringMap _options) {
3542
// TODO(aduffy): pass any S3 creds from options down into the scan builder.

0 commit comments

Comments
 (0)