Skip to content

Commit 04f7a48

Browse files
authored
ci(bigtable): update PartialResultSetSource to handle Cord usage (#15645)
* ci(bigtable): update PartialResultSetSource to handle Cord usage
1 parent b14d373 commit 04f7a48

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

google/cloud/bigtable/internal/partial_result_set_source.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,28 @@
1717
#include "google/cloud/internal/absl_str_cat_quiet.h"
1818
#include "google/cloud/internal/make_status.h"
1919
#include "google/cloud/log.h"
20+
#include "absl/strings/cord.h"
2021
#include "absl/types/optional.h"
2122

2223
namespace google {
2324
namespace cloud {
2425
namespace bigtable_internal {
2526

2627
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
28+
namespace {
29+
// Some Bigtable proto fields use Cord internally and string externally.
30+
template <typename T, typename std::enable_if<
31+
std::is_same<T, std::string>::value>::type* = nullptr>
32+
std::string AsString(T const& s) {
33+
return s;
34+
}
35+
36+
template <typename T, typename std::enable_if<
37+
std::is_same<T, absl::Cord>::value>::type* = nullptr>
38+
std::string AsString(T const& s) {
39+
return std::string(s);
40+
}
41+
} // namespace
2742

2843
StatusOr<std::unique_ptr<bigtable::ResultSourceInterface>>
2944
PartialResultSetSource::Create(
@@ -163,7 +178,7 @@ Status PartialResultSetSource::ProcessDataFromStream(
163178
rows_.insert(rows_.end(), buffered_rows_.begin(), buffered_rows_.end());
164179
buffered_rows_.clear();
165180
read_buffer_.clear();
166-
resume_token_ = result.resume_token();
181+
resume_token_ = AsString(result.resume_token());
167182
}
168183
return {}; // OK
169184
}

0 commit comments

Comments
 (0)