Skip to content

Commit 52f2e70

Browse files
dfa1claude
andcommitted
docs: update chunk examples to ColumnName keys
Follow-up to the writeChunk(Map<ColumnName, Object>) retype (#201) and the Chunk.put(ColumnName, ...) builder (#200): doc snippets still showed String keys and would not compile. DocsConsistencyTest is blind to them (the .put("x", ...) / writeChunk(Map<...>) forms have no dotted receiver its regex can match), so this was caught in review, not CI. - reference.md: writeChunk(Map<String, Object>) -> Map<ColumnName, Object> - README / tutorial / compatibility: .put("x", ...) -> .put(ColumnName.of("x"), ...) - tutorial: add the ColumnName import - JdbcImporter.toChunkMap: drop a pointless ColumnName -> String -> ColumnName round-trip (List<ColumnName> names = schema.fieldNames()) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent debf147 commit 52f2e70

5 files changed

Lines changed: 14 additions & 13 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ try (var ch = FileChannel.open(Path.of("data/example.vortex"),
115115
StandardOpenOption.CREATE, StandardOpenOption.WRITE);
116116
var writer = VortexWriter.create(ch, schema, WriteOptions.cascading(3))) {
117117
writer.writeChunk(c -> c
118-
.put("timestamp", new long[] {1_700_000_000_000L, 1_700_000_001_000L})
119-
.put("symbol", new String[] {"AAPL", "AAPL"})
120-
.put("price", new double[] {189.95, 190.10})
121-
.put("volume", new Long[] {100L, null})); // null in nullable col
118+
.put(ColumnName.of("timestamp"), new long[] {1_700_000_000_000L, 1_700_000_001_000L})
119+
.put(ColumnName.of("symbol"), new String[] {"AAPL", "AAPL"})
120+
.put(ColumnName.of("price"), new double[] {189.95, 190.10})
121+
.put(ColumnName.of("volume"), new Long[] {100L, null})); // null in nullable col
122122
}
123123
```
124124

docs/compatibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ End-to-end round-trip — write a `List<LocalDate>`, read it back:
177177
var schema = DType.structBuilder()
178178
.field("birthdays", DateExtensionDecoder.INSTANCE.dtype(false))
179179
.build();
180-
writer.writeChunk(c -> c.put("birthdays", dates)); // Collection auto-routed
180+
writer.writeChunk(c -> c.put(ColumnName.of("birthdays"), dates)); // Collection auto-routed
181181

182182
try (var iter = reader.scan(ScanOptions.all());
183183
Chunk chunk = iter.next()) {

docs/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Writes a Vortex file. Implements `Closeable`. The file is complete and readable
9898
| `static create(WritableByteChannel, DType.Struct, WriteOptions)` | Default codec set |
9999
| `static create(WritableByteChannel, DType.Struct, WriteOptions, List<Encoding>)` | Custom codec set |
100100
| `writeChunk(Consumer<Chunk>)` | One batch of rows; typed builder validates column names + array types at each `.put`; missing columns throw `IllegalStateException` when the lambda returns. Preferred when columns are known at compile time. |
101-
| `writeChunk(Map<String, Object>)` | One batch of rows by map. Validates that every schema column is present and that all columns share the same row count. Use when the column set is built dynamically (Parquet/JDBC importers, generic exporters). |
101+
| `writeChunk(Map<ColumnName, Object>)` | One batch of rows by map. Validates that every schema column is present and that all columns share the same row count. Use when the column set is built dynamically (Parquet/JDBC importers, generic exporters). |
102102
| `close()` | Finalizes file (footer, postscript, trailer) |
103103

104104
### `Chunk` (`io.github.dfa1.vortex.writer.Chunk`)

docs/tutorial.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ A Vortex file is a typed struct — every column has a declared type before any
4646

4747
```java
4848
import io.github.dfa1.vortex.core.model.DType;
49+
import io.github.dfa1.vortex.core.model.ColumnName;
4950

5051
DType.Struct schema = DType.structBuilder()
5152
.field("timestamp", DType.I64) // unix epoch millis
@@ -77,10 +78,10 @@ try (FileChannel ch = FileChannel.open(outPath, CREATE, WRITE, TRUNCATE_EXISTING
7778
VortexWriter writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) {
7879

7980
writer.writeChunk(c -> c
80-
.put("timestamp", new long[] {1_700_000_000_000L, 1_700_000_001_000L, 1_700_000_002_000L})
81-
.put("symbol", new String[] {"AAPL", "AAPL", "MSFT"})
82-
.put("price", new double[] {189.95, 190.10, 374.20})
83-
.put("volume", new Long[] {100L, null, 175L})); // boxed → nullable column
81+
.put(ColumnName.of("timestamp"), new long[] {1_700_000_000_000L, 1_700_000_001_000L, 1_700_000_002_000L})
82+
.put(ColumnName.of("symbol"), new String[] {"AAPL", "AAPL", "MSFT"})
83+
.put(ColumnName.of("price"), new double[] {189.95, 190.10, 374.20})
84+
.put(ColumnName.of("volume"), new Long[] {100L, null, 175L})); // boxed → nullable column
8485
}
8586
```
8687

jdbc/src/main/java/io/github/dfa1/vortex/jdbc/JdbcImporter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,18 @@ private static UUID toUuid(Object raw) {
271271

272272
private static Map<ColumnName, Object> toChunkMap(DType.Struct schema, Object[] buffers,
273273
boolean[][] validity, boolean[] anyNull, int rows) {
274-
List<String> names = schema.fieldNames().stream().map(ColumnName::value).toList();
274+
List<ColumnName> names = schema.fieldNames();
275275
Map<ColumnName, Object> chunk = new LinkedHashMap<>();
276276
for (int c = 0; c < names.size(); c++) {
277277
Object trimmed = trimBuffer(buffers[c], rows);
278278
if (validity[c] != null && anyNull[c]) {
279279
boolean[] trimmedValidity = rows == validity[c].length
280280
? validity[c]
281281
: Arrays.copyOf(validity[c], rows);
282-
chunk.put(ColumnName.of(names.get(c)),
282+
chunk.put(names.get(c),
283283
new io.github.dfa1.vortex.writer.encode.NullableData(trimmed, trimmedValidity));
284284
} else {
285-
chunk.put(ColumnName.of(names.get(c)), trimmed);
285+
chunk.put(names.get(c), trimmed);
286286
}
287287
}
288288
return chunk;

0 commit comments

Comments
 (0)