Remap Oracle API
RemapOracle
Bases: NamedTuple
An oracle that answers where an index has moved during a bulk edit.
Because swap-and-pop edits move row indices, references (like foreign keys) need to be remapped to their new physical locations. This oracle provides the mapping rules for a specific table during a transaction commit.
Attributes:
| Name | Type | Description |
|---|---|---|
set_null_unlinks_sorted |
ndarray
|
Sorted array of indices that should be set to null. |
deletions_sorted |
ndarray
|
Sorted array of deleted row indices. |
moves_from |
ndarray
|
Sorted array of original row indices that were relocated. |
moves_to |
ndarray
|
The new physical indices corresponding to |
moves_to_sorted |
ndarray
|
A sorted version of |
addition_destinations |
ndarray
|
Array of indices where new staged rows were placed. |
staged_indices_start |
int
|
The index where staged (newly added) rows begin. |
new_size |
int
|
The total physical size of the table after the edit. |
missing_index_sentinel |
int
|
The integer sentinel representing a missing link. |
Source code in src/packed_data_structures/remap_oracle.py
oracle_resolve
Translates a single index through a RemapOracle.
This resolves
- staged indices (newly added entries)
- moved indices (swap-and-pop relocations)
- overwritten indices
- explicit deletions
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
The original index to resolve. |
required |
oracle
|
RemapOracle
|
The oracle containing mapping rules. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The final physical index, or the missing sentinel if deleted/voided. |
Source code in src/packed_data_structures/remap_oracle.py
oracle_resolve_array
Translate a list of indices through a RemapOracle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ndarray
|
Array of indices referencing the oracle's table. |
required |
oracle
|
RemapOracle
|
RemapOracle for the referenced table. |
required |
inplace
|
bool
|
Preform the update in-place on the provided values array. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array with all indices translated to final physical indices. |