Skip to content

Commit

Permalink
Define a ctor for MultiPartFile.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-le-cam committed Sep 11, 2024
1 parent 1741dd6 commit 1b86f84
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/s3plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ SimpleOutcome<ReaderPtr> MakeReaderPtr(std::string bucketname, std::string objec
const long long size = size_outcome.GetResult();

return ReaderPtr(
new MultiPartFile{std::move(bucketname), std::move(objectname), 0, 0, {objectname}, {size}, size});
new MultiPartFile{std::move(bucketname), std::move(objectname), 0, 0, {objectname}, {size}});
}

// this is a multifile. the reader object needs the list of filenames matching the globbing pattern and their
Expand Down Expand Up @@ -957,9 +957,8 @@ SimpleOutcome<ReaderPtr> MakeReaderPtr(std::string bucketname, std::string objec
}

// construct the result
const tOffset total_size = cumulative_size.back(); // keep it now, cumulative_size will be moved from
return ReaderPtr(new MultiPartFile{std::move(bucketname), std::move(objectname), 0, common_header_length,
std::move(filenames), std::move(cumulative_size), total_size});
std::move(filenames), std::move(cumulative_size)});
}

SimpleOutcome<WriterPtr> MakeWriterPtr(std::string bucket, std::string object)
Expand Down Expand Up @@ -1294,7 +1293,6 @@ long long int driver_fwrite(const void* ptr, size_t size, size_t count, void* st

const size_t to_write = size * count;

const auto& writer = h_ptr->writer_;
// tune up the capacity of the internal buffer, the final buffer size must be a multiple of the size argument
auto& buffer = h_ptr->buffer_;
const size_t curr_size = buffer.size();
Expand Down
9 changes: 9 additions & 0 deletions src/s3plugin_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ struct MultiPartFile
std::vector<std::string> filenames_;
std::vector<tOffset> cumulative_sizes_;
tOffset total_size_{0};

MultiPartFile() = default;
explicit MultiPartFile(std::string bucket, std::string filename, tOffset offset, tOffset common_header_length,
std::vector<std::string> filenames, std::vector<tOffset> cumulative_sizes)
: bucketname_{std::move(bucket)}, filename_{std::move(filename)}, offset_{offset},
common_header_length_{common_header_length}, filenames_{std::move(filenames)},
cumulative_sizes_{std::move(cumulative_sizes)}, total_size_{cumulative_sizes_.back()}
{
}
};

using Parts = std::vector<Aws::S3::Model::CompletedPart>;
Expand Down
6 changes: 4 additions & 2 deletions test/basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ TEST_F(S3DriverTestFixture, GetFileSize_Pattern_MultiMatch_SameHeader_OK) {
static_cast<long long>(body_0.size() + content1.size());

auto content =
MakeObjectVector({key_0, key_1}, {body_0.size(), body_1.size()});
MakeObjectVector({key_0, key_1}, {static_cast<long long>(body_0.size()),
static_cast<long long>(body_1.size())});
std::string token;

// list
Expand Down Expand Up @@ -636,7 +637,8 @@ TEST_F(S3DriverTestFixture,
static_cast<long long>(body_0.size() + content1.size());

auto content =
MakeObjectVector({key_0, key_1}, {body_0.size(), body_1.size()});
MakeObjectVector({key_0, key_1}, {static_cast<long long>(body_0.size()),
static_cast<long long>(body_1.size())});
std::string token;

// list
Expand Down

0 comments on commit 1b86f84

Please sign in to comment.