Skip to content

Commit bc58652

Browse files
committed
Fix type warnings for size_t use in Firestore (#14790)
1 parent 432064a commit bc58652

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

Firestore/core/src/local/local_store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ LruResults LocalStore::CollectGarbage(LruGarbageCollector* garbage_collector) {
585585
});
586586
}
587587

588-
int LocalStore::Backfill() const {
588+
size_t LocalStore::Backfill() const {
589589
return persistence_->Run("Backfill Indexes", [&] {
590590
return index_backfiller_->WriteIndexEntries(this);
591591
});

Firestore/core/src/local/local_store.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class LocalStore : public bundle::BundleCallback {
254254
* Runs a single backfill operation and returns the number of documents
255255
* processed.
256256
*/
257-
int Backfill() const;
257+
size_t Backfill() const;
258258

259259
/**
260260
* Returns whether the given bundle has already been loaded and its create

Firestore/core/test/unit/local/index_backfiller_test.cc

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ TEST_F(IndexBackfillerTest, WritesLatestReadTimeToFieldIndexOnCompletion) {
176176
AddFieldIndex("coll2", "bar");
177177
AddDoc("coll1/docA", Version(10), "foo", 1);
178178
AddDoc("coll2/docA", Version(20), "bar", 1);
179-
int documents_processed = local_store_.Backfill();
179+
int documents_processed = static_cast<int>(local_store_.Backfill());
180180
ASSERT_EQ(2, documents_processed);
181181

182182
auto field_index1 = index_manager_->GetFieldIndexes("coll1").at(0);
@@ -189,7 +189,7 @@ TEST_F(IndexBackfillerTest, WritesLatestReadTimeToFieldIndexOnCompletion) {
189189
AddDoc("coll2/docB", Version(60), "bar", 1);
190190
AddDoc("coll2/docC", Version(60, 10), "bar", 1);
191191

192-
documents_processed = local_store_.Backfill();
192+
documents_processed = static_cast<int>(local_store_.Backfill());
193193
ASSERT_EQ(4, documents_processed);
194194

195195
field_index1 = index_manager_->GetFieldIndexes("coll1").at(0);
@@ -205,7 +205,7 @@ TEST_F(IndexBackfillerTest, FetchesDocumentsAfterEarliestReadTime) {
205205

206206
// Documents before read time should not be fetched.
207207
AddDoc("coll1/docA", Version(9), "foo", 1);
208-
int documents_processed = local_store_.Backfill();
208+
int documents_processed = static_cast<int>(local_store_.Backfill());
209209
ASSERT_EQ(0, documents_processed);
210210

211211
// Read time should be the highest read time from the cache.
@@ -217,7 +217,7 @@ TEST_F(IndexBackfillerTest, FetchesDocumentsAfterEarliestReadTime) {
217217
// Documents that are after the earliest read time
218218
// but before field index read time are fetched.
219219
AddDoc("coll1/docB", Version(19), "boo", 1);
220-
documents_processed = local_store_.Backfill();
220+
documents_processed = static_cast<int>(local_store_.Backfill());
221221
ASSERT_EQ(1, documents_processed);
222222

223223
// Field indexes should now hold the latest read time
@@ -233,7 +233,7 @@ TEST_F(IndexBackfillerTest, WritesIndexEntries) {
233233
AddDoc("coll2/docA", Version(10), "bar", 1);
234234
AddDoc("coll2/docB", Version(10), "car", 1);
235235

236-
int documents_processed = local_store_.Backfill();
236+
int documents_processed = static_cast<int>(local_store_.Backfill());
237237
ASSERT_EQ(4, documents_processed);
238238
}
239239

@@ -245,12 +245,12 @@ TEST_F(IndexBackfillerTest, WritesOldestDocumentFirst) {
245245
AddDoc("coll1/docB", Version(3), "foo", 1);
246246
AddDoc("coll1/docC", Version(10), "foo", 1);
247247

248-
int documents_processed = local_store_.Backfill();
248+
int documents_processed = static_cast<int>(local_store_.Backfill());
249249
ASSERT_EQ(2, documents_processed);
250250

251251
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB"});
252252

253-
documents_processed = local_store_.Backfill();
253+
documents_processed = static_cast<int>(local_store_.Backfill());
254254
ASSERT_EQ(1, documents_processed);
255255

256256
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB", "coll1/docC"});
@@ -264,12 +264,12 @@ TEST_F(IndexBackfillerTest, UsesDocumentKeyOffsetForLargeSnapshots) {
264264
AddDoc("coll1/docB", Version(1), "foo", 1);
265265
AddDoc("coll1/docC", Version(1), "foo", 1);
266266

267-
int documents_processed = local_store_.Backfill();
267+
int documents_processed = static_cast<int>(local_store_.Backfill());
268268
ASSERT_EQ(2, documents_processed);
269269

270270
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB"});
271271

272-
documents_processed = local_store_.Backfill();
272+
documents_processed = static_cast<int>(local_store_.Backfill());
273273
ASSERT_EQ(1, documents_processed);
274274

275275
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB", "coll1/docC"});
@@ -290,7 +290,7 @@ TEST_F(IndexBackfillerTest, UpdatesCollectionGroups) {
290290
ASSERT_TRUE(collection_group.has_value());
291291
ASSERT_EQ("coll1", collection_group.value());
292292

293-
int documents_processed = local_store_.Backfill();
293+
int documents_processed = static_cast<int>(local_store_.Backfill());
294294
ASSERT_EQ(2, documents_processed);
295295

296296
// Check that coll1 was backfilled and that coll2 is next
@@ -318,7 +318,7 @@ TEST_F(IndexBackfillerTest, PrioritizesNewCollectionGroups) {
318318
ASSERT_TRUE(collection_group.has_value());
319319
ASSERT_EQ("coll3", collection_group.value());
320320

321-
int documents_processed = local_store_.Backfill();
321+
int documents_processed = static_cast<int>(local_store_.Backfill());
322322
ASSERT_EQ(1, documents_processed);
323323

324324
VerifyQueryResults("coll3", {"coll3/doc"});
@@ -334,7 +334,7 @@ TEST_F(IndexBackfillerTest, WritesUntilCap) {
334334
AddDoc("coll2/docA", Version(30), "foo", 1);
335335
AddDoc("coll2/docA", Version(40), "foo", 1);
336336

337-
int documents_processed = local_store_.Backfill();
337+
int documents_processed = static_cast<int>(local_store_.Backfill());
338338
ASSERT_EQ(3, documents_processed);
339339

340340
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB"});
@@ -345,13 +345,13 @@ TEST_F(IndexBackfillerTest, UsesLatestReadTimeForEmptyCollections) {
345345
AddFieldIndex("coll", "foo", Version(1));
346346
AddDoc("readtime/doc", Version(1), "foo", 1);
347347

348-
int documents_processed = local_store_.Backfill();
348+
int documents_processed = static_cast<int>(local_store_.Backfill());
349349
ASSERT_EQ(0, documents_processed);
350350

351351
AddDoc("coll/ignored", Version(2), "foo", 1);
352352
AddDoc("coll/added", Version(3), "foo", 1);
353353

354-
documents_processed = local_store_.Backfill();
354+
documents_processed = static_cast<int>(local_store_.Backfill());
355355
ASSERT_EQ(2, documents_processed);
356356
}
357357

@@ -364,11 +364,11 @@ TEST_F(IndexBackfillerTest, HandlesLocalMutationsAfterRemoteDocs) {
364364
AddDoc("coll1/docC", Version(30), "foo", 1);
365365
AddSetMutationsToOverlay(1, {"coll1/docD"});
366366

367-
int documents_processed = local_store_.Backfill();
367+
int documents_processed = static_cast<int>(local_store_.Backfill());
368368
ASSERT_EQ(2, documents_processed);
369369
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB"});
370370

371-
documents_processed = local_store_.Backfill();
371+
documents_processed = static_cast<int>(local_store_.Backfill());
372372
ASSERT_EQ(2, documents_processed);
373373
VerifyQueryResults("coll1",
374374
{"coll1/docA", "coll1/docB", "coll1/docC", "coll1/docD"});
@@ -383,13 +383,13 @@ TEST_F(IndexBackfillerTest,
383383
AddSetMutationsToOverlay(3, {"coll1/docC"});
384384
AddSetMutationsToOverlay(4, {"coll1/docD"});
385385

386-
int documents_processed = local_store_.Backfill();
386+
int documents_processed = static_cast<int>(local_store_.Backfill());
387387
ASSERT_EQ(2, documents_processed);
388388
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB"});
389389
auto field_index = index_manager_->GetFieldIndexes("coll1").at(0);
390390
ASSERT_EQ(2, field_index.index_state().index_offset().largest_batch_id());
391391

392-
documents_processed = local_store_.Backfill();
392+
documents_processed = static_cast<int>(local_store_.Backfill());
393393
ASSERT_EQ(2, documents_processed);
394394
VerifyQueryResults("coll1",
395395
{"coll1/docA", "coll1/docB", "coll1/docC", "coll1/docD"});
@@ -404,7 +404,7 @@ TEST_F(IndexBackfillerTest, MutationFinishesMutationBatchEvenIfItExceedsLimit) {
404404
AddSetMutationsToOverlay(2, {"coll1/docB", "coll1/docC", "coll1/docD"});
405405
AddSetMutationsToOverlay(3, {"coll1/docE"});
406406

407-
int documents_processed = local_store_.Backfill();
407+
int documents_processed = static_cast<int>(local_store_.Backfill());
408408
ASSERT_EQ(4, documents_processed);
409409
VerifyQueryResults("coll1",
410410
{"coll1/docA", "coll1/docB", "coll1/docC", "coll1/docD"});
@@ -416,13 +416,13 @@ TEST_F(IndexBackfillerTest, MutationsFromHighWaterMark) {
416416
AddDoc("coll1/docA", Version(10), "foo", 1);
417417
AddSetMutationsToOverlay(3, {"coll1/docB"});
418418

419-
int documents_processed = local_store_.Backfill();
419+
int documents_processed = static_cast<int>(local_store_.Backfill());
420420
ASSERT_EQ(2, documents_processed);
421421
VerifyQueryResults("coll1", {"coll1/docA", "coll1/docB"});
422422

423423
AddSetMutationsToOverlay(1, {"coll1/docC"});
424424
AddSetMutationsToOverlay(2, {"coll1/docD"});
425-
documents_processed = local_store_.Backfill();
425+
documents_processed = static_cast<int>(local_store_.Backfill());
426426
ASSERT_EQ(0, documents_processed);
427427
}
428428

@@ -432,7 +432,7 @@ TEST_F(IndexBackfillerTest, UpdatesExistingDocToNewValue) {
432432

433433
AddDoc("coll/doc", Version(10), "foo", 1);
434434

435-
int documents_processed = local_store_.Backfill();
435+
int documents_processed = static_cast<int>(local_store_.Backfill());
436436
ASSERT_EQ(1, documents_processed);
437437
VerifyQueryResults(query, {});
438438

@@ -448,15 +448,15 @@ TEST_F(IndexBackfillerTest, UpdatesDocsThatNoLongerMatch) {
448448
AddFieldIndex("coll", "foo");
449449
AddDoc("coll/doc", Version(10), "foo", 1);
450450

451-
int documents_processed = local_store_.Backfill();
451+
int documents_processed = static_cast<int>(local_store_.Backfill());
452452
ASSERT_EQ(1, documents_processed);
453453
VerifyQueryResults(query, {"coll/doc"});
454454

455455
// Update doc to new remote version with new value that doesn't match field
456456
// index.
457457
AddDoc("coll/doc", Version(40), "foo", -1);
458458

459-
documents_processed = local_store_.Backfill();
459+
documents_processed = static_cast<int>(local_store_.Backfill());
460460
ASSERT_EQ(1, documents_processed);
461461
VerifyQueryResults(query, {});
462462
}
@@ -466,7 +466,7 @@ TEST_F(IndexBackfillerTest, DoesNotProcessSameDocumentTwice) {
466466
AddDoc("coll/doc", Version(5), "foo", 1);
467467
AddSetMutationsToOverlay(1, {"coll/doc"});
468468

469-
int documents_processed = local_store_.Backfill();
469+
int documents_processed = static_cast<int>(local_store_.Backfill());
470470
ASSERT_EQ(1, documents_processed);
471471

472472
const auto field_index = index_manager_->GetFieldIndexes("coll").at(0);
@@ -478,13 +478,13 @@ TEST_F(IndexBackfillerTest, AppliesSetToRemoteDoc) {
478478
AddFieldIndex("coll", "foo");
479479
AddDoc("coll/doc", Version(5), "boo", 1);
480480

481-
int documents_processed = local_store_.Backfill();
481+
int documents_processed = static_cast<int>(local_store_.Backfill());
482482
ASSERT_EQ(1, documents_processed);
483483

484484
model::Mutation patch = PatchMutation("coll/doc", Map("foo", "bar"));
485485
AddMutationToOverlay("coll/doc", patch);
486486

487-
documents_processed = local_store_.Backfill();
487+
documents_processed = static_cast<int>(local_store_.Backfill());
488488
ASSERT_EQ(1, documents_processed);
489489

490490
VerifyQueryResults("coll", {"coll/doc"});
@@ -498,15 +498,15 @@ TEST_F(IndexBackfillerTest, AppliesPatchToRemoteDoc) {
498498
AddFieldIndex("coll", "b");
499499
AddDoc("coll/doc", Version(5), "a", 1);
500500

501-
int documents_processed = local_store_.Backfill();
501+
int documents_processed = static_cast<int>(local_store_.Backfill());
502502
ASSERT_EQ(1, documents_processed);
503503

504504
VerifyQueryResults(query_a, {"coll/doc"});
505505
VerifyQueryResults(query_b, {});
506506

507507
model::Mutation patch = PatchMutation("coll/doc", Map("b", 1));
508508
AddMutationToOverlay("coll/doc", patch);
509-
documents_processed = local_store_.Backfill();
509+
documents_processed = static_cast<int>(local_store_.Backfill());
510510
ASSERT_EQ(1, documents_processed);
511511

512512
VerifyQueryResults(query_a, {"coll/doc"});
@@ -517,12 +517,12 @@ TEST_F(IndexBackfillerTest, AppliesDeleteToRemoteDoc) {
517517
AddFieldIndex("coll", "foo");
518518
AddDoc("coll/doc", Version(5), "foo", 1);
519519

520-
int documents_processed = local_store_.Backfill();
520+
int documents_processed = static_cast<int>(local_store_.Backfill());
521521
ASSERT_EQ(1, documents_processed);
522522

523523
const model::DeleteMutation delete_mutation = DeleteMutation("coll/doc");
524524
AddMutationToOverlay("coll/doc", delete_mutation);
525-
documents_processed = local_store_.Backfill();
525+
documents_processed = static_cast<int>(local_store_.Backfill());
526526
ASSERT_EQ(1, documents_processed);
527527

528528
persistence_->Run("BackfillAppliesDeleteToRemoteDoc", [&] {
@@ -541,13 +541,13 @@ TEST_F(IndexBackfillerTest, ReindexesDocumentsWhenNewIndexIsAdded) {
541541
AddDoc("coll/doc1", Version(1), "a", 1);
542542
AddDoc("coll/doc2", Version(1), "b", 1);
543543

544-
int documents_processed = local_store_.Backfill();
544+
int documents_processed = static_cast<int>(local_store_.Backfill());
545545
ASSERT_EQ(2, documents_processed);
546546
VerifyQueryResults(query_a, {"coll/doc1"});
547547
VerifyQueryResults(query_b, {});
548548

549549
AddFieldIndex("coll", "b");
550-
documents_processed = local_store_.Backfill();
550+
documents_processed = static_cast<int>(local_store_.Backfill());
551551
ASSERT_EQ(2, documents_processed);
552552

553553
VerifyQueryResults(query_a, {"coll/doc1"});

0 commit comments

Comments
 (0)