Skip to content

Commit 535de90

Browse files
committed
fmt is good
1 parent 9a27198 commit 535de90

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

crates/iceberg/src/io/file_io.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::collections::HashMap;
2020
use std::fmt::Debug;
2121
use std::ops::Range;
2222
use std::sync::Arc;
23+
2324
use async_trait::async_trait;
2425
use bytes::Bytes;
2526
use url::Url;
@@ -32,16 +33,16 @@ use crate::{Error, ErrorKind, Result};
3233
pub trait Storage: Debug + Send + Sync {
3334
/// Check if a file exists at the given path
3435
async fn exists(&self, path: &str) -> Result<bool>;
35-
36+
3637
/// Get metadata from an input path
3738
async fn metadata(&self, path: &str) -> Result<FileMetadata>;
38-
39+
3940
/// Read bytes from a path
4041
async fn read(&self, path: &str) -> Result<Bytes>;
41-
42+
4243
/// Get FileRead from a path
4344
async fn reader(&self, path: &str) -> Result<Box<dyn FileRead>>;
44-
45+
4546
/// Write bytes to an output path
4647
async fn write(&self, path: &str, bs: Bytes) -> Result<()>;
4748

@@ -319,7 +320,7 @@ pub trait FileRead: Send + Sync + Unpin + 'static {
319320

320321
#[async_trait::async_trait]
321322
impl FileRead for opendal::Reader {
322-
async fn read(&self, range: Range<u64>) -> crate::Result<Bytes> {
323+
async fn read(&self, range: Range<u64>) -> Result<Bytes> {
323324
Ok(opendal::Reader::read(self, range).await?.to_bytes())
324325
}
325326
}
@@ -344,23 +345,20 @@ impl InputFile {
344345
}
345346

346347
/// Check if file exists.
347-
pub async fn exists(&self) -> crate::Result<bool> {
348+
pub async fn exists(&self) -> Result<bool> {
348349
self.storage.exists(&self.path).await
349350
}
350351

351352
/// Fetch and returns metadata of file.
352-
pub async fn metadata(&self) -> crate::Result<FileMetadata> {
353+
pub async fn metadata(&self) -> Result<FileMetadata> {
353354
self.storage.metadata(&self.path).await
354355
}
355356

356357
/// Read and returns whole content of file.
357358
///
358359
/// For continuous reading, use [`Self::reader`] instead.
359360
pub async fn read(&self) -> Result<Bytes> {
360-
self
361-
.storage
362-
.read(&self.path)
363-
.await
361+
self.storage.read(&self.path).await
364362
}
365363

366364
/// Creates [`FileRead`] for continuous reading.
@@ -468,9 +466,7 @@ impl OutputFile {
468466
///
469467
/// For one-time writing, use [`Self::write`] instead.
470468
pub async fn writer(&self) -> crate::Result<Box<dyn FileWrite>> {
471-
Ok(Box::new(
472-
self.storage.writer(&self.path).await?
473-
))
469+
Ok(Box::new(self.storage.writer(&self.path).await?))
474470
}
475471
}
476472

crates/iceberg/src/io/storage.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use crate::Result;
1918
use std::sync::Arc;
19+
2020
use async_trait::async_trait;
2121
use bytes::Bytes;
2222
use opendal::layers::RetryLayer;
@@ -35,7 +35,7 @@ use super::AzureStorageScheme;
3535
use super::{FileIOBuilder, FileMetadata, FileRead, FileWrite, InputFile, OutputFile, Storage};
3636
#[cfg(feature = "storage-s3")]
3737
use crate::io::CustomAwsCredentialLoader;
38-
use crate::{Error, ErrorKind};
38+
use crate::{Error, ErrorKind, Result};
3939

4040
/// The storage carries all supported storage services in iceberg
4141
#[derive(Debug, Clone)]
@@ -79,7 +79,7 @@ impl Storage for OpenDALStorage {
7979
async fn metadata(&self, path: &str) -> Result<FileMetadata> {
8080
let (op, relative_path) = self.create_operator(&path)?;
8181
let meta = op.stat(relative_path).await?;
82-
82+
8383
Ok(FileMetadata {
8484
size: meta.content_length(),
8585
})
@@ -103,9 +103,7 @@ impl Storage for OpenDALStorage {
103103

104104
async fn writer(&self, path: &str) -> Result<Box<dyn FileWrite>> {
105105
let (op, relative_path) = self.create_operator(&path)?;
106-
Ok(Box::new(
107-
op.writer(relative_path).await?,
108-
))
106+
Ok(Box::new(op.writer(relative_path).await?))
109107
}
110108

111109
async fn delete(&self, path: &str) -> Result<()> {
@@ -126,19 +124,13 @@ impl Storage for OpenDALStorage {
126124
fn new_input(&self, path: &str) -> Result<InputFile> {
127125
let storage = Arc::new(self.clone());
128126
let path = path.to_string();
129-
Ok(InputFile {
130-
storage,
131-
path,
132-
})
127+
Ok(InputFile { storage, path })
133128
}
134129

135130
fn new_output(&self, path: &str) -> Result<OutputFile> {
136131
let storage = Arc::new(self.clone());
137132
let path = path.to_string();
138-
Ok(OutputFile {
139-
storage,
140-
path,
141-
})
133+
Ok(OutputFile { storage, path })
142134
}
143135
}
144136

crates/iceberg/src/puffin/metadata.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
use std::collections::{HashMap, HashSet};
19+
1920
use bytes::Bytes;
2021
use serde::{Deserialize, Serialize};
2122

@@ -288,9 +289,12 @@ impl FileMetadata {
288289
let input_file_length = input_file.metadata().await?.size;
289290
let footer_payload_length =
290291
FileMetadata::read_footer_payload_length(file_read.as_ref(), input_file_length).await?;
291-
let footer_bytes =
292-
FileMetadata::read_footer_bytes(file_read.as_ref(), input_file_length, footer_payload_length)
293-
.await?;
292+
let footer_bytes = FileMetadata::read_footer_bytes(
293+
file_read.as_ref(),
294+
input_file_length,
295+
footer_payload_length,
296+
)
297+
.await?;
294298

295299
let magic_length = FileMetadata::MAGIC_LENGTH as usize;
296300
// check first four bytes of footer

0 commit comments

Comments
 (0)