Skip to content

Commit

Permalink
feat: distinguish intermediate store and index store
Browse files Browse the repository at this point in the history
Signed-off-by: Zhenchi <[email protected]>
  • Loading branch information
zhongzc committed Jan 9, 2024
1 parent 45f917b commit 184c3b9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/mito2/src/sst/index/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,19 @@ impl SstIndexCreator {
region_dir: String,
sst_file_id: FileId,
metadata: &RegionMetadataRef,
object_store: ObjectStore,
index_store: ObjectStore,
intermediate_store: ObjectStore, // prefer to use local store
memory_usage_threshold: Option<usize>,
row_group_size: NonZeroUsize,
) -> Self {
let store = InstrumentedStore::new(object_store);

// `memory_usage_threshold` is the total memory usage threshold of the index creation,
// so we need to divide it by the number of columns
let memory_threshold = memory_usage_threshold.map(|threshold| {
(threshold / metadata.primary_key.len()).max(MIN_MEMORY_USAGE_THRESHOLD)
});
let temp_file_provider = Arc::new(TempFileProvider::new(
IntermediateLocation::new(&region_dir, &sst_file_id),
store.clone(),
InstrumentedStore::new(intermediate_store),
));
let sorter = ExternalSorter::factory(temp_file_provider.clone() as _, memory_threshold);
let index_creator = Box::new(SortIndexCreator::new(sorter, row_group_size));
Expand All @@ -106,7 +105,7 @@ impl SstIndexCreator {
Self {
region_dir,
sst_file_id,
store,
store: InstrumentedStore::new(index_store),
codec,
index_creator,
temp_file_provider,
Expand Down

0 comments on commit 184c3b9

Please sign in to comment.