feat(keyset): opt-in Id-range parallel paging for assets batch fetch (v1.4.0) - #111
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…guard, release safety
- buildKeysetUrl: parenthesize the base filter `(${filter}) and Id gt.. and Id le..`
so an `or` base filter binds the Id bounds to the whole predicate (OData `and` binds
tighter than `or`) — prevents silent duplication for future callers. + or-filter test.
- getAllBatchKeyset: tighten range guard with `lo < max` to drop empty ranges above the
data (avoids ~15 wasted probes on tiny/sparse tenants).
- package.json: add `prepublishOnly: npm run build` + `files: ["dist"]` — dist can't be
published stale, and the tarball ships only dist (not the 400-line plan doc).
- CHANGELOG + KEYSET_PARTITIONS comment: caveat the speedup as distribution-dependent
(clustered Ids page mostly sequentially).
Full suite 112/112 green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in keyset (Id-range-partitioned) parallel paging mode to the assets batch fetch — ~2–2.7× faster than the current
$skipOFFSET paging on large tenants, with no behavior change for existing callers.getAllAssetsBatch(context, callback)is unchanged; the new mode is reached only viagetAllAssetsBatch(context, callback, { paging: 'keyset' }). This is a shared SDK (connector + facility360 mobile + demoio), so the change is purely additive.How it works
getAllBatchKeyset<T extends { Id: number }>probesmin(Id)/max(Id), splits the Id space into 16 half-open ranges (Id gt lo and Id le hi), and pages each range with a keyset cursor under the same 4-wayBottleneckpool asgetAllBatch(16 partitions are load-balancing granularity, not a concurrency increase — ≤4 requests in flight).$orderby=Id;Idis the unique PK, so no row is dropped or duplicated at range boundaries.QueryContext.buildKeysetUrl/buildKeysetBoundUrlhelpers build the page/probe URLs.Testing
Unit:
tests/keyset_paging.test.ts— URL builders, row parity across multi-page ranges (dense cluster forces a genuine 2nd page so the cursor-advance loop is exercised), the ≤4 concurrency cap, empty-set, and default-$skipbackward-compat. Full suite 110/110 green,tscclean.Stage (real data, connector-driven, no prod load):
Notes
userpropertyassociation, etc.) are still$skip— only theassetsendpoint is keyset-enabled server-side today; converting those is a separate, larger win to request from Accruent.🤖 Generated with Claude Code