Skip to main content

Module multi_property

Module multi_property 

Source
Expand description

Utilities for managing and querying multi-properties.

A multi-property is a derived property composed of a tuple of other properties. They are primarily used to enable joint indexing and efficient multi-column style queries.

§Normalization

To ensure that queries can efficiently find matching indexes, multi-properties that consist of the same set of component properties are considered equivalent, regardless of their definition order. Component properties are sorted alphabetically by property name to produce a canonical identity for that unordered component set. A query with the same component set can then resolve to the index (if it exists) of an equivalent (multi-)property regardless of the order client code provides the component values.

§Query Integration

The querying subsystem uses the utilities in this module to detect when a query involving multiple individual properties can be satisfied by an existing multi-property index. If a match is found, the query can perform a fast index lookup instead of iterating over component properties.

§Implementation Details

Multi-properties are defined using the define_multi_property! macro, which handles the registration and mapping between the property set and its representative property ID. This module provides the runtime registries and reordering logic used by both the macro-generated code and the query engine.

Functions§

register_type_ids_to_multi_property_id
Registers the representative multi-property ID for an unordered component set.
static_apply_reordering
Reorders the values in place according to the ordering defined by indices. The indices is an ordering produced by sorted_indices/static_sorted_indices and encodes the sorted order of the keys (the names of the tag types).
static_inverse_indices
Returns the inverse of a reordering produced by static_sorted_indices.
static_reorder_by_keys
Reorder values in place according to the sorted order of keys.
static_sorted_indices
Returns the indices of keys in sorted order. These indices are used to reorder some other array according to the sorted order of the keys, e.g. by static_apply_reordering.
type_ids_to_multi_property_id
Looks up the representative multi-property ID for a sorted list of component TypeIds.