Skip to content
Open
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
1 change: 1 addition & 0 deletions cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ cc_library(
"@com_google_protobuf//:protobuf_lite",
"@com_google_riegeli//riegeli/base:object",
"@com_google_riegeli//riegeli/base:options_parser",
"@com_google_riegeli//riegeli/base:status",
"@com_google_riegeli//riegeli/bytes:chain_writer",
"@com_google_riegeli//riegeli/chunk_encoding:chunk",
"@com_google_riegeli//riegeli/chunk_encoding:chunk_encoder",
Expand Down
21 changes: 20 additions & 1 deletion cpp/array_record_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ limitations under the License.
#include "cpp/thread_pool.h"
#include "riegeli/base/object.h"
#include "riegeli/base/options_parser.h"
#include "riegeli/base/status.h"
#include "riegeli/bytes/chain_writer.h"
#include "riegeli/chunk_encoding/chunk.h"
#include "riegeli/chunk_encoding/chunk_encoder.h"
Expand Down Expand Up @@ -365,10 +366,28 @@ void ArrayRecordWriterBase::Initialize() {
}

void ArrayRecordWriterBase::Done() {
if (!ok()) {
return;
}
auto writer = get_writer();
if (writer == nullptr) {
Fail(absl::InternalError("writer should not be a nullptr."));
return;
}
if (!writer->ok()) {
Fail(riegeli::Annotate(writer->status(), "SequencedChunkWriter failure"));
return;
}
if (chunk_encoder_ == nullptr) {
Fail(absl::InternalError("chunk_encoder_ should not be a nullptr."));
return;
}
if (chunk_encoder_->num_records() > 0) {
std::promise<absl::StatusOr<Chunk>> chunk_promise;
writer->CommitFutureChunk(chunk_promise.get_future());
if (!writer->CommitFutureChunk(chunk_promise.get_future())) {
Fail(riegeli::Annotate(writer->status(), "Cannot commit future chunk"));
return;
}
chunk_promise.set_value(EncodeChunk(chunk_encoder_.get()));
}
submit_chunk_callback_->WriteFooterAndPostscript(writer.get());
Expand Down