Skip to content

Range lane narrows a bare string constant to xsd:string, and reads a whole predicate for a language-tagged one #2072

Open

Description

@aaj3f

The range provider's string arm (fluree-db-query/src/binary_range.rs, the FlakeValue::String arm of the bound-object encoding) narrows a bound string with no datatype to xsd:string, and RangeMatch (fluree-db-core/src/query_bounds.rs) has no language. The root (binary-scan) lane reads the same constant as any string datatype or language tag, as documented, so the two lanes can answer the same query differently. #2010 fixes typed and language-tagged constants on the range lane; what's left is the untyped case, and the cost of the tagged one.

Where it shows: a JSON-LD bare-string constant served by the range lane, meaning a predicate a non-root view policy covers, or each member of a dataset spanning ledgers. There it matches xsd:string rows only. And with #2010, a language-tagged constant on that lane reads its whole predicate and checks the tag per row: 1.62 ms against 0.16 ms on the root lane at 60,000 rows (a debug build). Main answers that lookup with no rows, so this one is a cost rather than wrong rows, but it's linear in the predicate.

  • "No datatype" means any string datatype, with a tight range per string o_type. A string twin of untyped_numeric_slices (binary_scan.rs), say untyped_string_slices(store, g_id, p_id, observed, str_id), returning one ObjectSlice per string o_type the predicate can hold, each at o_key = str_id. Every string o_type shares the interned id, so each slice is a point seek: xsd:string always; each other string-kinded XSD datatype in the predicate's observed datatypes; lang_string(lang_id) per language when LANG_STRING is observed or stats are absent; and custom datatypes when stats show one. The range provider already builds one filter per slice (object_slice_filters), as it does for untyped numerics. Whether rdf:JSON counts as a string datatype here is a call to make; the documented rule says "string datatypes or language tags".
  • A language-tagged constant gets a tight range. Carry the tag (lang: Option<Arc<str>> on RangeMatch, with a with_lang builder) and seek (lang_string(resolve_lang_id(tag)), str_id); an unknown tag goes overlay-only. That's non-breaking for every RangeMatch { …, ..Default::default() } literal, and the one literal that lists every field is in binary_history.rs. (Putting it on RangeOptions instead avoids touching RangeMatch, but it's a less natural home for a match criterion.)
  • Optional: the root lane's untyped-string path uses the same slices instead of its wild-o_type o_key filter, so both lanes share one resolution and a predicate-range read becomes k point seeks.

Edge cases: an empty slice list (the string isn't in the dictionary) goes overlay-only as today, and the novelty side already matches by value when dt is None. In a correlated join that opens a scan per driving row, we may want to cache the slice list per (operator, predicate), since only str_id changes per row.

Tests I'd want: the lane differential (root against an allow-all policy) on SPARQL and JSON-LD, a dataset of two ledgers, and a cost check for the tagged constant.

From #2010 (Not changed here: the range scan's string arm).

Activity

  1. added
    bug
    P2
    area:query
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2area:querybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions