mini\Table\Index\TreapIndex final class

Documentation

Hybrid hash/sorted-array/treap index optimized for real-world access patterns.

Three stages based on usage:

  1. Hash only: eq() lookups, no range yet
  2. Sorted array: first range() called, assume no more inserts
  3. Treap: insert after range, convert sorted→treap once, stay in treap

This avoids merge overhead by using only one structure at a time for range().

Inheritance

Implements: mini\Table\Index\IndexInterface mini\Table\Index\HashIndexInterface

Constants (3)

Name Value
MODE_HASH 0
MODE_SORTED 1
MODE_TREAP 2

Properties (4)

private array $hash
private int $mode
private ?array $sorted
private ?mini\Table\Index\TreapNode $treap

Methods (21)

Build index from a generator function.

Build index from array of [key, rowId] pairs.

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Count rowIds for a specific key.

Count unique keys.

Count total rowIds across all keys.

Clear all data from the index.

Count rowIds in a range.

Documentation missing

Convert sorted array to treap (called on first insert after range).

Build balanced treap from sorted keys.

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Treap range with blob yielding (iterative, strict pruning).

Documentation missing

Documentation missing

Source

src/Table/Index/TreapIndex.php:16-402