MCPcopy Create free account
hub / github.com/cosdata/cosdata / get_object

Method get_object

src/models/cache_loader.rs:261–268  ·  view source on GitHub ↗

Retrieves an object from the cache, attempting to batch load if possible, based on the state of the batch load lock. This function first attempts to acquire the `batch_load_lock` using a non-blocking `try_lock`. If successful, it sets a high `max_loads` value (1000), allowing for a larger batch load. This is the preferred scenario where the system is capable of performing a more efficient batch l

(&self, file_index: FileIndex<IndexFileId>)

Source from the content-addressed store, hash-verified

259 // After determining the appropriate `max_loads`, the function proceeds by calling `get_lazy_object`, which handles
260 // the actual loading process, and retrieves the lazy-loaded data.
261 pub fn get_object(&self, file_index: FileIndex<IndexFileId>) -> Result<SharedNode, BufIoError> {
262 let (_lock, max_loads) = match self.batch_load_lock.try_lock() {
263 Ok(lock) => (Some(lock), 1000),
264 Err(TryLockError::Poisoned(poison_err)) => panic!("lock error: {}", poison_err),
265 Err(TryLockError::WouldBlock) => (None, 1),
266 };
267 self.get_lazy_object(file_index, max_loads, &mut FxHashSet::default())
268 }
269
270 pub fn combine_index(file_index: &FileIndex<IndexFileId>) -> u64 {
271 ((file_index.offset.0 as u64) << 32) | (*file_index.file_id as u64)

Callers 2

download_fileMethod · 0.80
try_get_dataMethod · 0.80

Calls 1

get_lazy_objectMethod · 0.80

Tested by

no test coverage detected