Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove dup cache consts and respect index size param #2948

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions rust/lance-core/src/cache.rs
Original file line number Diff line number Diff line change
@@ -14,9 +14,6 @@ use object_store::path::Path;
use crate::utils::path::LancePathExt;
use crate::Result;

pub const DEFAULT_INDEX_CACHE_SIZE: usize = 128;
pub const DEFAULT_METADATA_CACHE_SIZE: usize = 128;

type ArcAny = Arc<dyn Any + Send + Sync>;

#[derive(Clone)]
9 changes: 9 additions & 0 deletions rust/lance/src/index/cache.rs
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ use moka::sync::{Cache, ConcurrentCacheExt};

use std::sync::atomic::{AtomicU64, Ordering};

use crate::dataset::DEFAULT_INDEX_CACHE_SIZE;

#[derive(Debug, Default, DeepSizeOf)]
struct CacheStats {
hits: AtomicU64,
@@ -71,6 +73,13 @@ impl IndexCache {
}
}

pub(crate) fn capacity(&self) -> u64 {
self.vector_cache
.policy()
.max_capacity()
.unwrap_or(DEFAULT_INDEX_CACHE_SIZE as u64)
}

#[allow(dead_code)]
pub(crate) fn len_vector(&self) -> usize {
self.vector_cache.sync();
5 changes: 3 additions & 2 deletions rust/lance/src/index/vector/ivf/v2.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ use futures::prelude::stream::{self, StreamExt, TryStreamExt};
use lance_arrow::RecordBatchExt;
use lance_core::cache::FileMetadataCache;
use lance_core::utils::tokio::get_num_compute_intensive_cpus;
use lance_core::{cache::DEFAULT_INDEX_CACHE_SIZE, Error, Result};
use lance_core::{Error, Result};
use lance_encoding::decoder::{DecoderMiddlewareChain, FilterExpression};
use lance_file::v2::reader::FileReader;
use lance_index::vector::flat::index::{FlatIndex, FlatQuantizer};
@@ -122,6 +122,7 @@ impl<S: IvfSubIndex + 'static, Q: Quantization> IVFIndex<S, Q> {
.upgrade()
.map(|sess| sess.file_metadata_cache.clone())
.unwrap_or_else(FileMetadataCache::no_cache);
let index_cache_capacity = session.upgrade().unwrap().index_cache.capacity();
let index_reader = FileReader::try_open(
scheduler
.open_file(&index_dir.child(uuid.as_str()).child(INDEX_FILE_NAME))
@@ -191,7 +192,7 @@ impl<S: IvfSubIndex + 'static, Q: Quantization> IVFIndex<S, Q> {
ivf,
reader: index_reader,
storage,
partition_cache: Cache::new(DEFAULT_INDEX_CACHE_SIZE as u64),
partition_cache: Cache::new(index_cache_capacity),
partition_locks: PartitionLoadLock::new(num_partitions),
sub_index_metadata,
distance_type,

Unchanged files with check annotations Beta

pub fn remove_stream<'a>(
&'a self,
locations: BoxStream<'a, Result<Path>>,
) -> BoxStream<Result<Path>> {

Check warning on line 638 in rust/lance-io/src/object_store.rs

GitHub Actions / linux-build (nightly)

elided lifetime has a name
self.inner
.delete_stream(locations.err_into::<ObjectStoreError>().boxed())
.err_into::<Error>()
fn cast_dictionary_arrays<'a, T: ArrowDictionaryKeyType + 'static>(
arrays: &'a [&'a ArrayRef],
) -> Vec<&Arc<dyn Array>> {

Check warning on line 489 in rust/lance-file/src/writer/statistics.rs

GitHub Actions / linux-build (nightly)

elided lifetime has a name
arrays
.iter()
.map(|x| x.as_dictionary::<T>().values())
fn search_values<'a>(
&'a self,
values: &'a Vec<ScalarValue>,
) -> BoxStream<Result<RowIdTreeMap>> {

Check warning on line 81 in rust/lance-index/src/scalar/label_list.rs

GitHub Actions / linux-build (nightly)

elided lifetime has a name
futures::stream::iter(values)
.then(move |value| {
let value_query = SargableQuery::Equals(value.clone());