mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-15 01:32:56 +00:00
refactor: reduce a object store "stat" call (#4645)
This commit is contained in:
7
src/mito2/src/cache/write_cache.rs
vendored
7
src/mito2/src/cache/write_cache.rs
vendored
@@ -176,6 +176,7 @@ impl WriteCache {
|
||||
index_key: IndexKey,
|
||||
remote_path: &str,
|
||||
remote_store: &ObjectStore,
|
||||
file_size: u64,
|
||||
) -> Result<()> {
|
||||
const DOWNLOAD_READER_CONCURRENCY: usize = 8;
|
||||
const DOWNLOAD_READER_CHUNK_SIZE: ReadableSize = ReadableSize::mb(8);
|
||||
@@ -188,17 +189,13 @@ impl WriteCache {
|
||||
}])
|
||||
.start_timer();
|
||||
|
||||
let remote_metadata = remote_store
|
||||
.stat(remote_path)
|
||||
.await
|
||||
.context(error::OpenDalSnafu)?;
|
||||
let reader = remote_store
|
||||
.reader_with(remote_path)
|
||||
.concurrent(DOWNLOAD_READER_CONCURRENCY)
|
||||
.chunk(DOWNLOAD_READER_CHUNK_SIZE.as_bytes() as usize)
|
||||
.await
|
||||
.context(error::OpenDalSnafu)?
|
||||
.into_futures_async_read(0..remote_metadata.content_length())
|
||||
.into_futures_async_read(0..file_size)
|
||||
.await
|
||||
.context(error::OpenDalSnafu)?;
|
||||
|
||||
|
||||
@@ -306,9 +306,10 @@ async fn edit_region(
|
||||
|
||||
let index_key = IndexKey::new(region_id, file_meta.file_id, FileType::Parquet);
|
||||
let remote_path = location::sst_file_path(layer.region_dir(), file_meta.file_id);
|
||||
let file_size = file_meta.file_size;
|
||||
common_runtime::spawn_global(async move {
|
||||
if write_cache
|
||||
.download(index_key, &remote_path, layer.object_store())
|
||||
.download(index_key, &remote_path, layer.object_store(), file_size)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user