mito2/
access_layer.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::sync::Arc;
16use std::time::{Duration, Instant};
17
18use async_stream::try_stream;
19use common_time::Timestamp;
20use futures::{Stream, TryStreamExt};
21use object_store::services::Fs;
22use object_store::util::{join_dir, with_instrument_layers};
23use object_store::{ATOMIC_WRITE_DIR, ErrorKind, OLD_ATOMIC_WRITE_DIR, ObjectStore};
24use smallvec::SmallVec;
25use snafu::ResultExt;
26use store_api::metadata::RegionMetadataRef;
27use store_api::region_request::PathType;
28use store_api::sst_entry::StorageSstEntry;
29use store_api::storage::{FileId, RegionId, SequenceNumber};
30
31use crate::cache::CacheManagerRef;
32use crate::cache::file_cache::{FileCacheRef, FileType, IndexKey};
33use crate::cache::write_cache::SstUploadRequest;
34use crate::config::{BloomFilterConfig, FulltextIndexConfig, IndexConfig, InvertedIndexConfig};
35use crate::error::{
36    CleanDirSnafu, DeleteIndexSnafu, DeleteIndexesSnafu, DeleteSstsSnafu, OpenDalSnafu, Result,
37};
38use crate::metrics::{COMPACTION_STAGE_ELAPSED, FLUSH_ELAPSED};
39use crate::read::FlatSource;
40use crate::region::options::IndexOptions;
41use crate::sst::file::{FileHandle, RegionFileId, RegionIndexId};
42use crate::sst::index::IndexerBuilderImpl;
43use crate::sst::index::intermediate::IntermediateManager;
44use crate::sst::index::puffin_manager::{PuffinManagerFactory, SstPuffinManager};
45use crate::sst::location::{self, region_dir_from_table_dir};
46use crate::sst::parquet::reader::ParquetReaderBuilder;
47use crate::sst::parquet::writer::ParquetWriter;
48use crate::sst::parquet::{SstInfo, WriteOptions};
49use crate::sst::{DEFAULT_WRITE_BUFFER_SIZE, DEFAULT_WRITE_CONCURRENCY, FormatType};
50
51pub type AccessLayerRef = Arc<AccessLayer>;
52/// SST write results.
53pub type SstInfoArray = SmallVec<[SstInfo; 2]>;
54
55/// Write operation type.
56#[derive(Eq, PartialEq, Debug)]
57pub enum WriteType {
58    /// Writes from flush
59    Flush,
60    /// Writes from compaction.
61    Compaction,
62}
63
64#[derive(Debug)]
65pub struct Metrics {
66    pub(crate) write_type: WriteType,
67    pub(crate) iter_source: Duration,
68    pub(crate) write_batch: Duration,
69    pub(crate) update_index: Duration,
70    pub(crate) upload_parquet: Duration,
71    pub(crate) upload_puffin: Duration,
72    pub(crate) compact_memtable: Duration,
73}
74
75impl Metrics {
76    pub fn new(write_type: WriteType) -> Self {
77        Self {
78            write_type,
79            iter_source: Default::default(),
80            write_batch: Default::default(),
81            update_index: Default::default(),
82            upload_parquet: Default::default(),
83            upload_puffin: Default::default(),
84            compact_memtable: Default::default(),
85        }
86    }
87
88    pub(crate) fn merge(mut self, other: Self) -> Self {
89        assert_eq!(self.write_type, other.write_type);
90        self.iter_source += other.iter_source;
91        self.write_batch += other.write_batch;
92        self.update_index += other.update_index;
93        self.upload_parquet += other.upload_parquet;
94        self.upload_puffin += other.upload_puffin;
95        self.compact_memtable += other.compact_memtable;
96        self
97    }
98
99    pub(crate) fn observe(self) {
100        match self.write_type {
101            WriteType::Flush => {
102                FLUSH_ELAPSED
103                    .with_label_values(&["iter_source"])
104                    .observe(self.iter_source.as_secs_f64());
105                FLUSH_ELAPSED
106                    .with_label_values(&["write_batch"])
107                    .observe(self.write_batch.as_secs_f64());
108                FLUSH_ELAPSED
109                    .with_label_values(&["update_index"])
110                    .observe(self.update_index.as_secs_f64());
111                FLUSH_ELAPSED
112                    .with_label_values(&["upload_parquet"])
113                    .observe(self.upload_parquet.as_secs_f64());
114                FLUSH_ELAPSED
115                    .with_label_values(&["upload_puffin"])
116                    .observe(self.upload_puffin.as_secs_f64());
117                if !self.compact_memtable.is_zero() {
118                    FLUSH_ELAPSED
119                        .with_label_values(&["compact_memtable"])
120                        .observe(self.upload_puffin.as_secs_f64());
121                }
122            }
123            WriteType::Compaction => {
124                COMPACTION_STAGE_ELAPSED
125                    .with_label_values(&["iter_source"])
126                    .observe(self.iter_source.as_secs_f64());
127                COMPACTION_STAGE_ELAPSED
128                    .with_label_values(&["write_batch"])
129                    .observe(self.write_batch.as_secs_f64());
130                COMPACTION_STAGE_ELAPSED
131                    .with_label_values(&["update_index"])
132                    .observe(self.update_index.as_secs_f64());
133                COMPACTION_STAGE_ELAPSED
134                    .with_label_values(&["upload_parquet"])
135                    .observe(self.upload_parquet.as_secs_f64());
136                COMPACTION_STAGE_ELAPSED
137                    .with_label_values(&["upload_puffin"])
138                    .observe(self.upload_puffin.as_secs_f64());
139            }
140        };
141    }
142}
143
144/// A layer to access SST files under the same directory.
145pub struct AccessLayer {
146    table_dir: String,
147    /// Path type for generating file paths.
148    path_type: PathType,
149    /// Target object store.
150    object_store: ObjectStore,
151    /// Puffin manager factory for index.
152    puffin_manager_factory: PuffinManagerFactory,
153    /// Intermediate manager for inverted index.
154    intermediate_manager: IntermediateManager,
155}
156
157impl std::fmt::Debug for AccessLayer {
158    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
159        f.debug_struct("AccessLayer")
160            .field("table_dir", &self.table_dir)
161            .finish()
162    }
163}
164
165impl AccessLayer {
166    /// Returns a new [AccessLayer] for specific `table_dir`.
167    pub fn new(
168        table_dir: impl Into<String>,
169        path_type: PathType,
170        object_store: ObjectStore,
171        puffin_manager_factory: PuffinManagerFactory,
172        intermediate_manager: IntermediateManager,
173    ) -> AccessLayer {
174        AccessLayer {
175            table_dir: table_dir.into(),
176            path_type,
177            object_store,
178            puffin_manager_factory,
179            intermediate_manager,
180        }
181    }
182
183    /// Returns the directory of the table.
184    pub fn table_dir(&self) -> &str {
185        &self.table_dir
186    }
187
188    /// Returns the object store of the layer.
189    pub fn object_store(&self) -> &ObjectStore {
190        &self.object_store
191    }
192
193    /// Returns the path type of the layer.
194    pub fn path_type(&self) -> PathType {
195        self.path_type
196    }
197
198    /// Returns the puffin manager factory.
199    pub fn puffin_manager_factory(&self) -> &PuffinManagerFactory {
200        &self.puffin_manager_factory
201    }
202
203    /// Returns the intermediate manager.
204    pub fn intermediate_manager(&self) -> &IntermediateManager {
205        &self.intermediate_manager
206    }
207
208    /// Build the puffin manager.
209    pub(crate) fn build_puffin_manager(&self) -> SstPuffinManager {
210        let store = self.object_store.clone();
211        let path_provider =
212            RegionFilePathFactory::new(self.table_dir().to_string(), self.path_type());
213        self.puffin_manager_factory.build(store, path_provider)
214    }
215
216    pub(crate) async fn delete_index(
217        &self,
218        index_file_id: RegionIndexId,
219    ) -> Result<(), crate::error::Error> {
220        let path = location::index_file_path(
221            &self.table_dir,
222            RegionIndexId::new(index_file_id.file_id, index_file_id.version),
223            self.path_type,
224        );
225        self.object_store
226            .delete(&path)
227            .await
228            .context(DeleteIndexSnafu {
229                file_id: index_file_id.file_id(),
230            })?;
231        Ok(())
232    }
233
234    pub(crate) async fn delete_ssts(
235        &self,
236        region_id: RegionId,
237        file_ids: &[FileId],
238    ) -> Result<(), crate::error::Error> {
239        if file_ids.is_empty() {
240            return Ok(());
241        }
242
243        let attempted_files = file_ids.to_vec();
244        let paths: Vec<_> = file_ids
245            .iter()
246            .map(|file_id| {
247                location::sst_file_path(
248                    &self.table_dir,
249                    RegionFileId::new(region_id, *file_id),
250                    self.path_type,
251                )
252            })
253            .collect();
254
255        let mut deleter = self
256            .object_store
257            .deleter()
258            .await
259            .with_context(|_| DeleteSstsSnafu {
260                region_id,
261                file_ids: attempted_files.clone(),
262            })?;
263        deleter
264            .delete_iter(paths.iter().map(String::as_str))
265            .await
266            .with_context(|_| DeleteSstsSnafu {
267                region_id,
268                file_ids: attempted_files.clone(),
269            })?;
270        deleter.close().await.with_context(|_| DeleteSstsSnafu {
271            region_id,
272            file_ids: attempted_files,
273        })?;
274
275        Ok(())
276    }
277
278    pub(crate) async fn delete_indexes(
279        &self,
280        index_ids: &[RegionIndexId],
281    ) -> Result<(), crate::error::Error> {
282        if index_ids.is_empty() {
283            return Ok(());
284        }
285
286        let file_ids: Vec<_> = index_ids
287            .iter()
288            .map(|index_id| index_id.file_id())
289            .collect();
290        let paths: Vec<_> = index_ids
291            .iter()
292            .map(|index_id| location::index_file_path(&self.table_dir, *index_id, self.path_type))
293            .collect();
294
295        let mut deleter = self
296            .object_store
297            .deleter()
298            .await
299            .context(DeleteIndexesSnafu {
300                file_ids: file_ids.clone(),
301            })?;
302        deleter
303            .delete_iter(paths.iter().map(String::as_str))
304            .await
305            .context(DeleteIndexesSnafu {
306                file_ids: file_ids.clone(),
307            })?;
308        deleter
309            .close()
310            .await
311            .context(DeleteIndexesSnafu { file_ids })?;
312
313        Ok(())
314    }
315
316    /// Returns the directory of the region in the table.
317    pub fn build_region_dir(&self, region_id: RegionId) -> String {
318        region_dir_from_table_dir(&self.table_dir, region_id, self.path_type)
319    }
320
321    /// Returns a reader builder for specific `file`.
322    pub(crate) fn read_sst(&self, file: FileHandle) -> ParquetReaderBuilder {
323        ParquetReaderBuilder::new(
324            self.table_dir.clone(),
325            self.path_type,
326            file,
327            self.object_store.clone(),
328        )
329    }
330
331    /// Writes a SST with specific `file_id` and `metadata` to the layer.
332    ///
333    /// Returns the info of the SST. If no data written, returns None.
334    pub async fn write_sst(
335        &self,
336        request: SstWriteRequest,
337        write_opts: &WriteOptions,
338        metrics: &mut Metrics,
339    ) -> Result<SstInfoArray> {
340        let region_id = request.metadata.region_id;
341        let cache_manager = request.cache_manager.clone();
342
343        let sst_info = if let Some(write_cache) = cache_manager.write_cache() {
344            // Write to the write cache.
345            write_cache
346                .write_and_upload_sst(
347                    request,
348                    SstUploadRequest {
349                        dest_path_provider: RegionFilePathFactory::new(
350                            self.table_dir.clone(),
351                            self.path_type,
352                        ),
353                        remote_store: self.object_store.clone(),
354                    },
355                    write_opts,
356                    metrics,
357                )
358                .await?
359        } else {
360            // Write cache is disabled.
361            let store = self.object_store.clone();
362            let path_provider = RegionFilePathFactory::new(self.table_dir.clone(), self.path_type);
363            let indexer_builder = IndexerBuilderImpl {
364                build_type: request.op_type.into(),
365                metadata: request.metadata.clone(),
366                row_group_size: write_opts.row_group_size,
367                puffin_manager: self
368                    .puffin_manager_factory
369                    .build(store, path_provider.clone()),
370                write_cache_enabled: false,
371                intermediate_manager: self.intermediate_manager.clone(),
372                index_options: request.index_options,
373                inverted_index_config: request.inverted_index_config,
374                fulltext_index_config: request.fulltext_index_config,
375                bloom_filter_index_config: request.bloom_filter_index_config,
376                #[cfg(feature = "vector_index")]
377                vector_index_config: request.vector_index_config,
378            };
379            // We disable write cache on file system but we still use atomic write.
380            // TODO(yingwen): If we support other non-fs stores without the write cache, then
381            // we may have find a way to check whether we need the cleaner.
382            let cleaner = TempFileCleaner::new(region_id, self.object_store.clone());
383            let mut writer = ParquetWriter::new_with_object_store(
384                self.object_store.clone(),
385                request.metadata,
386                request.index_config,
387                indexer_builder,
388                path_provider,
389                metrics,
390            )
391            .await
392            .with_file_cleaner(cleaner);
393            match request.sst_write_format {
394                FormatType::PrimaryKey => {
395                    writer
396                        .write_all_flat_as_primary_key(
397                            request.source,
398                            request.max_sequence,
399                            write_opts,
400                        )
401                        .await?
402                }
403                FormatType::Flat => {
404                    writer
405                        .write_all_flat(request.source, request.max_sequence, write_opts)
406                        .await?
407                }
408            }
409        };
410
411        // Put parquet metadata to cache manager.
412        if !sst_info.is_empty() {
413            for sst in &sst_info {
414                if let Some(parquet_metadata) = &sst.file_metadata {
415                    cache_manager.put_parquet_meta_data(
416                        RegionFileId::new(region_id, sst.file_id),
417                        parquet_metadata.clone(),
418                    )
419                }
420            }
421        }
422
423        Ok(sst_info)
424    }
425
426    /// Puts encoded SST bytes to the write cache (if enabled) and uploads it to the object store.
427    pub(crate) async fn put_sst(
428        &self,
429        data: &bytes::Bytes,
430        region_id: RegionId,
431        sst_info: &SstInfo,
432        cache_manager: &CacheManagerRef,
433    ) -> Result<Metrics> {
434        if let Some(write_cache) = cache_manager.write_cache() {
435            // Write to cache and upload to remote store
436            let upload_request = SstUploadRequest {
437                dest_path_provider: RegionFilePathFactory::new(
438                    self.table_dir.clone(),
439                    self.path_type,
440                ),
441                remote_store: self.object_store.clone(),
442            };
443            write_cache
444                .put_and_upload_sst(data, region_id, sst_info, upload_request)
445                .await
446        } else {
447            let start = Instant::now();
448            let cleaner = TempFileCleaner::new(region_id, self.object_store.clone());
449            let path_provider = RegionFilePathFactory::new(self.table_dir.clone(), self.path_type);
450            let sst_file_path =
451                path_provider.build_sst_file_path(RegionFileId::new(region_id, sst_info.file_id));
452            let mut writer = self
453                .object_store
454                .writer_with(&sst_file_path)
455                .chunk(DEFAULT_WRITE_BUFFER_SIZE.as_bytes() as usize)
456                .concurrent(DEFAULT_WRITE_CONCURRENCY)
457                .await
458                .context(OpenDalSnafu)?;
459            if let Err(err) = writer.write(data.clone()).await.context(OpenDalSnafu) {
460                cleaner.clean_by_file_id(sst_info.file_id).await;
461                return Err(err);
462            }
463            if let Err(err) = writer.close().await.context(OpenDalSnafu) {
464                cleaner.clean_by_file_id(sst_info.file_id).await;
465                return Err(err);
466            }
467            let mut metrics = Metrics::new(WriteType::Flush);
468            metrics.write_batch = start.elapsed();
469            Ok(metrics)
470        }
471    }
472
473    /// Lists the SST entries from the storage layer in the table directory.
474    pub fn storage_sst_entries(&self) -> impl Stream<Item = Result<StorageSstEntry>> + use<> {
475        let object_store = self.object_store.clone();
476        let table_dir = self.table_dir.clone();
477
478        try_stream! {
479            let mut lister = object_store
480                .lister_with(table_dir.as_str())
481                .recursive(true)
482                .await
483                .context(OpenDalSnafu)?;
484
485            while let Some(entry) = lister.try_next().await.context(OpenDalSnafu)? {
486                let metadata = entry.metadata();
487                if metadata.is_dir() {
488                    continue;
489                }
490
491                let path = entry.path();
492                if !path.ends_with(".parquet") && !path.ends_with(".puffin") {
493                    continue;
494                }
495
496                let file_size = metadata.content_length();
497                let file_size = if file_size == 0 { None } else { Some(file_size) };
498                let last_modified_ms = metadata
499                    .last_modified()
500                    .map(|ts| Timestamp::new_millisecond(ts.timestamp_millis()));
501
502                let entry = StorageSstEntry {
503                    file_path: path.to_string(),
504                    file_size,
505                    last_modified_ms,
506                    node_id: None,
507                };
508
509                yield entry;
510            }
511        }
512    }
513}
514
515/// `OperationType` represents the origin of the `SstWriteRequest`.
516#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
517pub enum OperationType {
518    Flush,
519    Compact,
520}
521
522/// Contents to build a SST.
523pub struct SstWriteRequest {
524    pub op_type: OperationType,
525    pub metadata: RegionMetadataRef,
526    pub source: FlatSource,
527    pub cache_manager: CacheManagerRef,
528    #[allow(dead_code)]
529    pub storage: Option<String>,
530    pub max_sequence: Option<SequenceNumber>,
531    pub sst_write_format: FormatType,
532
533    /// Configs for index
534    pub index_options: IndexOptions,
535    pub index_config: IndexConfig,
536    pub inverted_index_config: InvertedIndexConfig,
537    pub fulltext_index_config: FulltextIndexConfig,
538    pub bloom_filter_index_config: BloomFilterConfig,
539    #[cfg(feature = "vector_index")]
540    pub vector_index_config: crate::config::VectorIndexConfig,
541}
542
543/// Cleaner to remove temp files on the atomic write dir.
544pub(crate) struct TempFileCleaner {
545    region_id: RegionId,
546    object_store: ObjectStore,
547}
548
549impl TempFileCleaner {
550    /// Constructs the cleaner for the region and store.
551    pub(crate) fn new(region_id: RegionId, object_store: ObjectStore) -> Self {
552        Self {
553            region_id,
554            object_store,
555        }
556    }
557
558    /// Removes the SST and index file from the local atomic dir by the file id.
559    /// This only removes the initial index, since the index version is always 0 for a new SST, this method should be safe to pass 0.
560    pub(crate) async fn clean_by_file_id(&self, file_id: FileId) {
561        let sst_key = IndexKey::new(self.region_id, file_id, FileType::Parquet).to_string();
562        let index_key = IndexKey::new(self.region_id, file_id, FileType::Puffin(0)).to_string();
563
564        Self::clean_atomic_dir_files(&self.object_store, &[&sst_key, &index_key]).await;
565    }
566
567    /// Removes the files from the local atomic dir by their names.
568    pub(crate) async fn clean_atomic_dir_files(
569        local_store: &ObjectStore,
570        names_to_remove: &[&str],
571    ) {
572        // We don't know the actual suffix of the file under atomic dir, so we have
573        // to list the dir. The cost should be acceptable as there won't be to many files.
574        let Ok(entries) = local_store.list(ATOMIC_WRITE_DIR).await.inspect_err(|e| {
575            if e.kind() != ErrorKind::NotFound {
576                common_telemetry::error!(e; "Failed to list tmp files for {:?}", names_to_remove)
577            }
578        }) else {
579            return;
580        };
581
582        // In our case, we can ensure the file id is unique so it is safe to remove all files
583        // with the same file id under the atomic write dir.
584        let actual_files: Vec<_> = entries
585            .into_iter()
586            .filter_map(|entry| {
587                if entry.metadata().is_dir() {
588                    return None;
589                }
590
591                // Remove name that matches files_to_remove.
592                let should_remove = names_to_remove
593                    .iter()
594                    .any(|file| entry.name().starts_with(file));
595                if should_remove {
596                    Some(entry.path().to_string())
597                } else {
598                    None
599                }
600            })
601            .collect();
602
603        common_telemetry::warn!(
604            "Clean files {:?} under atomic write dir for {:?}",
605            actual_files,
606            names_to_remove
607        );
608
609        if let Err(e) = local_store.delete_iter(actual_files).await {
610            common_telemetry::error!(e; "Failed to delete tmp file for {:?}", names_to_remove);
611        }
612    }
613}
614
615pub(crate) async fn new_fs_cache_store(root: &str) -> Result<ObjectStore> {
616    let atomic_write_dir = join_dir(root, ATOMIC_WRITE_DIR);
617    clean_dir(&atomic_write_dir).await?;
618
619    // Compatible code. Remove this after a major release.
620    let old_atomic_temp_dir = join_dir(root, OLD_ATOMIC_WRITE_DIR);
621    clean_dir(&old_atomic_temp_dir).await?;
622
623    let builder = Fs::default().root(root).atomic_write_dir(&atomic_write_dir);
624    let store = ObjectStore::new(builder).context(OpenDalSnafu)?.finish();
625
626    Ok(with_instrument_layers(store, false))
627}
628
629/// Clean the directory.
630async fn clean_dir(dir: &str) -> Result<()> {
631    if tokio::fs::try_exists(dir)
632        .await
633        .context(CleanDirSnafu { dir })?
634    {
635        tokio::fs::remove_dir_all(dir)
636            .await
637            .context(CleanDirSnafu { dir })?;
638    }
639
640    Ok(())
641}
642
643/// Path provider for SST file and index file.
644pub trait FilePathProvider: Send + Sync {
645    /// Creates index file path of given file id. Version default to 0, and not shown in the path.
646    fn build_index_file_path(&self, file_id: RegionFileId) -> String;
647
648    /// Creates index file path of given index id (with version support).
649    fn build_index_file_path_with_version(&self, index_id: RegionIndexId) -> String;
650
651    /// Creates SST file path of given file id.
652    fn build_sst_file_path(&self, file_id: RegionFileId) -> String;
653}
654
655/// Path provider that builds paths in local write cache.
656#[derive(Clone)]
657pub(crate) struct WriteCachePathProvider {
658    file_cache: FileCacheRef,
659}
660
661impl WriteCachePathProvider {
662    /// Creates a new `WriteCachePathProvider` instance.
663    pub fn new(file_cache: FileCacheRef) -> Self {
664        Self { file_cache }
665    }
666}
667
668impl FilePathProvider for WriteCachePathProvider {
669    fn build_index_file_path(&self, file_id: RegionFileId) -> String {
670        let puffin_key = IndexKey::new(file_id.region_id(), file_id.file_id(), FileType::Puffin(0));
671        self.file_cache.cache_file_path(puffin_key)
672    }
673
674    fn build_index_file_path_with_version(&self, index_id: RegionIndexId) -> String {
675        let puffin_key = IndexKey::new(
676            index_id.region_id(),
677            index_id.file_id(),
678            FileType::Puffin(index_id.version),
679        );
680        self.file_cache.cache_file_path(puffin_key)
681    }
682
683    fn build_sst_file_path(&self, file_id: RegionFileId) -> String {
684        let parquet_file_key =
685            IndexKey::new(file_id.region_id(), file_id.file_id(), FileType::Parquet);
686        self.file_cache.cache_file_path(parquet_file_key)
687    }
688}
689
690/// Path provider that builds paths in region storage path.
691#[derive(Clone, Debug)]
692pub(crate) struct RegionFilePathFactory {
693    pub(crate) table_dir: String,
694    pub(crate) path_type: PathType,
695}
696
697impl RegionFilePathFactory {
698    /// Creates a new `RegionFilePathFactory` instance.
699    pub fn new(table_dir: String, path_type: PathType) -> Self {
700        Self {
701            table_dir,
702            path_type,
703        }
704    }
705}
706
707impl FilePathProvider for RegionFilePathFactory {
708    fn build_index_file_path(&self, file_id: RegionFileId) -> String {
709        location::index_file_path_legacy(&self.table_dir, file_id, self.path_type)
710    }
711
712    fn build_index_file_path_with_version(&self, index_id: RegionIndexId) -> String {
713        location::index_file_path(&self.table_dir, index_id, self.path_type)
714    }
715
716    fn build_sst_file_path(&self, file_id: RegionFileId) -> String {
717        location::sst_file_path(&self.table_dir, file_id, self.path_type)
718    }
719}