Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
236ea7e
Add unit tests that reproduce the problems with moveWindow on infinit…
kevin-dp Oct 22, 2025
a1a8441
Handle Infinity limit in move
kevin-dp Oct 22, 2025
d4b0995
Changeset
kevin-dp Oct 22, 2025
a166376
Add support for orderBy and limit options in currentStateAsChanges
kevin-dp Oct 21, 2025
f650a07
Unit tests for currentStateAsChanges
kevin-dp Oct 21, 2025
448469c
changeset
kevin-dp Oct 21, 2025
33945c9
fix for eslint
kevin-dp Oct 21, 2025
113f396
Move helper functions to the end of the file
kevin-dp Oct 21, 2025
7c82494
add predicate utils
samwillis Oct 11, 2025
fc201ee
optimise in when all primatives
samwillis Oct 11, 2025
4af3410
optimisations
samwillis Oct 11, 2025
140f887
changeset
samwillis Oct 11, 2025
5c40c7d
minusWherePredicates
samwillis Oct 13, 2025
66e9d53
Add unit test for OR in both subset and superset that shows bug with …
kevin-dp Oct 14, 2025
dc9601e
Reorder OR handling to fix bug and handle AND similarly
kevin-dp Oct 14, 2025
e8d18d0
change chageset
samwillis Oct 15, 2025
1e527cf
dedupe code
samwillis Oct 15, 2025
1e82263
add createDeduplicatedLoadSubset function
samwillis Oct 15, 2025
9f075cd
convert deduper to a class, with reset, and dedupe inflight
samwillis Oct 15, 2025
a4117c9
Simplify matching of inflight requests
kevin-dp Oct 16, 2025
4fbe451
Improve minusWherePredicates such that it can handle common condition…
kevin-dp Oct 16, 2025
769dda4
Modify DeduplicatedLoadSubset.loadSubset such that it only loads the …
kevin-dp Oct 16, 2025
6365f37
Remove unused predicate helper functions
kevin-dp Oct 16, 2025
b256276
Fix eslint issue
kevin-dp Oct 16, 2025
3ca21ee
Prettier
kevin-dp Oct 20, 2025
ac9557f
Unify handling of IN and OR
kevin-dp Oct 20, 2025
e519eab
Handle subset that is false
kevin-dp Oct 20, 2025
6ee696c
Fix isLimitSubset to correctly handle unlimited subsets
kevin-dp Oct 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/legal-cooks-sink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tanstack/db-ivm": patch
---

Fix bug with setWindow on ordered queries that have no limit.
5 changes: 5 additions & 0 deletions .changeset/light-phones-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tanstack/db": patch
---

Add predicate comparison and merging utilities (isWhereSubset, intersectWherePredicates, unionWherePredicates, and related functions) to support predicate push-down in collection sync operations, enabling efficient tracking of loaded data ranges and preventing redundant server requests. Includes performance optimizations for large primitive IN predicates and full support for Date objects in equality, range, and IN clause comparisons.
5 changes: 5 additions & 0 deletions .changeset/open-cups-lose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tanstack/db": patch
---

Add support for orderBy and limit in currentStateAsChanges function
21 changes: 17 additions & 4 deletions packages/db-ivm/src/operators/topKWithFractionalIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,25 @@ class TopKArray<V> implements TopK<V> {
}): TopKMoveChanges<V> {
const oldOffset = this.#topKStart
const oldLimit = this.#topKEnd - this.#topKStart
const oldRange: HRange = [this.#topKStart, this.#topKEnd]

this.#topKStart = offset ?? oldOffset
this.#topKEnd = this.#topKStart + (limit ?? oldLimit)
// `this.#topKEnd` can be `Infinity` if it has no limit
// but `diffHalfOpen` expects a finite range
// so we restrict it to the size of the topK if topKEnd is infinite
const oldRange: HRange = [
this.#topKStart,
this.#topKEnd === Infinity ? this.#topKStart + this.size : this.#topKEnd,
]

const newRange: HRange = [this.#topKStart, this.#topKEnd]
this.#topKStart = offset ?? oldOffset
this.#topKEnd = this.#topKStart + (limit ?? oldLimit) // can be `Infinity` if limit is `Infinity`

// Also handle `Infinity` in the newRange
const newRange: HRange = [
this.#topKStart,
this.#topKEnd === Infinity
? Math.max(this.#topKStart + this.size, oldRange[1]) // since the new limit is Infinity we need to take everything (so we need to take the biggest (finite) topKEnd)
: this.#topKEnd,
]
const { onlyInA, onlyInB } = diffHalfOpen(oldRange, newRange)

const moveIns: Array<IndexedValue<V>> = []
Expand Down
Loading
Loading