Skip to main content

prepare_constraints_sorted

Function prepare_constraints_sorted 

Source
pub fn prepare_constraints_sorted(
    permutation: IndexPermutation,
    constraints: &[EncodedTerm],
) -> Result<Vec<EncodedTerm>, StorageError>
Expand description

Validate, dedupe, and sort constraints by encoded key bytes.

Foundation for every domain scan walk (the RocksDB legacy and parallel-walk modes, and the memory reference backend): key-order visitation is what makes the start_after resume skip sound — a cursor landing inside constraint C proves every constraint sorting before C was fully emitted on earlier pages, so dropping them loses nothing. Caller order cannot express that, which is why the walkers normalize to this order regardless of input. Byte order is iterator order — index keys are term-major byte-encoded — and distinct encoded terms are never byte-prefixes of each other (fixed-width, self-delimiting super::binary::write_term layouts), so one constraint’s key range is never nested inside another’s. With limit > 0 every mode truncates the key-first hits of this order.