Skip to content

Commit f53bb78

Browse files
dfa1claude
andcommitted
docs: complete Javadoc for core public API and add jdbc module
Zero javadoc warnings on `./mvnw javadoc:javadoc -pl core`. Excludes generated fbs/proto packages from javadoc checks. Adds jdbc module with JdbcImporter, JdbcImportOptions, ProgressListener, and SqlTypeToDType (6 unit tests, all green). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3f2e9d6 commit f53bb78

83 files changed

Lines changed: 1334 additions & 17 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/src/main/java/io/github/dfa1/vortex/core/ArrayStats.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
import java.nio.ByteBuffer;
77

88
/// Per-array statistics embedded in the encoding tree.
9+
///
10+
/// @param min minimum value in the array, or {@code null} if unknown
11+
/// @param max maximum value in the array, or {@code null} if unknown
12+
/// @param trueCount number of {@code true} values for bool columns, or {@code null} if unknown
13+
/// @param nullCount number of null values, or {@code null} if unknown
14+
/// @param isSorted {@code true} if the array is sorted in ascending order, or {@code null} if unknown
15+
/// @param isStrictSorted {@code true} if the array is strictly sorted (no duplicates), or {@code null} if unknown
916
public record ArrayStats(
1017
Object min,
1118
Object max,
@@ -16,10 +23,18 @@ public record ArrayStats(
1623
) {
1724
private static final ArrayStats EMPTY = new ArrayStats(null, null, null, null, null, null);
1825

26+
/// Returns an empty stats instance with all fields set to {@code null}.
27+
///
28+
/// @return an empty {@link ArrayStats} with no known statistics
1929
public static ArrayStats empty() {
2030
return EMPTY;
2131
}
2232

33+
/// Parses stats from a FlatBuffers {@link io.github.dfa1.vortex.fbs.ArrayStats} table.
34+
/// Returns an empty instance when {@code fbs} is {@code null} or carries no min/max.
35+
///
36+
/// @param fbs the FlatBuffers stats table, or {@code null}
37+
/// @return parsed stats, or an empty instance if no usable data is present
2338
public static ArrayStats fromFbs(io.github.dfa1.vortex.fbs.ArrayStats fbs) {
2439
if (fbs == null) {
2540
return EMPTY;

core/src/main/java/io/github/dfa1/vortex/core/CompressionScheme.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
package io.github.dfa1.vortex.core;
22

3+
/// Block-level compression scheme applied to flat segments in the Vortex file format.
34
public enum CompressionScheme {
4-
NONE(0), LZ4(1), ZLIB(2), ZSTD(3);
5+
/// No compression.
6+
NONE(0),
7+
/// LZ4 block compression.
8+
LZ4(1),
9+
/// Zlib deflate compression.
10+
ZLIB(2),
11+
/// Zstandard compression.
12+
ZSTD(3);
513

14+
/// Numeric code as stored in the file postscript.
615
public final int code;
716

817
CompressionScheme(int code) {
918
this.code = code;
1019
}
1120

21+
/// Returns the enum constant matching the given numeric code.
22+
///
23+
/// @param code numeric compression code from the file postscript
24+
/// @return the matching {@link CompressionScheme}
25+
/// @throws IllegalArgumentException if {@code code} does not correspond to any known scheme
1226
public static CompressionScheme of(int code) {
1327
return switch (code) {
1428
case 0 -> NONE;

core/src/main/java/io/github/dfa1/vortex/core/DType.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,65 @@ public sealed interface DType
1717
DType.Utf8, DType.Binary, DType.Struct,
1818
DType.List, DType.FixedSizeList, DType.Extension {
1919

20+
/// Returns whether this type allows null values.
21+
///
22+
/// @return {@code true} if null values are permitted
2023
boolean nullable();
2124

25+
/// The SQL {@code NULL} type — no values, always nullable.
26+
///
27+
/// @param nullable whether null values are permitted
2228
record Null(boolean nullable) implements DType {
2329
}
2430

31+
/// Boolean logical type.
32+
///
33+
/// @param nullable whether null values are permitted
2534
record Bool(boolean nullable) implements DType {
2635
}
2736

37+
/// Primitive numeric logical type backed by a physical {@link PType}.
38+
///
39+
/// @param ptype physical primitive type (e.g. I32, F64)
40+
/// @param nullable whether null values are permitted
2841
record Primitive(PType ptype, boolean nullable) implements DType {
2942
}
3043

44+
/// Fixed-precision decimal logical type.
45+
///
46+
/// @param precision total number of significant decimal digits
47+
/// @param scale number of digits to the right of the decimal point
48+
/// @param nullable whether null values are permitted
3149
record Decimal(byte precision, byte scale, boolean nullable) implements DType {
3250
}
3351

52+
/// Variable-length UTF-8 string logical type.
53+
///
54+
/// @param nullable whether null values are permitted
3455
record Utf8(boolean nullable) implements DType {
3556
}
3657

58+
/// Variable-length binary (byte string) logical type.
59+
///
60+
/// @param nullable whether null values are permitted
3761
record Binary(boolean nullable) implements DType {
3862
}
3963

64+
/// Struct logical type with named, typed fields.
65+
///
66+
/// @param fieldNames ordered list of field names
67+
/// @param fieldTypes ordered list of field types, parallel to {@code fieldNames}
68+
/// @param nullable whether null values are permitted
4069
record Struct(
4170
java.util.List<String> fieldNames,
4271
java.util.List<DType> fieldTypes,
4372
boolean nullable
4473
) implements DType {
74+
/// Returns the type of the field with the given name.
75+
///
76+
/// @param name the field name to look up
77+
/// @return the {@link DType} of the named field
78+
/// @throws IllegalArgumentException if no field with that name exists
4579
public DType field(String name) {
4680
int i = fieldNames.indexOf(name);
4781
if (i < 0) {
@@ -51,12 +85,27 @@ public DType field(String name) {
5185
}
5286
}
5387

88+
/// Variable-length list logical type.
89+
///
90+
/// @param elementType logical type of each list element
91+
/// @param nullable whether null values are permitted
5492
record List(DType elementType, boolean nullable) implements DType {
5593
}
5694

95+
/// Fixed-size list logical type where every list has the same length.
96+
///
97+
/// @param elementType logical type of each list element
98+
/// @param fixedSize number of elements in every list
99+
/// @param nullable whether null values are permitted
57100
record FixedSizeList(DType elementType, int fixedSize, boolean nullable) implements DType {
58101
}
59102

103+
/// Extension logical type with user-defined semantics layered over a storage type.
104+
///
105+
/// @param extensionId unique string identifier for the extension type (e.g. {@code "vortex.timestamp"})
106+
/// @param storageDType underlying storage dtype used for physical encoding
107+
/// @param metadata opaque extension-specific metadata bytes, or {@code null}
108+
/// @param nullable whether null values are permitted
60109
record Extension(
61110
String extensionId,
62111
DType storageDType,
@@ -65,6 +114,10 @@ record Extension(
65114
) implements DType {
66115
}
67116

117+
/// Returns a copy of this type with the given nullability.
118+
///
119+
/// @param nullable the desired nullability for the returned type
120+
/// @return a new {@link DType} identical to this one except for its nullability
68121
default DType withNullable(boolean nullable) {
69122
return switch (this) {
70123
case Null _ -> new Null(nullable);

core/src/main/java/io/github/dfa1/vortex/core/Footer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
///
77
/// All spec lists are index-stable: array/layout/segment indices in the tree refer
88
/// into these lists by position.
9+
///
10+
/// @param arraySpecs encoding id strings indexed by array spec index
11+
/// @param layoutSpecs layout type strings indexed by layout spec index
12+
/// @param segmentSpecs segment byte ranges indexed by segment index
13+
/// @param compressionSpecs compression schemes indexed by compression spec index
914
public record Footer(
1015
List<String> arraySpecs,
1116
List<String> layoutSpecs,

core/src/main/java/io/github/dfa1/vortex/core/Layout.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,61 @@
99
/// ```
1010
/// Struct → Zoned(Stats) → Chunked → [Flat, Flat, ...]
1111
/// ```
12+
///
13+
/// @param encodingId encoding id string (e.g. {@code "vortex.flat"})
14+
/// @param rowCount number of logical rows covered by this node
15+
/// @param metadata optional encoding-specific metadata bytes, or {@code null}
16+
/// @param children child layout nodes (empty for leaf nodes)
17+
/// @param segments indices into the file's segment table for buffers owned by this node
1218
public record Layout(
1319
String encodingId,
1420
long rowCount,
1521
ByteBuffer metadata,
1622
List<Layout> children,
1723
List<Integer> segments
1824
) {
25+
/// Encoding id for flat (leaf) layouts ({@code "vortex.flat"}).
1926
public static final String FLAT = "vortex.flat";
27+
/// Encoding id for chunked layouts ({@code "vortex.chunked"}).
2028
public static final String CHUNKED = "vortex.chunked";
29+
/// Encoding id for struct layouts ({@code "vortex.struct"}).
2130
public static final String STRUCT = "vortex.struct";
31+
/// Encoding id for zone-map layouts ({@code "vortex.stats"}).
2232
public static final String ZONED = "vortex.stats";
33+
/// Encoding id for dictionary layouts ({@code "vortex.dict"}).
2334
public static final String DICT = "vortex.dict";
2435

36+
/// Returns {@code true} if this layout is a flat (leaf) layout.
37+
///
38+
/// @return {@code true} when {@code encodingId} equals {@link #FLAT}
2539
public boolean isFlat() {
2640
return FLAT.equals(encodingId);
2741
}
2842

43+
/// Returns {@code true} if this layout is a chunked layout.
44+
///
45+
/// @return {@code true} when {@code encodingId} equals {@link #CHUNKED}
2946
public boolean isChunked() {
3047
return CHUNKED.equals(encodingId);
3148
}
3249

50+
/// Returns {@code true} if this layout is a struct layout.
51+
///
52+
/// @return {@code true} when {@code encodingId} equals {@link #STRUCT}
3353
public boolean isStruct() {
3454
return STRUCT.equals(encodingId);
3555
}
3656

57+
/// Returns {@code true} if this layout is a zone-map (stats) layout.
58+
///
59+
/// @return {@code true} when {@code encodingId} equals {@link #ZONED}
3760
public boolean isZoned() {
3861
return ZONED.equals(encodingId);
3962
}
4063

64+
/// Returns {@code true} if this layout is a dictionary layout.
65+
///
66+
/// @return {@code true} when {@code encodingId} equals {@link #DICT}
4167
public boolean isDict() {
4268
return DICT.equals(encodingId);
4369
}

core/src/main/java/io/github/dfa1/vortex/core/PType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public enum PType {
3030
F64;
3131

3232
/// Number of bytes per element on the wire (1, 2, 4, or 8).
33+
///
34+
/// @return the byte size of this physical type
3335
public int byteSize() {
3436
return switch (this) {
3537
case U8, I8 -> 1;
@@ -40,11 +42,15 @@ public int byteSize() {
4042
}
4143

4244
/// Returns {@code true} for {@code F16}, {@code F32}, and {@code F64}.
45+
///
46+
/// @return {@code true} if this ptype is a floating-point type
4347
public boolean isFloating() {
4448
return this == F16 || this == F32 || this == F64;
4549
}
4650

4751
/// Returns {@code true} for signed integers ({@code I8}–{@code I64}) and all floating-point types.
52+
///
53+
/// @return {@code true} if this ptype is signed
4854
public boolean isSigned() {
4955
return this == I8 || this == I16 || this == I32 || this == I64
5056
|| this == F16 || this == F32 || this == F64;

core/src/main/java/io/github/dfa1/vortex/core/SegmentSpec.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
/// {@code length} is {@code long} because the wire format encodes it as
66
/// {@code uint32} (up to 4 GB per segment). Storing it as a Java {@code int}
77
/// silently truncates segments larger than 2 GB into negative values.
8+
///
9+
/// @param offset byte offset from the start of the file
10+
/// @param length byte length of the segment (unsigned, stored as {@code long})
11+
/// @param alignmentExponent log2 of the required byte alignment; 0 means no alignment constraint
12+
/// @param compression compression scheme applied to this segment's bytes
813
public record SegmentSpec(
914
long offset,
1015
long length,

core/src/main/java/io/github/dfa1/vortex/core/VortexException.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,48 @@
1515
/// for recovery logic.
1616
public final class VortexException extends RuntimeException {
1717

18+
/// The encoding that raised this exception, or {@code null} if not attributed to a specific encoding.
1819
private final EncodingId encodingId;
1920

21+
/// Creates a {@code VortexException} with the given message and no associated encoding.
22+
///
23+
/// @param message human-readable error description
2024
public VortexException(String message) {
2125
super(message);
2226
this.encodingId = null;
2327
}
2428

29+
/// Creates a {@code VortexException} with the given message and cause, and no associated encoding.
30+
///
31+
/// @param message human-readable error description
32+
/// @param cause the underlying cause
2533
public VortexException(String message, Throwable cause) {
2634
super(message, cause);
2735
this.encodingId = null;
2836
}
2937

38+
/// Creates a {@code VortexException} attributed to the given encoding.
39+
///
40+
/// @param encodingId encoding responsible for this error
41+
/// @param message human-readable error description (prefixed with the encoding id)
3042
public VortexException(EncodingId encodingId, String message) {
3143
super(prefix(encodingId) + message);
3244
this.encodingId = encodingId;
3345
}
3446

47+
/// Creates a {@code VortexException} attributed to the given encoding, with a cause.
48+
///
49+
/// @param encodingId encoding responsible for this error
50+
/// @param message human-readable error description (prefixed with the encoding id)
51+
/// @param cause the underlying cause
3552
public VortexException(EncodingId encodingId, String message, Throwable cause) {
3653
super(prefix(encodingId) + message, cause);
3754
this.encodingId = encodingId;
3855
}
3956

57+
/// Returns the encoding that raised this exception, if known.
58+
///
59+
/// @return an {@link Optional} containing the {@link EncodingId}, or empty if not attributed
4060
public Optional<EncodingId> encodingId() {
4161
return Optional.ofNullable(encodingId);
4262
}

core/src/main/java/io/github/dfa1/vortex/core/array/Array.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,28 @@ public sealed interface Array
1515
FloatArray, GenericArray, IntArray, ListArray, ListViewArray, LongArray,
1616
MaskedArray, NullArray, ShortArray, StructArray, UnknownArray, VarBinArray {
1717

18+
/// Returns the number of elements in this array.
19+
///
20+
/// @return element count
1821
long length();
1922

23+
/// Returns the logical type of elements in this array.
24+
///
25+
/// @return dtype
2026
DType dtype();
2127

22-
/// Optional method to access the internals (used by some {@link io.github.dfa1.vortex.encoding.Encoding})
28+
/// Returns the raw buffer at position {@code i} (used by some {@link io.github.dfa1.vortex.encoding.Encoding}).
29+
///
30+
/// @param i buffer index
31+
/// @return memory segment for buffer {@code i}
2332
default MemorySegment buffer(int i) {
2433
throw new VortexException(getClass().getSimpleName() + " has no raw buffers");
2534
}
2635

27-
/// Optional method to access any children array (used by some {@link io.github.dfa1.vortex.encoding.Encoding})
36+
/// Returns the child array at position {@code i} (used by some {@link io.github.dfa1.vortex.encoding.Encoding}).
37+
///
38+
/// @param i child index
39+
/// @return child array at index {@code i}
2840
default Array child(int i) {
2941
throw new VortexException(getClass().getSimpleName() + " has no children");
3042
}

core/src/main/java/io/github/dfa1/vortex/core/array/BoolArray.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public final class BoolArray implements Array {
1414
private final MemorySegment buffer;
1515
private final ArrayStats stats;
1616

17+
/// Constructs a {@code BoolArray} backed by the given bit-packed buffer.
18+
///
19+
/// @param dtype logical type, must be {@link io.github.dfa1.vortex.core.DType.Bool}
20+
/// @param length number of logical boolean elements
21+
/// @param buffer bit-packed boolean data (LSB-first, one byte per 8 elements)
22+
/// @param stats per-array statistics, or {@link ArrayStats#empty()} if unknown
1723
public BoolArray(DType dtype, long length, MemorySegment buffer, ArrayStats stats) {
1824
this.dtype = dtype;
1925
this.length = length;
@@ -31,6 +37,9 @@ public long length() {
3137
return length;
3238
}
3339

40+
/// Returns the per-array statistics for this array.
41+
///
42+
/// @return the {@link ArrayStats} associated with this array
3443
public ArrayStats stats() {
3544
return stats;
3645
}
@@ -43,6 +52,10 @@ public MemorySegment buffer(int i) {
4352
return buffer;
4453
}
4554

55+
/// Returns the boolean value at the given logical index.
56+
///
57+
/// @param i zero-based logical index (must be in {@code [0, length)})
58+
/// @return the boolean value at position {@code i}
4659
public boolean getBoolean(long i) {
4760
byte b = buffer.get(ValueLayout.JAVA_BYTE, i >>> 3);
4861
return (b & (1 << (i & 7))) != 0;

0 commit comments

Comments
 (0)