refactor: reduce a object store "stat" call (#4645)

This commit is contained in:
LFC
2024-08-30 11:31:19 +08:00
committed by GitHub
parent 5e4bac2633
commit 8ea4f67e4b
2 changed files with 4 additions and 6 deletions

View File

@@ -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)?;

View File

@@ -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()
{