Skip to content

Commit 66e1614

Browse files
dfa1claude
andcommitted
docs: fix quickstart — correct package names, add column() and write examples
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 422289a commit 66e1614

1 file changed

Lines changed: 44 additions & 11 deletions

File tree

README.md

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,30 +146,63 @@ exactly.
146146
Add the library to your build (example, Maven):
147147

148148
```xml
149-
<!-- TODO: replace with released coordinates -->
149+
<!-- TODO: replace with released coordinates once published to Maven Central -->
150150
<dependency>
151151
<groupId>io.github.dfa1</groupId>
152152
<artifactId>vortex-java</artifactId>
153-
<version>0.0.0-SNAPSHOT</version>
153+
<version>0.1.0-SNAPSHOT</version>
154154
</dependency>
155155
```
156156

157-
Open and read a Vortex file:
157+
### Read a Vortex file
158158

159159
```java
160-
import io.github.dfa1.vortex.reader.VortexFile;
161-
import io.github.dfa1.vortex.reader.ScanIterator;
162-
163-
try (VortexFile vf = VortexFile.open(Path.of("data/example.vortex"))) {
164-
try (ScanIterator it = vf.scan()) {
165-
while (it.hasNext()) {
166-
var row = it.next();
167-
// process row
160+
import io.github.dfa1.vortex.io.VortexReader;
161+
import io.github.dfa1.vortex.scan.ScanOptions;
162+
import io.github.dfa1.vortex.core.array.LongArray;
163+
164+
try (VortexReader vf = VortexReader.open(Path.of("data/example.vortex"));
165+
var iter = vf.scan(ScanOptions.all())) {
166+
while (iter.hasNext()) {
167+
var chunk = iter.next();
168+
// access a typed column
169+
LongArray ts = chunk.column("timestamp");
170+
for (long i = 0; i < ts.length(); i++) {
171+
System.out.println(ts.getLong(i));
168172
}
173+
// or get all columns as a map
174+
chunk.columns().forEach((name, arr) ->
175+
System.out.printf("%s: %d rows%n", name, arr.length()));
169176
}
170177
}
171178
```
172179

180+
> **Note:** `iter.hasNext()` closes the previous chunk's arena. Access all column data
181+
> before calling `hasNext()` again.
182+
183+
### Write a Vortex file
184+
185+
```java
186+
import io.github.dfa1.vortex.writer.VortexWriter;
187+
import io.github.dfa1.vortex.writer.WriteOptions;
188+
import io.github.dfa1.vortex.core.DType;
189+
import io.github.dfa1.vortex.core.PType;
190+
191+
var schema = new DType.Struct(
192+
List.of("timestamp", "value"),
193+
List.of(new DType.Primitive(PType.I64, false),
194+
new DType.Primitive(PType.F64, false)),
195+
false);
196+
197+
long[] timestamps = {1_700_000_000L, 1_700_000_001L, 1_700_000_002L};
198+
double[] values = {1.23, 4.56, 7.89};
199+
200+
try (var ch = FileChannel.open(Path.of("out.vortex"), CREATE, WRITE);
201+
var writer = VortexWriter.create(ch, schema, WriteOptions.defaults())) {
202+
writer.writeChunk(Map.of("timestamp", timestamps, "value", values));
203+
}
204+
```
205+
173206
## Requirements
174207

175208
- Java 25+

0 commit comments

Comments
 (0)