Repository navigation
Conversation
…ast index The batched probe lanes emit `EncodedSid`/`EncodedLit` under novelty, with `DictNovelty` ids for subjects and strings the index has not seen. Equality surfaces normalize decoded bindings to that encoded form, but the normalizer looked only in the persisted dictionaries, on the premise that encoded bindings never carry novelty ids. A novelty-only term in two representations was therefore two terms: - VALUES joined to a typed star dropped rows whose string value was new since the last index build. - FILTER NOT EXISTS / OPTIONAL + !BOUND kept, and EXISTS dropped, rows whose subject was new since the last index build. - DISTINCT returned such a term twice, MINUS did not remove it, GROUP BY split it into two groups. - The SAMETERM fast path compared an encoded subject against a constant through the persisted dictionary only, so `sameTerm(?s, ex:new)` was false. The normalizer also skipped blank-node subjects, though skolemized blank nodes are subject-dictionary entries that index lanes emit encoded, so the same split hit COUNT(DISTINCT) and MINUS over a blank node under novelty. One value -> id lookup and one normalizer now serve every site: - `DictLookup` (binary-index) reads the persisted dictionaries, then `DictNovelty`, in the order `populate_dict_novelty_safe` allocates. It replaces the hand-rolled copies in the binary scan and range providers, the batched join/OPTIONAL/property-join key resolution, the annotation probe, fulltext and `DictOverlay`. - `EqualityNorm::for_ctx` carries the store, the novelty layer and the graph view; `normalize_for_key` / `binding_to_group_key_normalized` take it in place of loose store/view pairs. DISTINCT, GROUP BY (both operators), COUNT(DISTINCT), MINUS, semijoin, VALUES, subquery, range semijoin, membership join, the annotation probe, R2RML and the hash join all key through it. The hash join's own `JoinKey` and Sid lookup are gone, and VALUES builds its norm once per open rather than per comparison. Lookups left persisted-only are the ones that read index leaflets alone: frontier `PathNode::Id`, `sid_to_store_s_id` scan filters, and the EXISTS cache and fast-path-common lookups behind the overlay-free gate.
bplatz
added a commit
that referenced
this pull request
Oct 11, 2026
Carried over from #2047, whose fixes this branch subsumes. Covers shapes the OPTIONAL suite does not: a novelty-only string through the property-join lane (VALUES, DISTINCT, MINUS, GROUP BY), EXISTS / NOT EXISTS / OPTIONAL+!BOUND and sameTerm keyed on a novelty-only subject, and a skolemized blank node across a hash join, COUNT(DISTINCT) and MINUS. Each case asserts the lane that pairs the encoded term with a decoded one ran, then compares against the reindexed ledger. On main, 14 of the 16 cases fail.
Contributor
Author
|
Superseded by #2010. Its |
1 task done
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.
Problem
Terms committed after the last index build compared unequal to themselves when one side of a comparison came from a batched index lane and the other from VALUES, a UNION branch, or a scan over novelty. Wrong answers, no error:
VALUES ?o { "new" "old" } ?d a :C ; :p ?odropped the rows whose string first appeared after the last index build.?r :type ?t . VALUES ?t { :A :B } FILTER NOT EXISTS { ?r :template ?a }returned a new subject that has a template; OPTIONAL +!BOUNDdid the same, and EXISTS dropped it.FILTER(sameTerm(?r, :new))was false for a new subject.Each answer corrects itself after a reindex, and the single-value VALUES and
FILTER INforms were unaffected, which is why it read as intermittent.Cause
The batched probe lanes emit
EncodedSid/EncodedLitunder novelty, carryingDictNoveltyids for subjects and strings the index has not seen. Equality surfaces normalize decoded bindings to that encoded form throughencoded_equivalent, which looked only in the persisted dictionaries, on the premise that encoded bindings never carry novelty ids. It also skipped blank-node subjects, though skolemized blank nodes are subject-dictionary entries that index lanes emit encoded. The SAMETERM fast path had its own persisted-only lookup.Change
One value → id lookup and one normalizer for every site:
DictLookup(fluree-db-binary-index): persisted dictionaries, thenDictNovelty, in the orderpopulate_dict_novelty_safeallocates. Exposed asBinaryGraphView::dict_lookup()andExecutionContext::dict_lookup(). Replaces the hand-rolled copies in the binary scan and range providers, batched join / OPTIONAL / property-join key resolution, the annotation probe (Dicts), fulltext andDictOverlay.EqualityNorm::for_ctxcarries the store, the novelty layer and the graph view.normalize_for_keyandbinding_to_group_key_normalizedtake it in place of loose store/view pairs;equality_norm_store,normalize_for_key_cowandEqualityNorm::partsare removed. DISTINCT, both GROUP BY operators, COUNT(DISTINCT), MINUS, semijoin, VALUES, subquery, range semijoin, membership join, the annotation probe, R2RML and the hash join all key through it. The hash join's privateJoinKey/Sid lookup is gone, and VALUES and the SQL lane build their norm once per open instead of per comparison.Behavior notes beyond the fix: the streaming GROUP BY now normalizes on a dataset spanning several graphs of one ledger, as DISTINCT already did; the hash join and R2RML no longer normalize on multi-ledger datasets, where no lane emits encoded bindings.
Paths checked and left persisted-only
These look up subjects in the persisted dictionaries alone by design: they read index leaflets, which hold no novelty ids.
frontier.rs— a node without a persisted id isPathNode::Novel.sid_iri::sid_to_store_s_id— leaflet scan filters.filter.rsEXISTS cache and thefast_path_commonlookups — behindfast_path_store, which declines whenever novelty is present.Language tags need no novelty lookup: overlay translation refuses a tag the index has not seen and keeps those values decoded.
Tests
it_novelty_encoded_equality.rsindexes a base, adds a novelty tail, and asserts explicit rows, then reindexes and requires identical answers. Each case also asserts the lane that pairs the encoded term with a decoded one actually ran (property-join completion event, subject/object batched flush span, orHashJoinOperatorin the physical plan), so a planner change cannot leave a case passing vacuously. SPARQL cases have JSON-LD twins for VALUES, NOT EXISTS, sameTerm and the hash join.Mutation checks:
EqualityNorm::normalizefails the 10 VALUES / EXISTS / NOT EXISTS / OPTIONAL / DISTINCT / MINUS / GROUP BY cases.