Skip to content
Merged
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
2 changes: 1 addition & 1 deletion google/cloud/bigtable/client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TEST(Client, AsyncPrepareQuery) {
class MockQueryRowSource : public ResultSourceInterface {
public:
MOCK_METHOD(StatusOr<QueryRow>, NextRow, (), (override));
MOCK_METHOD(absl::optional<google::bigtable::v2::ResultSetMetadata>, Metadata,
MOCK_METHOD(std::optional<google::bigtable::v2::ResultSetMetadata>, Metadata,
(), (override));
};

Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigtable/examples/data_snippets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ void PrepareAndExecuteQuery(google::cloud::bigtable::Client client,

auto results = client.ExecuteQuery(std::move(bound_query));

using RowType = std::tuple<cbt::Bytes, absl::optional<std::string>>;
using RowType = std::tuple<cbt::Bytes, std::optional<std::string>>;
for (auto& row : cbt::StreamOf<RowType>(results)) {
if (!row.ok()) throw std::move(row.status());
auto v = std::get<1>(*row);
Expand Down
35 changes: 14 additions & 21 deletions google/cloud/bigtable/internal/async_bulk_apply_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Matcher<v2::MutateRowsRequest::Entry> MatchEntry(std::string const& row_key) {
}

// Individual entry pairs are: {index, StatusCode}
absl::optional<v2::MutateRowsResponse> MakeResponse(
std::optional<v2::MutateRowsResponse> MakeResponse(
std::vector<std::pair<int, grpc::StatusCode>> const& entries) {
v2::MutateRowsResponse resp;
for (auto entry : entries) {
Expand Down Expand Up @@ -227,8 +227,7 @@ TEST_F(AsyncBulkApplyTest, Success) {
MakeResponse({{1, grpc::StatusCode::OK}}));
})
.WillOnce([] {
return make_ready_future(
absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand Down Expand Up @@ -299,8 +298,7 @@ TEST_F(AsyncBulkApplyTest, PartialStreamIsRetried) {
MakeResponse({{0, grpc::StatusCode::OK}}));
})
.WillOnce([] {
return make_ready_future(
absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand All @@ -323,8 +321,7 @@ TEST_F(AsyncBulkApplyTest, PartialStreamIsRetried) {
MakeResponse({{0, grpc::StatusCode::OK}}));
})
.WillOnce([] {
return make_ready_future(
absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand Down Expand Up @@ -403,8 +400,7 @@ TEST_F(AsyncBulkApplyTest, IdempotentMutationPolicy) {
{3, grpc::StatusCode::UNAVAILABLE}}));
})
.WillOnce([] {
return make_ready_future(
absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand All @@ -428,8 +424,7 @@ TEST_F(AsyncBulkApplyTest, IdempotentMutationPolicy) {
MakeResponse({{0, grpc::StatusCode::OK}}));
})
.WillOnce([] {
return make_ready_future(
absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand Down Expand Up @@ -559,7 +554,7 @@ TEST_F(AsyncBulkApplyTest, RetryInfoHeeded) {
.WillOnce(Return(ByMove(
make_ready_future(MakeResponse({{0, grpc::StatusCode::OK}})))))
.WillOnce(Return(ByMove(
make_ready_future(absl::optional<v2::MutateRowsResponse>()))));
make_ready_future(std::optional<v2::MutateRowsResponse>()))));
EXPECT_CALL(*stream, Finish)
.WillOnce(Return(make_ready_future(Status())));
return stream;
Expand Down Expand Up @@ -687,7 +682,7 @@ TEST_F(AsyncBulkApplyTest, TimerError) {

TEST_F(AsyncBulkApplyTest, CancelAfterSuccess) {
bigtable::BulkMutation mut(IdempotentMutation("r0"));
promise<absl::optional<v2::MutateRowsResponse>> p;
promise<std::optional<v2::MutateRowsResponse>> p;

#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
auto mock_metric = std::make_unique<MockMetric>();
Expand Down Expand Up @@ -754,7 +749,7 @@ TEST_F(AsyncBulkApplyTest, CancelAfterSuccess) {
actual.cancel();
// Proceed with the rest of the stream. In this test, there are no more
// responses to be read. The client call should succeed.
p.set_value(absl::optional<v2::MutateRowsResponse>{});
p.set_value(std::optional<v2::MutateRowsResponse>{});
CheckFailedMutations(actual.get(), {});
}

Expand All @@ -763,7 +758,7 @@ TEST_F(AsyncBulkApplyTest, CancelMidStream) {
{Status(StatusCode::kCancelled, "User cancelled"), 2}};
bigtable::BulkMutation mut(IdempotentMutation("r0"), IdempotentMutation("r1"),
IdempotentMutation("r2"));
promise<absl::optional<v2::MutateRowsResponse>> p;
promise<std::optional<v2::MutateRowsResponse>> p;

#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
auto mock_metric = std::make_unique<MockMetric>();
Expand Down Expand Up @@ -806,7 +801,7 @@ TEST_F(AsyncBulkApplyTest, CancelMidStream) {
.WillOnce([&p] { return p.get_future(); });
EXPECT_CALL(*stream, Cancel);
EXPECT_CALL(*stream, Read).WillOnce([] {
return make_ready_future(absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(
Expand Down Expand Up @@ -924,8 +919,7 @@ TEST_F(AsyncBulkApplyTest, RetriesOkStreamWithFailedMutations) {
MakeResponse({{0, grpc::StatusCode::UNAVAILABLE}}));
})
.WillOnce([] {
return make_ready_future(
absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status());
Expand Down Expand Up @@ -993,7 +987,7 @@ TEST_F(AsyncBulkApplyTest, Throttling) {
});
EXPECT_CALL(*limiter, Update);
EXPECT_CALL(*stream, Read).WillOnce([] {
return make_ready_future(absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status());
Expand Down Expand Up @@ -1029,8 +1023,7 @@ TEST_F(AsyncBulkApplyTest, ThrottlingBeforeEachRetry) {
MakeResponse({{0, grpc::StatusCode::UNAVAILABLE}}));
})
.WillOnce([] {
return make_ready_future(
absl::optional<v2::MutateRowsResponse>{});
return make_ready_future(std::optional<v2::MutateRowsResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status());
Expand Down
8 changes: 4 additions & 4 deletions google/cloud/bigtable/internal/async_row_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#include "google/cloud/internal/call_context.h"
#include "google/cloud/options.h"
#include "google/cloud/status_or.h"
#include "absl/types/optional.h"
#include <chrono>
#include <memory>
#include <optional>
#include <queue>
#include <string>
#include <utility>
Expand Down Expand Up @@ -157,13 +157,13 @@ class AsyncRowReader : public std::enable_shared_from_this<AsyncRowReader> {
/**
* The promise to the underlying stream to either continue reading or cancel.
*
* If the `absl::optional` is empty, it means that either the whole scan is
* If the `std::optional` is empty, it means that either the whole scan is
* finished or the underlying layers are already trying to fetch more data.
*
* If the `absl::optional` is not empty, the lower layers are waiting for this
* If the `std::optional` is not empty, the lower layers are waiting for this
* to be satisfied before they start fetching more data.
*/
absl::optional<promise<bool>> continue_reading_;
std::optional<promise<bool>> continue_reading_;
/// The final status of the operation.
bool whole_op_finished_ = false;
/**
Expand Down
8 changes: 4 additions & 4 deletions google/cloud/bigtable/internal/async_row_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Status TransientError() {
//
// We use `commit_row == true` to return a full row, and `commit_row == false`
// to return a partial row.
absl::optional<v2::ReadRowsResponse> MakeResponse(
std::optional<v2::ReadRowsResponse> MakeResponse(
std::vector<std::pair<std::string, bool>> rows) {
v2::ReadRowsResponse resp;
for (auto& row : rows) {
Expand All @@ -85,7 +85,7 @@ absl::optional<v2::ReadRowsResponse> MakeResponse(
return resp;
}

absl::optional<v2::ReadRowsResponse> EndOfStream() { return absl::nullopt; }
std::optional<v2::ReadRowsResponse> EndOfStream() { return std::nullopt; }

class AsyncRowReaderTest : public ::testing::Test {
protected:
Expand Down Expand Up @@ -975,7 +975,7 @@ TEST_F(AsyncRowReaderTest, LastScannedRowKeyIsRespected) {
.WillOnce([] {
v2::ReadRowsResponse r;
r.set_last_scanned_row_key("r2");
return make_ready_future(absl::make_optional(r));
return make_ready_future(std::make_optional(r));
})
.WillOnce([] { return make_ready_future(EndOfStream()); });
EXPECT_CALL(*stream, Finish).WillOnce([] {
Expand Down Expand Up @@ -1610,7 +1610,7 @@ TEST_F(AsyncRowReaderTest, ReverseScanResumption) {
.WillOnce([] {
v2::ReadRowsResponse r;
r.set_last_scanned_row_key("r2");
return make_ready_future(absl::make_optional(r));
return make_ready_future(std::make_optional(r));
})
.WillOnce([] { return make_ready_future(EndOfStream()); });
EXPECT_CALL(*stream, Finish).WillOnce([] {
Expand Down
22 changes: 11 additions & 11 deletions google/cloud/bigtable/internal/async_row_sampler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ struct RowKeySampleVectors {
std::vector<std::int64_t> offset_bytes;
};

absl::optional<v2::SampleRowKeysResponse> MakeResponse(std::string row_key,
std::int64_t offset) {
std::optional<v2::SampleRowKeysResponse> MakeResponse(std::string row_key,
std::int64_t offset) {
v2::SampleRowKeysResponse r;
r.set_row_key(std::move(row_key));
r.set_offset_bytes(offset);
return absl::make_optional(r);
return std::make_optional(r);
};

#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
Expand Down Expand Up @@ -163,7 +163,7 @@ TEST_F(AsyncSampleRowKeysTest, Simple) {
[] { return make_ready_future(MakeResponse("test2", 22)); })
.WillOnce([] {
return make_ready_future(
absl::optional<v2::SampleRowKeysResponse>{});
std::optional<v2::SampleRowKeysResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand Down Expand Up @@ -229,7 +229,7 @@ TEST_F(AsyncSampleRowKeysTest, RetryResetsSamples) {
[] { return make_ready_future(MakeResponse("forgotten", 11)); })
.WillOnce([] {
return make_ready_future(
absl::optional<v2::SampleRowKeysResponse>{});
std::optional<v2::SampleRowKeysResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(
Expand All @@ -251,7 +251,7 @@ TEST_F(AsyncSampleRowKeysTest, RetryResetsSamples) {
[] { return make_ready_future(MakeResponse("returned", 22)); })
.WillOnce([] {
return make_ready_future(
absl::optional<v2::SampleRowKeysResponse>{});
std::optional<v2::SampleRowKeysResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand Down Expand Up @@ -396,7 +396,7 @@ TEST_F(AsyncSampleRowKeysTest, RetryInfoHeeded) {
[] { return make_ready_future(MakeResponse("returned", 22)); })
.WillOnce([] {
return make_ready_future(
absl::optional<v2::SampleRowKeysResponse>{});
std::optional<v2::SampleRowKeysResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand Down Expand Up @@ -521,7 +521,7 @@ TEST_F(AsyncSampleRowKeysTest, TimerError) {
}

TEST_F(AsyncSampleRowKeysTest, CancelAfterSuccess) {
promise<absl::optional<v2::SampleRowKeysResponse>> p;
promise<std::optional<v2::SampleRowKeysResponse>> p;
#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
auto mock_metric = std::make_unique<MockMetric>();
EXPECT_CALL(*mock_metric, PreCall).Times(1);
Expand Down Expand Up @@ -582,7 +582,7 @@ TEST_F(AsyncSampleRowKeysTest, CancelAfterSuccess) {
fut.cancel();
// Proceed with the rest of the stream. In this test, there are no more
// responses to be read. The client call should succeed.
p.set_value(absl::optional<v2::SampleRowKeysResponse>{});
p.set_value(std::optional<v2::SampleRowKeysResponse>{});
auto sor = fut.get();
ASSERT_STATUS_OK(sor);
auto samples = RowKeySampleVectors(*sor);
Expand All @@ -591,7 +591,7 @@ TEST_F(AsyncSampleRowKeysTest, CancelAfterSuccess) {
}

TEST_F(AsyncSampleRowKeysTest, CancelMidStream) {
promise<absl::optional<v2::SampleRowKeysResponse>> p;
promise<std::optional<v2::SampleRowKeysResponse>> p;
#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
auto mock_metric = std::make_unique<MockMetric>();
EXPECT_CALL(*mock_metric, PreCall).Times(1);
Expand Down Expand Up @@ -636,7 +636,7 @@ TEST_F(AsyncSampleRowKeysTest, CancelMidStream) {
[] { return make_ready_future(MakeResponse("discarded", 33)); })
.WillOnce([] {
return make_ready_future(
absl::optional<v2::SampleRowKeysResponse>{});
std::optional<v2::SampleRowKeysResponse>{});
});
EXPECT_CALL(*stream, Finish).WillOnce([] {
return make_ready_future(
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable/internal/async_streaming_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AsyncStreamingReadImpl
void Read() {
auto self = this->shared_from_this();
auto read = stream_->Read();
read.then([self](future<absl::optional<Response>> f) {
read.then([self](future<std::optional<Response>> f) {
auto r = f.get();
// Read did not yield a response, finish stream.
if (!r.has_value()) return self->Finish();
Expand All @@ -79,7 +79,7 @@ class AsyncStreamingReadImpl
void Discard() {
auto self = this->shared_from_this();
auto read = stream_->Read();
read.then([self](future<absl::optional<Response>> f) {
read.then([self](future<std::optional<Response>> f) {
auto r = f.get();
// Read did not yield a response, finish stream.
if (!r.has_value()) return self->Finish();
Expand Down
12 changes: 6 additions & 6 deletions google/cloud/bigtable/internal/async_streaming_read_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ TEST(AsyncStreamingReadTest, FullStream) {
::testing::InSequence s;
EXPECT_CALL(*mock, Start).WillOnce([] { return make_ready_future(true); });
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::make_optional(FakeResponse{"v0"}));
return make_ready_future(std::make_optional(FakeResponse{"v0"}));
});
EXPECT_CALL(on_read, Call).WillOnce([](FakeResponse const& r) {
EXPECT_EQ(r.value, "v0");
return make_ready_future(true);
});
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::make_optional(FakeResponse{"v1"}));
return make_ready_future(std::make_optional(FakeResponse{"v1"}));
});
EXPECT_CALL(on_read, Call).WillOnce([](FakeResponse const& r) {
EXPECT_EQ(r.value, "v1");
return make_ready_future(true);
});
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::optional<FakeResponse>{});
return make_ready_future(std::optional<FakeResponse>{});
});
EXPECT_CALL(*mock, Finish).WillOnce([] {
return make_ready_future(Status{});
Expand Down Expand Up @@ -91,18 +91,18 @@ TEST(AsyncStreamingReadTest, CancelMidStream) {
::testing::InSequence s;
EXPECT_CALL(*mock, Start).WillOnce([] { return make_ready_future(true); });
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::make_optional(FakeResponse{"v0"}));
return make_ready_future(std::make_optional(FakeResponse{"v0"}));
});
EXPECT_CALL(on_read, Call).WillOnce([](FakeResponse const& r) {
EXPECT_EQ(r.value, "v0");
return make_ready_future(false);
});
EXPECT_CALL(*mock, Cancel);
EXPECT_CALL(*mock, Read).Times(3).WillRepeatedly([] {
return make_ready_future(absl::make_optional(FakeResponse{"ignored"}));
return make_ready_future(std::make_optional(FakeResponse{"ignored"}));
});
EXPECT_CALL(*mock, Read).WillOnce([] {
return make_ready_future(absl::optional<FakeResponse>{});
return make_ready_future(std::optional<FakeResponse>{});
});
EXPECT_CALL(*mock, Finish).WillOnce([] {
return make_ready_future(Status(StatusCode::kCancelled, "cancelled"));
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigtable/internal/bulk_mutator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Status BulkMutator::MakeOneRequest(BigtableStub& stub,

// Read the stream of responses.
auto stream = stub.MutateRows(client_context, options, mutations);
absl::optional<Status> status;
std::optional<Status> status;
while (true) {
btproto::MutateRowsResponse response;
status = stream->Read(&response);
Expand Down
Loading
Loading