# Retrieval and Streaming

> USearch for Java

`get` returns every vector the key holds, however many there turn out to be, at the natural width of the kind asked for, with the `columns` and `strideBytes` the library reported.

```java
DenseVectors every = index.get(Key.of(42), Scalar.F32, arena);
float[] values = every.segment().toArray(ValueLayout.JAVA_FLOAT);
```

A cursor walks the index contents, reading each shard's publication watermark as it enters that shard, so an entry once passed is never revisited.
Without start keys it yields every entry as stored, and `cursor(starts...)` yields the starts' own entries first, then the entries those link to breadth-first, each once.
Each pull writes up to a wanted count of keys into the arena, and `nextLinks` the keys each links to beside them; the vectors themselves come from `get`.

```java
try (DenseCursor cursor = index.on(pool).cursor()) {
    for (DenseBatch batch = cursor.nextLinks(1024, arena); batch.written() != 0;
            batch = cursor.nextLinks(1024, arena)) {
        export(batch);
    }
}
```

A search stream is a resumable best-first traversal of one query row, so a caller that post-filters aggressively pulls until satisfied instead of guessing "k" upfront; no engine residency implements it yet, so the engine answers `Status.UNSUPPORTED`.

```java
try (DenseSearchStream stream = index.on(pool).searchStream(query)) {
    Matches next = stream.next(16, arena);
}
```

### Sampling

`sample` draws keys around a focus, each hanging from a shown or earlier draw, and places them in three dimensions beside the keys already shown, so a view grows one connected sample as it zooms.

```java
Sample drawn = index.on(pool).sample(
        256, arena, new DenseSampleConfig().shown(shown, shownCoordinates).focus(near).seed(42));
float x = drawn.coordinate(0, 0);
```

