Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crates/paimon/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ pub enum Error {
)]
IoUnexpected {
message: String,
source: opendal::Error,
#[snafu(source(from(opendal::Error, Box::new)))]
source: Box<opendal::Error>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err
which suggest us to wrap big size error to Box.

},
#[snafu(
visibility(pub(crate)),
Expand All @@ -58,7 +59,7 @@ pub enum Error {
)]
DataUnexpected {
message: String,
source: apache_avro::Error,
source: Box<apache_avro::Error>,
},
#[snafu(
visibility(pub(crate)),
Expand All @@ -72,7 +73,7 @@ impl From<opendal::Error> for Error {
// TODO: Simple use IoUnexpected for now
Error::IoUnexpected {
message: "IO operation failed on underlying storage".to_string(),
source,
source: Box::new(source),
}
}
}
Expand All @@ -81,7 +82,7 @@ impl From<apache_avro::Error> for Error {
fn from(source: apache_avro::Error) -> Self {
Error::DataUnexpected {
message: "".to_string(),
source,
source: Box::new(source),
}
}
}
10 changes: 5 additions & 5 deletions crates/paimon/src/file_index/file_index_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl FileIndex {
Ok(result)
} else {
Err(Error::FileIndexFormatInvalid {
message: format!("Column '{}' not found in header", column_name),
message: format!("Column '{column_name}' not found in header"),
})
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ impl FileIndexFormatReader {
let magic = buffer.get_u64_le();
if magic != MAGIC {
return Err(Error::FileIndexFormatInvalid {
message: format!("Expected MAGIC: {}, but found: {}", MAGIC, magic),
message: format!("Expected MAGIC: {MAGIC}, but found: {magic}"),
});
}

Expand Down Expand Up @@ -339,7 +339,7 @@ impl FileIndexFormatReader {
// Column Name (variable-length UTF-8 string)
let column_name = String::from_utf8(buffer.split_to(column_name_len as usize).to_vec())
.map_err(|e| Error::FileIndexFormatInvalid {
message: format!("Invalid UTF-8 sequence in column name: {}", e),
message: format!("Invalid UTF-8 sequence in column name: {e}"),
})?;
current_offset += column_name_len as u64;

Expand Down Expand Up @@ -430,11 +430,11 @@ mod file_index_format_tests {

let mut indexes = HashMap::new();
for col_num in 1..5 {
let column_name = format!("column{}", col_num);
let column_name = format!("column{col_num}");
let mut index_map = HashMap::new();
for idx_num in 1..5 {
index_map.insert(
format!("index{}", idx_num),
format!("index{idx_num}"),
random_bytes(100 + col_num * idx_num),
);
}
Expand Down
16 changes: 8 additions & 8 deletions crates/paimon/src/io/file_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl FileIO {
/// The input HashMap is paimon-java's [`Options`](https://github.com/apache/paimon/blob/release-0.8.2/paimon-common/src/main/java/org/apache/paimon/options/Options.java#L60)
pub fn from_url(path: &str) -> crate::Result<FileIOBuilder> {
let url = Url::parse(path).map_err(|_| Error::ConfigInvalid {
message: format!("Invalid URL: {}", path),
message: format!("Invalid URL: {path}"),
})?;

Ok(FileIOBuilder::new(url.scheme()))
Expand Down Expand Up @@ -79,7 +79,7 @@ impl FileIO {
pub async fn get_status(&self, path: &str) -> Result<FileStatus> {
let (op, relative_path) = self.storage.create(path)?;
let meta = op.stat(relative_path).await.context(IoUnexpectedSnafu {
message: format!("Failed to get file status for '{}'", path),
message: format!("Failed to get file status for '{path}'"),
})?;

Ok(FileStatus {
Expand All @@ -99,7 +99,7 @@ impl FileIO {
let (op, relative_path) = self.storage.create(path)?;

let entries = op.list(relative_path).await.context(IoUnexpectedSnafu {
message: format!("Failed to list files in '{}'", path),
message: format!("Failed to list files in '{path}'"),
})?;

let mut statuses = Vec::new();
Expand All @@ -124,7 +124,7 @@ impl FileIO {
let (op, relative_path) = self.storage.create(path)?;

op.is_exist(relative_path).await.context(IoUnexpectedSnafu {
message: format!("Failed to check existence of '{}'", path),
message: format!("Failed to check existence of '{path}'"),
})
}

Expand All @@ -135,7 +135,7 @@ impl FileIO {
let (op, relative_path) = self.storage.create(path)?;

op.delete(relative_path).await.context(IoUnexpectedSnafu {
message: format!("Failed to delete file '{}'", path),
message: format!("Failed to delete file '{path}'"),
})?;

Ok(())
Expand All @@ -150,7 +150,7 @@ impl FileIO {
op.remove_all(relative_path)
.await
.context(IoUnexpectedSnafu {
message: format!("Failed to delete directory '{}'", path),
message: format!("Failed to delete directory '{path}'"),
})?;

Ok(())
Expand All @@ -167,7 +167,7 @@ impl FileIO {
op.create_dir(relative_path)
.await
.context(IoUnexpectedSnafu {
message: format!("Failed to create directory '{}'", path),
message: format!("Failed to create directory '{path}'"),
})?;

Ok(())
Expand All @@ -184,7 +184,7 @@ impl FileIO {
.rename(relative_path_src, relative_path_dst)
.await
.context(IoUnexpectedSnafu {
message: format!("Failed to rename '{}' to '{}'", src, dst),
message: format!("Failed to rename '{src}' to '{dst}'"),
})?;

Ok(())
Expand Down
1 change: 1 addition & 0 deletions crates/paimon/src/spec/index_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::fmt::{Display, Formatter};
/// Manifest entry for index file.
///
/// Impl Reference: <https://github.com/apache/paimon/blob/release-0.8.2/paimon-core/src/main/java/org/apache/paimon/manifest/IndexManifestEntry.java>
#[allow(dead_code)] // Part of spec; used when index manifest is implemented.
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct IndexManifestEntry {
#[serde(rename = "_KIND")]
Expand Down
1 change: 1 addition & 0 deletions crates/paimon/src/spec/manifest_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum FileKind {

/// The Source of a file.
/// Impl References: <https://github.com/apache/paimon/blob/release-0.8.2/paimon-core/src/main/java/org/apache/paimon/manifest/FileSource.java>
#[allow(dead_code)] // Part of spec; used when file source is needed.
#[derive(PartialEq, Eq, Debug, Clone, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum FileSource {
Expand Down
3 changes: 1 addition & 2 deletions crates/paimon/src/spec/manifest_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

use crate::spec::manifest_common::FileKind;
use crate::spec::DataFileMeta;
use serde::Deserialize;
use serde_with::serde_derive::Serialize;
use serde::{Deserialize, Serialize};

/// The same {@link Identifier} indicates that the {@link ManifestEntry} refers to the same data file.
///
Expand Down
19 changes: 6 additions & 13 deletions crates/paimon/src/spec/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,29 +1506,22 @@ mod serde_utils {
) -> crate::Result<(usize, usize), Error> {
let Some(open_bracket) = s.find('(') else {
return Err(Error::DataTypeInvalid {
message: format!(
"Invalid {} specification. Missing opening bracket.",
type_name
)
.to_string(),
message: format!("Invalid {type_name} specification. Missing opening bracket.")
.to_string(),
});
};
let Some(close_bracket) = s.find(')') else {
return Err(Error::DataTypeInvalid {
message: format!(
"Invalid {} specification. Missing closing bracket.",
type_name
)
.to_string(),
message: format!("Invalid {type_name} specification. Missing closing bracket.")
.to_string(),
});
};

if open_bracket >= close_bracket {
return Err(Error::DataTypeInvalid {
message: format!(
"Invalid {} specification. Opening bracket \
appears after or at the same position as closing bracket.",
type_name
"Invalid {type_name} specification. Opening bracket \
appears after or at the same position as closing bracket."
)
.to_string(),
});
Expand Down
Loading