File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -696,14 +696,30 @@ class Value {
696696 if (!t.has_map_type () || v.array_value ().values ().empty ()) return ;
697697 std::map<std::string, google::bigtable::v2::Value> m;
698698 for (auto const & kv : v.array_value ().values ()) {
699- auto key = kv.array_value ().values ()[0 ];
699+ auto key_proto = kv.array_value ().values ()[0 ];
700+ std::string key;
701+ switch (key_proto.kind_case ()) {
702+ case google::bigtable::v2::Value::kStringValue :
703+ key = key_proto.string_value ();
704+ break ;
705+ case google::bigtable::v2::Value::kBytesValue :
706+ key = key_proto.bytes_value ();
707+ break ;
708+ case google::bigtable::v2::Value::kIntValue :
709+ key = std::to_string (key_proto.int_value ());
710+ break ;
711+ default :
712+ // Undefined behavior for malformed proto. We leave it as is and
713+ // return.
714+ return ;
715+ }
700716 // the documented behavior indicates that the last value will take
701717 // precedence for a given key.
702- auto pos = m.find (key. raw_value () );
718+ auto pos = m.find (key);
703719 if (pos != m.end ()) {
704720 m.erase (pos);
705721 }
706- m.insert (std::make_pair (key. raw_value () , std::move (kv)));
722+ m.insert (std::make_pair (key, std::move (kv)));
707723 }
708724 auto new_array_value = google::bigtable::v2::ArrayValue ();
709725 for (auto const & kv : m) {
You can’t perform that action at this time.
0 commit comments