Skip to content

Commit 3662a9b

Browse files
committed
firestore::local::LevelDbDocumentOverlayCache added.
1 parent 37c273f commit 3662a9b

18 files changed

+1284
-22
lines changed

Firestore/Protos/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ endif()
3030
# excluding anything in google/protobuf.
3131
set(
3232
PROTO_FILE_ROOTS
33+
firestore/local/document_overlay
3334
firestore/local/maybe_document
3435
firestore/local/mutation
3536
firestore/local/target
Lines changed: 356 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,356 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Generated by the protocol buffer compiler. DO NOT EDIT!
18+
// source: firestore/local/document_overlay.proto
19+
20+
#include "firestore/local/document_overlay.pb.h"
21+
22+
#include <algorithm>
23+
24+
#include <google/protobuf/io/coded_stream.h>
25+
#include <google/protobuf/extension_set.h>
26+
#include <google/protobuf/wire_format_lite.h>
27+
#include <google/protobuf/descriptor.h>
28+
#include <google/protobuf/generated_message_reflection.h>
29+
#include <google/protobuf/reflection_ops.h>
30+
#include <google/protobuf/wire_format.h>
31+
// @@protoc_insertion_point(includes)
32+
#include <google/protobuf/port_def.inc>
33+
extern PROTOBUF_INTERNAL_EXPORT_google_2ffirestore_2fv1_2fwrite_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<5> scc_info_Write_google_2ffirestore_2fv1_2fwrite_2eproto;
34+
namespace firestore {
35+
namespace client {
36+
class DocumentOverlayDefaultTypeInternal {
37+
public:
38+
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<DocumentOverlay> _instance;
39+
} _DocumentOverlay_default_instance_;
40+
} // namespace client
41+
} // namespace firestore
42+
static void InitDefaultsscc_info_DocumentOverlay_firestore_2flocal_2fdocument_5foverlay_2eproto() {
43+
GOOGLE_PROTOBUF_VERIFY_VERSION;
44+
45+
{
46+
void* ptr = &::firestore::client::_DocumentOverlay_default_instance_;
47+
new (ptr) ::firestore::client::DocumentOverlay();
48+
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
49+
}
50+
::firestore::client::DocumentOverlay::InitAsDefaultInstance();
51+
}
52+
53+
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_DocumentOverlay_firestore_2flocal_2fdocument_5foverlay_2eproto =
54+
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_DocumentOverlay_firestore_2flocal_2fdocument_5foverlay_2eproto}, {
55+
&scc_info_Write_google_2ffirestore_2fv1_2fwrite_2eproto.base,}};
56+
57+
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_firestore_2flocal_2fdocument_5foverlay_2eproto[1];
58+
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_firestore_2flocal_2fdocument_5foverlay_2eproto = nullptr;
59+
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_firestore_2flocal_2fdocument_5foverlay_2eproto = nullptr;
60+
61+
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_firestore_2flocal_2fdocument_5foverlay_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
62+
~0u, // no _has_bits_
63+
PROTOBUF_FIELD_OFFSET(::firestore::client::DocumentOverlay, _internal_metadata_),
64+
~0u, // no _extensions_
65+
~0u, // no _oneof_case_
66+
~0u, // no _weak_field_map_
67+
PROTOBUF_FIELD_OFFSET(::firestore::client::DocumentOverlay, largest_batch_id_),
68+
PROTOBUF_FIELD_OFFSET(::firestore::client::DocumentOverlay, overlay_mutation_),
69+
};
70+
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
71+
{ 0, -1, sizeof(::firestore::client::DocumentOverlay)},
72+
};
73+
74+
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
75+
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::firestore::client::_DocumentOverlay_default_instance_),
76+
};
77+
78+
const char descriptor_table_protodef_firestore_2flocal_2fdocument_5foverlay_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
79+
"\n&firestore/local/document_overlay.proto"
80+
"\022\020firestore.client\032\037google/firestore/v1/"
81+
"write.proto\032\037google/protobuf/timestamp.p"
82+
"roto\"a\n\017DocumentOverlay\022\030\n\020largest_batch"
83+
"_id\030\001 \001(\005\0224\n\020overlay_mutation\030\002 \001(\0132\032.go"
84+
"ogle.firestore.v1.WriteB/\n#com.google.fi"
85+
"rebase.firestore.protoP\001\242\002\005FSTPBb\006proto3"
86+
;
87+
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_deps[2] = {
88+
&::descriptor_table_google_2ffirestore_2fv1_2fwrite_2eproto,
89+
&::descriptor_table_google_2fprotobuf_2ftimestamp_2eproto,
90+
};
91+
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_sccs[1] = {
92+
&scc_info_DocumentOverlay_firestore_2flocal_2fdocument_5foverlay_2eproto.base,
93+
};
94+
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_once;
95+
static bool descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_initialized = false;
96+
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto = {
97+
&descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_initialized, descriptor_table_protodef_firestore_2flocal_2fdocument_5foverlay_2eproto, "firestore/local/document_overlay.proto", 280,
98+
&descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_once, descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_sccs, descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto_deps, 1, 2,
99+
schemas, file_default_instances, TableStruct_firestore_2flocal_2fdocument_5foverlay_2eproto::offsets,
100+
file_level_metadata_firestore_2flocal_2fdocument_5foverlay_2eproto, 1, file_level_enum_descriptors_firestore_2flocal_2fdocument_5foverlay_2eproto, file_level_service_descriptors_firestore_2flocal_2fdocument_5foverlay_2eproto,
101+
};
102+
103+
// Force running AddDescriptors() at dynamic initialization time.
104+
static bool dynamic_init_dummy_firestore_2flocal_2fdocument_5foverlay_2eproto = ( ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_firestore_2flocal_2fdocument_5foverlay_2eproto), true);
105+
namespace firestore {
106+
namespace client {
107+
108+
// ===================================================================
109+
110+
void DocumentOverlay::InitAsDefaultInstance() {
111+
::firestore::client::_DocumentOverlay_default_instance_._instance.get_mutable()->overlay_mutation_ = const_cast< ::google::firestore::v1::Write*>(
112+
::google::firestore::v1::Write::internal_default_instance());
113+
}
114+
class DocumentOverlay::_Internal {
115+
public:
116+
static const ::google::firestore::v1::Write& overlay_mutation(const DocumentOverlay* msg);
117+
};
118+
119+
const ::google::firestore::v1::Write&
120+
DocumentOverlay::_Internal::overlay_mutation(const DocumentOverlay* msg) {
121+
return *msg->overlay_mutation_;
122+
}
123+
void DocumentOverlay::clear_overlay_mutation() {
124+
if (GetArenaNoVirtual() == nullptr && overlay_mutation_ != nullptr) {
125+
delete overlay_mutation_;
126+
}
127+
overlay_mutation_ = nullptr;
128+
}
129+
DocumentOverlay::DocumentOverlay()
130+
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
131+
SharedCtor();
132+
// @@protoc_insertion_point(constructor:firestore.client.DocumentOverlay)
133+
}
134+
DocumentOverlay::DocumentOverlay(const DocumentOverlay& from)
135+
: ::PROTOBUF_NAMESPACE_ID::Message(),
136+
_internal_metadata_(nullptr) {
137+
_internal_metadata_.MergeFrom(from._internal_metadata_);
138+
if (from._internal_has_overlay_mutation()) {
139+
overlay_mutation_ = new ::google::firestore::v1::Write(*from.overlay_mutation_);
140+
} else {
141+
overlay_mutation_ = nullptr;
142+
}
143+
largest_batch_id_ = from.largest_batch_id_;
144+
// @@protoc_insertion_point(copy_constructor:firestore.client.DocumentOverlay)
145+
}
146+
147+
void DocumentOverlay::SharedCtor() {
148+
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_DocumentOverlay_firestore_2flocal_2fdocument_5foverlay_2eproto.base);
149+
::memset(&overlay_mutation_, 0, static_cast<size_t>(
150+
reinterpret_cast<char*>(&largest_batch_id_) -
151+
reinterpret_cast<char*>(&overlay_mutation_)) + sizeof(largest_batch_id_));
152+
}
153+
154+
DocumentOverlay::~DocumentOverlay() {
155+
// @@protoc_insertion_point(destructor:firestore.client.DocumentOverlay)
156+
SharedDtor();
157+
}
158+
159+
void DocumentOverlay::SharedDtor() {
160+
if (this != internal_default_instance()) delete overlay_mutation_;
161+
}
162+
163+
void DocumentOverlay::SetCachedSize(int size) const {
164+
_cached_size_.Set(size);
165+
}
166+
const DocumentOverlay& DocumentOverlay::default_instance() {
167+
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_DocumentOverlay_firestore_2flocal_2fdocument_5foverlay_2eproto.base);
168+
return *internal_default_instance();
169+
}
170+
171+
172+
void DocumentOverlay::Clear() {
173+
// @@protoc_insertion_point(message_clear_start:firestore.client.DocumentOverlay)
174+
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
175+
// Prevent compiler warnings about cached_has_bits being unused
176+
(void) cached_has_bits;
177+
178+
if (GetArenaNoVirtual() == nullptr && overlay_mutation_ != nullptr) {
179+
delete overlay_mutation_;
180+
}
181+
overlay_mutation_ = nullptr;
182+
largest_batch_id_ = 0;
183+
_internal_metadata_.Clear();
184+
}
185+
186+
const char* DocumentOverlay::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
187+
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
188+
while (!ctx->Done(&ptr)) {
189+
::PROTOBUF_NAMESPACE_ID::uint32 tag;
190+
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
191+
CHK_(ptr);
192+
switch (tag >> 3) {
193+
// int32 largest_batch_id = 1;
194+
case 1:
195+
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
196+
largest_batch_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
197+
CHK_(ptr);
198+
} else goto handle_unusual;
199+
continue;
200+
// .google.firestore.v1.Write overlay_mutation = 2;
201+
case 2:
202+
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
203+
ptr = ctx->ParseMessage(_internal_mutable_overlay_mutation(), ptr);
204+
CHK_(ptr);
205+
} else goto handle_unusual;
206+
continue;
207+
default: {
208+
handle_unusual:
209+
if ((tag & 7) == 4 || tag == 0) {
210+
ctx->SetLastTag(tag);
211+
goto success;
212+
}
213+
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
214+
CHK_(ptr != nullptr);
215+
continue;
216+
}
217+
} // switch
218+
} // while
219+
success:
220+
return ptr;
221+
failure:
222+
ptr = nullptr;
223+
goto success;
224+
#undef CHK_
225+
}
226+
227+
::PROTOBUF_NAMESPACE_ID::uint8* DocumentOverlay::_InternalSerialize(
228+
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
229+
// @@protoc_insertion_point(serialize_to_array_start:firestore.client.DocumentOverlay)
230+
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
231+
(void) cached_has_bits;
232+
233+
// int32 largest_batch_id = 1;
234+
if (this->largest_batch_id() != 0) {
235+
target = stream->EnsureSpace(target);
236+
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_largest_batch_id(), target);
237+
}
238+
239+
// .google.firestore.v1.Write overlay_mutation = 2;
240+
if (this->has_overlay_mutation()) {
241+
target = stream->EnsureSpace(target);
242+
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
243+
InternalWriteMessage(
244+
2, _Internal::overlay_mutation(this), target, stream);
245+
}
246+
247+
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
248+
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
249+
_internal_metadata_.unknown_fields(), target, stream);
250+
}
251+
// @@protoc_insertion_point(serialize_to_array_end:firestore.client.DocumentOverlay)
252+
return target;
253+
}
254+
255+
size_t DocumentOverlay::ByteSizeLong() const {
256+
// @@protoc_insertion_point(message_byte_size_start:firestore.client.DocumentOverlay)
257+
size_t total_size = 0;
258+
259+
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
260+
// Prevent compiler warnings about cached_has_bits being unused
261+
(void) cached_has_bits;
262+
263+
// .google.firestore.v1.Write overlay_mutation = 2;
264+
if (this->has_overlay_mutation()) {
265+
total_size += 1 +
266+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
267+
*overlay_mutation_);
268+
}
269+
270+
// int32 largest_batch_id = 1;
271+
if (this->largest_batch_id() != 0) {
272+
total_size += 1 +
273+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
274+
this->_internal_largest_batch_id());
275+
}
276+
277+
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
278+
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
279+
_internal_metadata_, total_size, &_cached_size_);
280+
}
281+
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
282+
SetCachedSize(cached_size);
283+
return total_size;
284+
}
285+
286+
void DocumentOverlay::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
287+
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.DocumentOverlay)
288+
GOOGLE_DCHECK_NE(&from, this);
289+
const DocumentOverlay* source =
290+
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<DocumentOverlay>(
291+
&from);
292+
if (source == nullptr) {
293+
// @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.DocumentOverlay)
294+
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
295+
} else {
296+
// @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.DocumentOverlay)
297+
MergeFrom(*source);
298+
}
299+
}
300+
301+
void DocumentOverlay::MergeFrom(const DocumentOverlay& from) {
302+
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.DocumentOverlay)
303+
GOOGLE_DCHECK_NE(&from, this);
304+
_internal_metadata_.MergeFrom(from._internal_metadata_);
305+
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
306+
(void) cached_has_bits;
307+
308+
if (from.has_overlay_mutation()) {
309+
_internal_mutable_overlay_mutation()->::google::firestore::v1::Write::MergeFrom(from._internal_overlay_mutation());
310+
}
311+
if (from.largest_batch_id() != 0) {
312+
_internal_set_largest_batch_id(from._internal_largest_batch_id());
313+
}
314+
}
315+
316+
void DocumentOverlay::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
317+
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.DocumentOverlay)
318+
if (&from == this) return;
319+
Clear();
320+
MergeFrom(from);
321+
}
322+
323+
void DocumentOverlay::CopyFrom(const DocumentOverlay& from) {
324+
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.DocumentOverlay)
325+
if (&from == this) return;
326+
Clear();
327+
MergeFrom(from);
328+
}
329+
330+
bool DocumentOverlay::IsInitialized() const {
331+
return true;
332+
}
333+
334+
void DocumentOverlay::InternalSwap(DocumentOverlay* other) {
335+
using std::swap;
336+
_internal_metadata_.Swap(&other->_internal_metadata_);
337+
swap(overlay_mutation_, other->overlay_mutation_);
338+
swap(largest_batch_id_, other->largest_batch_id_);
339+
}
340+
341+
::PROTOBUF_NAMESPACE_ID::Metadata DocumentOverlay::GetMetadata() const {
342+
return GetMetadataStatic();
343+
}
344+
345+
346+
// @@protoc_insertion_point(namespace_scope)
347+
} // namespace client
348+
} // namespace firestore
349+
PROTOBUF_NAMESPACE_OPEN
350+
template<> PROTOBUF_NOINLINE ::firestore::client::DocumentOverlay* Arena::CreateMaybeMessage< ::firestore::client::DocumentOverlay >(Arena* arena) {
351+
return Arena::CreateInternal< ::firestore::client::DocumentOverlay >(arena);
352+
}
353+
PROTOBUF_NAMESPACE_CLOSE
354+
355+
// @@protoc_insertion_point(global_scope)
356+
#include <google/protobuf/port_undef.inc>

0 commit comments

Comments
 (0)