@@ -39,6 +39,7 @@ namespace local {
39
39
namespace {
40
40
41
41
const char * kVersionGlobalTable = " version" ;
42
+ const char * kGlobalsTable = " globals" ;
42
43
const char * kMutationsTable = " mutation" ;
43
44
const char * kDocumentMutationsTable = " document_mutation" ;
44
45
const char * kMutationQueuesTable = " mutation_queue" ;
@@ -159,6 +160,11 @@ enum ComponentLabel {
159
160
*/
160
161
DataMigrationName = 25 ,
161
162
163
+ /* *
164
+ * The name of a global.
165
+ */
166
+ GlobalName = 26 ,
167
+
162
168
/* *
163
169
* A path segment describes just a single segment in a resource path. Path
164
170
* segments that occur sequentially in a key represent successive segments in
@@ -245,6 +251,10 @@ class Reader {
245
251
return ReadLabeledString (ComponentLabel::BundleId);
246
252
}
247
253
254
+ std::string ReadGlobalName () {
255
+ return ReadLabeledString (ComponentLabel::GlobalName);
256
+ }
257
+
248
258
std::string ReadQueryName () {
249
259
return ReadLabeledString (ComponentLabel::QueryName);
250
260
}
@@ -718,6 +728,10 @@ class Writer {
718
728
WriteLabeledString (ComponentLabel::TableName, table_name);
719
729
}
720
730
731
+ void WriteGlobalName (absl::string_view global_name) {
732
+ WriteLabeledString (ComponentLabel::GlobalName, global_name);
733
+ }
734
+
721
735
void WriteBatchId (model::BatchId batch_id) {
722
736
WriteLabeledInt32 (ComponentLabel::BatchId, batch_id);
723
737
}
@@ -1206,6 +1220,28 @@ bool LevelDbRemoteDocumentReadTimeKey::Decode(absl::string_view key) {
1206
1220
return reader.ok ();
1207
1221
}
1208
1222
1223
+ std::string LevelDbGlobalKey::KeyPrefix () {
1224
+ Writer writer;
1225
+ writer.WriteTableName (kGlobalsTable );
1226
+ return writer.result ();
1227
+ }
1228
+
1229
+ std::string LevelDbGlobalKey::Key (absl::string_view global_name) {
1230
+ Writer writer;
1231
+ writer.WriteTableName (kGlobalsTable );
1232
+ writer.WriteGlobalName (global_name);
1233
+ writer.WriteTerminator ();
1234
+ return writer.result ();
1235
+ }
1236
+
1237
+ bool LevelDbGlobalKey::Decode (absl::string_view key) {
1238
+ Reader reader{key};
1239
+ reader.ReadTableNameMatching (kGlobalsTable );
1240
+ global_name_ = reader.ReadGlobalName ();
1241
+ reader.ReadTerminator ();
1242
+ return reader.ok ();
1243
+ }
1244
+
1209
1245
std::string LevelDbBundleKey::KeyPrefix () {
1210
1246
Writer writer;
1211
1247
writer.WriteTableName (kBundlesTable );
0 commit comments