You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add nearest UDTF with k support and bioframe parity tests (#13)
* Add nearest UDTF with k support and bioframe parity tests
* Address PR review feedback for nearest behavior
* Optimize nearest k=1 hot path: remove HashMap, specialize stream loop
- Remove `by_position` FnvHashMap from NearestIntervalIndex, replacing
HashMap lookups with direct field extraction via extract_coitree_meta()
and interval_meta_from() (eliminates O(n) construction + per-query lookups)
- Specialize k=1 path in get_nearest_stream to call nearest_one() directly,
bypassing Vec clear/push/iterate overhead
- Pre-allocate output vectors with_capacity(num_rows * k)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Optimize nearest: cache contig lookups and intern strings in index build
Cache the last contig hash-map lookup in the stream loop so sorted
genomic data (~10M rows, ~24 contigs) drops from ~10M FNV hashes to ~24.
Intern contig strings in build_nearest_indexes() by grouping on borrowed
&str from Arrow, reducing String allocations from ~1M to ~25.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Optimize nearest: remove RepartitionExec, resolve arrays per-batch, lazy by_end
- Remove forced RepartitionExec on right plan; use natural partitioning
(matches interval_join CollectLeft behavior, avoids cross-thread shuffle)
- Add PosArray::resolve() returning Cow<[i32]> — resolves enum variant
once per batch; inner loop uses direct slice indexing with zero dispatch
and no Result overhead per row
- Make NearestIntervalIndex::by_end lazily initialized via OnceLock —
for k=1 include_overlaps=true hot path, avoids ~24MB/contig allocation
and cache pressure from the sorted copy
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Address PR review feedback for optimization commit
- Add null guard in PosArray::resolve(): reject arrays with null
coordinate values early instead of silently reading raw buffer garbage
- Add comment explaining intentional k=1 vs k>1 loop duplication
(hot-path avoids Vec alloc and clear per row)
- Replace FnvHashMap<Position, ()> with FnvHashSet<Position> in
nearest_k seen-set for idiomatic usage
- Consolidate extract_coitree_position/extract_coitree_meta cfg blocks
into per-platform modules so both functions share a single predicate;
adding a new target only requires updating one block
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Replace fnv with ahash for all hash maps/sets
ahash uses hardware AES-NI instructions on modern CPUs, providing
better throughput than FNV for all key sizes. It was already a direct
dependency (and transitive via hashbrown/DataFusion). Removes the fnv
dependency entirely.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix import ordering after fnv→ahash migration
cargo fmt reorders ahash imports alphabetically with other external
crate imports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Registers the `coverage`and `count_overlaps` SQL table functions on an existing `SessionContext`. This is analogous to `register_pileup_functions` in the pileup crate.
37
+
Registers the `coverage`, `count_overlaps`, and `nearest` SQL table functions on an existing `SessionContext`. This is analogous to `register_pileup_functions` in the pileup crate.
Returns exactly one match per right-side row: the overlapping interval if one exists, otherwise the nearest interval by distance.
179
+
If there is no matching key group on the left side, the row is emitted with nulls on left columns.
133
180
134
181
## Programmatic API
135
182
@@ -207,11 +254,12 @@ register_ranges_functions(&ctx); // registers coverage() and count_overlaps() U
207
254
208
255
### New SQL Table Functions
209
256
210
-
The `coverage`and `count_overlaps` operations are now available as SQL table functions (previously only accessible via the Rust `CountOverlapsProvider` API):
257
+
The `coverage`, `count_overlaps`, and `nearest` operations are now available as SQL table functions:
0 commit comments