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.

§Indexing and 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. The system achieves this by:

  1. Canonicalization: Component properties are sorted based on their unique identifiers.
  2. Shared Indexes: The index subsystem reuses a single Index instance for all multi-properties that are equivalent up to reordering.

§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 canonical index ID. This module provides the runtime registry (MULTI_PROPERTY_INDEX_MAP) and reordering logic used by both the macro-generated code and the query engine.

Functions§

register_type_ids_to_multi_property_index
A method that registers the index ID of the multi-property tuple type that has the given list of TypeIds as its properties.
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_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_index
A method that looks up the index ID of the multi-property that has the given list of TypeIds as its properties.