mirror of
https://github.com/qdrant/qdrant.git
synced 2026-09-21 13:37:46 -05:00
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:
@@ -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,
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+43
@@ -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`].
|
||||
|
||||
Reference in New Issue
Block a user