IndexManager class
Manages secondary indexes for Rift boxes.
The IndexManager is a singleton-like registry that holds all indexes for all open boxes. It provides methods to create, drop, and query indexes, as well as update them when data changes.
Usage:
final indexManager = IndexManager();
// Create an index
await indexManager.createIndex('users', 'age');
// Query using the index
final keys = await indexManager.queryIndex('users', 'age', 25);
// The index is automatically updated when you call
// updateIndex/removeFromIndex after box writes
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearAll(
) → void - Clear all indexes (e.g., when a box is closed).
-
createCompositeIndex(
String boxName, List< String> fields) → Future<void> - Create a composite index on multiple fields.
-
createIndex(
String boxName, String field, {IndexType type = IndexType.btree}) → Future< void> - Create a secondary index on a field of a box.
-
dropAllIndexes(
String boxName) → Future< void> - Drop all indexes for a box.
-
dropIndex(
String boxName, String field) → Future< void> - Drop (remove) an index.
-
getCompositeIndexes(
String boxName) → List< CompositeIndex> - Get all composite indexes for a box.
-
getFieldExtractor(
String boxName) → FieldValueExtractor - Get the field value extractor for a box.
-
getIndex(
String boxName, String field) → SecondaryIndex? - Get the secondary index for a box and field, or null if not indexed.
-
hasIndex(
String boxName, String field) → bool - Check if an index exists for a box and field.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
queryIndex(
String boxName, String field, dynamic value, {IndexOperator op = IndexOperator.eq}) → Future< List> - Query a secondary index.
-
rebuildIndexes(
String boxName, Iterable< MapEntry> entries) → Future<void> - Rebuild all indexes for a box from scratch.
-
registerFieldExtractor(
String boxName, FieldValueExtractor extractor) → void - Register a custom field value extractor for a box.
-
removeFromIndex(
String boxName, dynamic key, dynamic value) → Future< void> - Remove from the index after a delete.
-
removeFromIndexByPrimaryKey(
String boxName, dynamic key) → Future< void> - Remove a primary key from all indexes without knowing its field value.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateIndex(
String boxName, dynamic key, dynamic value) → Future< void> - Update the index after a write (put/add).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited