Skip to content

Commit e56fd7e

Browse files
committed
Sort results from ls_with_sizes LocalFS helper.
1 parent 035e2a7 commit e56fd7e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

tiledb/sm/filesystem/local.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ LsObjects LocalFilesystem::ls_filtered_v2(
126126

127127
Status LocalFilesystem::ls(
128128
const std::string& path, std::vector<std::string>* paths) const {
129+
// Noop if the parent ` path ` is not a directory, do not error out.
130+
if (!is_dir(URI(path))) {
131+
return Status::Ok();
132+
}
133+
129134
for (auto& fs : ls_with_sizes(URI(path), false)) {
130135
paths->emplace_back(fs.path().native());
131136
}

tiledb/sm/filesystem/vfs.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,21 @@ bool VFS::is_bucket(const URI& uri) const {
364364
Status VFS::ls(const URI& parent, std::vector<URI>* uris) const {
365365
stats_->add_counter("ls_num", 1);
366366

367-
const auto entries = parent.is_file() ? local_.ls_with_sizes(parent, false) :
368-
ls_with_sizes(parent);
367+
auto entries = parent.is_file() ? local_.ls_with_sizes(parent, false) :
368+
ls_with_sizes(parent);
369+
if (parent.is_file()) {
370+
parallel_sort(
371+
compute_tp_,
372+
entries.begin(),
373+
entries.end(),
374+
[](const directory_entry& l, const directory_entry& r) {
375+
return l.path().native() < r.path().native();
376+
});
377+
}
378+
369379
for (const auto& fs : entries) {
370380
uris->emplace_back(fs.path().native());
371381
}
372-
373382
return Status::Ok();
374383
}
375384

0 commit comments

Comments
 (0)