Skip to content

Commit

Permalink
remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Aug 28, 2023
1 parent b726569 commit ee64bf0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion analytic_engine/src/sst/meta_data/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ mod tests {
writer.write(&batch).unwrap();
writer.close().unwrap();

let bytes = encoding::encode_sst_meta_data_v2(custom_meta_data.clone()).unwrap();
let bytes = encoding::encode_sst_meta_data(custom_meta_data.clone()).unwrap();
let meta_path = object_store::Path::from(meta_path);
store.put(&meta_path, bytes).await.unwrap();
}
Expand Down
6 changes: 3 additions & 3 deletions analytic_engine/src/sst/meta_data/metadata_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::sst::{
KvMetaPathEmpty,
},
parquet::{
encoding::{self, decode_sst_meta_data_v2, META_VERSION_CURRENT, META_VERSION_V1},
encoding::{self, decode_sst_meta_data_from_bytes, META_VERSION_CURRENT, META_VERSION_V1},
meta_data::{ParquetMetaData, ParquetMetaDataRef},
},
};
Expand All @@ -54,7 +54,7 @@ impl CustomMetadataReader for MetaV1Reader<'_> {
async fn get_metadata(&self) -> Result<ParquetMetaData> {
let custom_kv_meta = self.custom_kv_meta.context(KvMetaDataNotFound)?;

encoding::decode_sst_meta_data_v1(custom_kv_meta).context(DecodeCustomMetaData)
encoding::decode_sst_meta_data_from_kv(custom_kv_meta).context(DecodeCustomMetaData)
}
}

Expand Down Expand Up @@ -88,7 +88,7 @@ impl CustomMetadataReader for MetaV2Reader {
file_path: meta_path.to_string(),
})?;

decode_sst_meta_data_v2(metadata.as_bytes()).context(DecodeCustomMetaData)
decode_sst_meta_data_from_bytes(metadata.as_bytes()).context(DecodeCustomMetaData)
}
}
}
Expand Down
20 changes: 5 additions & 15 deletions analytic_engine/src/sst/parquet/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub const META_VERSION_KEY: &str = "meta_version";
pub const META_VALUE_HEADER: u8 = 0;

/// Encode the sst custom meta data into binary key value pair.
pub fn encode_sst_meta_data_v2(meta_data: ParquetMetaData) -> Result<Bytes> {
pub fn encode_sst_meta_data(meta_data: ParquetMetaData) -> Result<Bytes> {
let meta_data_pb = sst_pb::ParquetMetaData::from(meta_data);

let mut buf = BytesMut::with_capacity(meta_data_pb.encoded_len() + 1);
Expand All @@ -178,7 +178,7 @@ pub fn encode_sst_meta_data_v2(meta_data: ParquetMetaData) -> Result<Bytes> {
}

/// Decode the sst custom meta data from the binary key value pair.
pub fn decode_sst_meta_data_v2(bytes: &[u8]) -> Result<ParquetMetaData> {
pub fn decode_sst_meta_data_from_bytes(bytes: &[u8]) -> Result<ParquetMetaData> {
ensure!(
bytes[0] == META_VALUE_HEADER,
InvalidMetaBytesHeader {
Expand All @@ -193,19 +193,9 @@ pub fn decode_sst_meta_data_v2(bytes: &[u8]) -> Result<ParquetMetaData> {
ParquetMetaData::try_from(meta_data_pb).context(ConvertSstMetaData)
}

/// Encode the sst meta data into binary key value pair.
// TODO: remove this function when hybrid format is not supported.
pub fn encode_sst_meta_data_v1(meta_data: ParquetMetaData) -> Result<KeyValue> {
let buf = encode_sst_meta_data_v2(meta_data)?;

Ok(KeyValue {
key: META_KEY.to_string(),
value: Some(base64::encode(buf.as_ref())),
})
}

/// Decode the sst meta data from the binary key value pair.
pub fn decode_sst_meta_data_v1(kv: &KeyValue) -> Result<ParquetMetaData> {
/// Used in v1 format.
pub fn decode_sst_meta_data_from_kv(kv: &KeyValue) -> Result<ParquetMetaData> {
ensure!(
kv.key == META_KEY,
InvalidMetaKey {
Expand All @@ -222,7 +212,7 @@ pub fn decode_sst_meta_data_v1(kv: &KeyValue) -> Result<ParquetMetaData> {

let raw_bytes = base64::decode(meta_value).context(DecodeBase64MetaValue { meta_value })?;

decode_sst_meta_data_v2(&raw_bytes)
decode_sst_meta_data_from_bytes(&raw_bytes)
}

/// RecordEncoder is used for encoding ArrowBatch.
Expand Down
4 changes: 2 additions & 2 deletions analytic_engine/src/sst/parquet/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::{
factory::{ObjectStorePickerRef, SstWriteOptions},
file::Level,
parquet::{
encoding::{encode_sst_meta_data_v2, ParquetEncoder},
encoding::{encode_sst_meta_data, ParquetEncoder},
meta_data::{ParquetFilter, ParquetMetaData, RowGroupFilterBuilder},
},
writer::{
Expand Down Expand Up @@ -290,7 +290,7 @@ async fn write_metadata<W>(
where
W: AsyncWrite + Send + Unpin,
{
let buf = encode_sst_meta_data_v2(parquet_metadata).context(EncodePbData)?;
let buf = encode_sst_meta_data(parquet_metadata).context(EncodePbData)?;
meta_sink
.write_all(buf.as_bytes())
.await
Expand Down
2 changes: 1 addition & 1 deletion tools/src/sst_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ pub async fn meta_from_sst(store: &ObjectStoreRef, sst_path: &Path) -> MetaData
.find(|kv| kv.key == encoding::META_KEY)
.unwrap();

let parquet_meta_data = encoding::decode_sst_meta_data_v1(kv_meta).unwrap();
let parquet_meta_data = encoding::decode_sst_meta_data_from_kv(kv_meta).unwrap();
MetaData::from(parquet_meta_data)
}

0 comments on commit ee64bf0

Please sign in to comment.