Skip to content

Commit

Permalink
internal changes.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 602863918
  • Loading branch information
dryman authored and copybara-github committed Jan 31, 2024
1 parent 2ac1d90 commit a33fa56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit a33fa56

Please sign in to comment.