mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-21 07:20:41 +00:00
feat: add metadata method to puffin reader (#5501)
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
This commit is contained in:
@@ -21,6 +21,7 @@ pub mod stager;
|
||||
mod tests;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use common_base::range_read::RangeReader;
|
||||
@@ -28,6 +29,7 @@ use futures::AsyncRead;
|
||||
|
||||
use crate::blob_metadata::CompressionCodec;
|
||||
use crate::error::Result;
|
||||
use crate::file_metadata::FileMetadata;
|
||||
|
||||
/// The `PuffinManager` trait provides a unified interface for creating `PuffinReader` and `PuffinWriter`.
|
||||
#[async_trait]
|
||||
@@ -79,6 +81,9 @@ pub trait PuffinReader {
|
||||
|
||||
fn with_file_size_hint(self, file_size_hint: Option<u64>) -> Self;
|
||||
|
||||
/// Returns the metadata of the Puffin file.
|
||||
async fn metadata(&self) -> Result<Arc<FileMetadata>>;
|
||||
|
||||
/// Reads a blob from the Puffin file.
|
||||
///
|
||||
/// The returned `BlobGuard` is used to access the blob data.
|
||||
|
||||
@@ -87,6 +87,15 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
async fn metadata(&self) -> Result<Arc<FileMetadata>> {
|
||||
let reader = self
|
||||
.puffin_file_accessor
|
||||
.reader(&self.puffin_file_name)
|
||||
.await?;
|
||||
let mut file = PuffinFileReader::new(reader);
|
||||
self.get_puffin_file_metadata(&mut file).await
|
||||
}
|
||||
|
||||
async fn blob(&self, key: &str) -> Result<Self::Blob> {
|
||||
let mut reader = self
|
||||
.puffin_file_accessor
|
||||
|
||||
Reference in New Issue
Block a user