Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shbhmrzd committed Apr 22, 2024
1 parent 42848ea commit a8a6d17
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
50 changes: 25 additions & 25 deletions core/src/services/hdfs_native/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// under the License.

use chrono::DateTime;
use hdfs_native::client::{FileStatus, ListStatusIterator};
use hdfs_native::client::ListStatusIterator;

use crate::raw::oio::Entry;
use crate::raw::{build_rel_path, oio};
Expand All @@ -39,38 +39,38 @@ impl HdfsNativeLister {

impl oio::List for HdfsNativeLister {
async fn next(&mut self) -> Result<Option<Entry>> {
let Ok(de) = self
if let Some(de) = self
.lsi
.next()
.await
.transpose()
.map_err(parse_hdfs_error)?
else {
return Ok(None);
};
{
let path = build_rel_path(&self.root, &de.path);

let path = build_rel_path(&self.root, &de.path);
let entry = if !de.isdir {
let odt = DateTime::from_timestamp(de.modification_time as i64, 0);

let entry = if !de.isdir {
let odt = DateTime::from_timestamp(de.modification_time as i64, 0);

let Some(dt) = odt else {
return Err(Error::new(
ErrorKind::Unexpected,
&format!("Failure in extracting modified_time for {}", path),
));
let Some(dt) = odt else {
return Err(Error::new(
ErrorKind::Unexpected,
&format!("Failure in extracting modified_time for {}", path),
));
};
let meta = Metadata::new(EntryMode::FILE)
.with_content_length(de.length as u64)
.with_last_modified(dt);
oio::Entry::new(&path, meta)
} else if de.isdir {
// Make sure we are returning the correct path.
oio::Entry::new(&format!("{path}/"), Metadata::new(EntryMode::DIR))
} else {
oio::Entry::new(&path, Metadata::new(EntryMode::Unknown))
};
let meta = Metadata::new(EntryMode::FILE)
.with_content_length(de.length as u64)
.with_last_modified(dt);
oio::Entry::new(&path, meta)
} else if de.isdir {
// Make sure we are returning the correct path.
oio::Entry::new(&format!("{path}/"), Metadata::new(EntryMode::DIR))
} else {
oio::Entry::new(&path, Metadata::new(EntryMode::Unknown))
};

Ok(Some(entry))
Ok(Some(entry))
} else {
Ok(None)
}
}
}
8 changes: 2 additions & 6 deletions core/src/services/hdfs_native/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ impl HdfsNativeReader {
impl oio::Read for HdfsNativeReader {
async fn read_at(&self, offset: u64, limit: usize) -> Result<Buffer> {
// Perform the read operation using read_range
let bytes = match self
let bytes = self
.f
.read_range(offset as usize, limit)
.await
.map_err(parse_hdfs_error)
{
Ok(data) => data,
Err(e) => return Err(e),
};
.map_err(parse_hdfs_error)?;

Ok(Buffer::from(bytes))
}
Expand Down

0 comments on commit a8a6d17

Please sign in to comment.