feat: implement LiveReload for geo index (#9298)

* feat: implement LiveReload for geo index

* chore: rename ingest_raw_points to ingest

* chore: rebase to dev
This commit is contained in:
Daniel Boros
2026-08-04 11:16:47 +02:00
committed by generall
parent 7f436572c1
commit 463d72531b
7 changed files with 76 additions and 3 deletions
@@ -0,0 +1,28 @@
use common::counter::hardware_counter::HardwareCounterCell;
use common::types::PointOffsetType;
use common::universal_io::UniversalRead;
use super::StoredGeoMapIndex;
use crate::common::operation_error::OperationResult;
use crate::index::field_index::LiveReload;
impl<S: UniversalRead> LiveReload for StoredGeoMapIndex<S> {
type Fs = S::Fs;
fn live_reload(
&mut self,
_fs: &S::Fs,
deleted_points: &[PointOffsetType],
_new_points: &[PointOffsetType],
_hw_counter: &HardwareCounterCell,
) -> OperationResult<()> {
// No on-disk state changes on reload: this index is immutable, so only
// the in-memory deletion bitvec is patched. `fs` / `new_points` are
// unused because nothing is appended after build.
for deleted_point in deleted_points {
self.remove_point(*deleted_point);
}
Ok(())
}
}
@@ -10,6 +10,7 @@ use crate::index::field_index::on_disk_point_to_values::OnDiskPointToValues;
use crate::types::GeoPoint;
mod lifecycle;
mod live_reload;
mod read_ops;
pub(super) const DELETED_PATH: &str = "deleted.bin";
@@ -177,7 +177,7 @@ impl InMemoryGeoMapIndex {
///
/// [1]: super::MutableGeoMapIndex::open_gridstore
/// [2]: super::read_only::ReadOnlyAppendableGeoMapIndex::open
pub fn ingest_raw_points(
pub fn ingest(
&mut self,
idx: PointOffsetType,
values: Vec<RawGeoPoint>,
@@ -53,7 +53,7 @@ impl MutableGeoMapIndex {
store
.iter::<_, OperationError>(
|idx, values: Vec<RawGeoPoint>| {
in_memory_index.ingest_raw_points(idx, values)?;
in_memory_index.ingest(idx, values)?;
Ok(true)
},
hw_counter_ref,
@@ -39,7 +39,7 @@ impl<S: UniversalRead> ReadOnlyAppendableGeoMapIndex<S> {
.iter::<_, OperationError>(
storage.max_point_offset(),
|idx, values: Vec<RawGeoPoint>| {
in_memory_index.ingest_raw_points(idx, values)?;
in_memory_index.ingest(idx, values)?;
Ok(true)
},
// Same counter the writable `open_gridstore` load uses; this is
@@ -0,0 +1,43 @@
use common::counter::hardware_counter::HardwareCounterCell;
use common::generic_consts::Random;
use common::types::PointOffsetType;
use common::universal_io::UniversalRead;
use super::ReadOnlyAppendableGeoMapIndex;
use crate::common::operation_error::{OperationError, OperationResult};
use crate::index::field_index::LiveReload;
use crate::types::RawGeoPoint;
impl<S: UniversalRead> LiveReload for ReadOnlyAppendableGeoMapIndex<S> {
type Fs = S::Fs;
fn live_reload(
&mut self,
fs: &S::Fs,
deleted_points: &[PointOffsetType],
new_points: &[PointOffsetType],
hw_counter: &HardwareCounterCell,
) -> OperationResult<()> {
self.storage.live_reload(fs)?;
let in_memory_index = &mut self.in_memory_index;
for deleted_point in deleted_points {
in_memory_index.remove_point(*deleted_point)?;
}
self.storage
.view()
.read_values::<Random, _, OperationError>(
new_points.iter().copied().enumerate(),
|_, point_offset, maybe_values: Option<Vec<RawGeoPoint>>| {
let values = maybe_values.unwrap_or_default();
in_memory_index.ingest(point_offset, values)?;
Ok(())
},
hw_counter.payload_index_io_read_counter(),
)?;
Ok(())
}
}
@@ -5,6 +5,7 @@ use super::inner::InMemoryGeoMapIndex;
use crate::types::RawGeoPoint;
mod lifecycle;
mod live_reload;
mod read_ops;
/// Read-only counterpart to [`super::MutableGeoMapIndex`].