@@ -321,7 +321,7 @@ bool ReadDocumentKey(leveldb::Slice *contents, DocumentKey *result) {
321
321
leveldb::Slice complete_segments = *contents;
322
322
323
323
std::string segment;
324
- std::vector<std::string> path_segments{} ;
324
+ std::vector<std::string> path_segments;
325
325
for (;;) {
326
326
// Advance a temporary slice to avoid advancing contents into the next key
327
327
// component which may not be a path segment.
@@ -343,7 +343,7 @@ bool ReadDocumentKey(leveldb::Slice *contents, DocumentKey *result) {
343
343
ResourcePath path{std::move (path_segments)};
344
344
if (path.size () > 0 && DocumentKey::IsDocumentKey (path)) {
345
345
*contents = complete_segments;
346
- *result = DocumentKey ( std::move (path)) ;
346
+ *result = DocumentKey{ std::move (path)} ;
347
347
return true ;
348
348
}
349
349
@@ -370,37 +370,37 @@ inline bool ReadTableNameMatching(leveldb::Slice *contents,
370
370
expected_table_name);
371
371
}
372
372
373
- inline void WriteBatchID (std::string *dest, model::BatchId batch_id) {
373
+ inline void WriteBatchId (std::string *dest, model::BatchId batch_id) {
374
374
WriteLabeledInt32 (dest, ComponentLabel::BatchId, batch_id);
375
375
}
376
376
377
- inline bool ReadBatchID (leveldb::Slice *contents, model::BatchId *batch_id) {
377
+ inline bool ReadBatchId (leveldb::Slice *contents, model::BatchId *batch_id) {
378
378
return ReadLabeledInt32 (contents, ComponentLabel::BatchId, batch_id);
379
379
}
380
380
381
- inline void WriteCanonicalID (std::string *dest,
381
+ inline void WriteCanonicalId (std::string *dest,
382
382
absl::string_view canonical_id) {
383
383
WriteLabeledString (dest, ComponentLabel::CanonicalId, canonical_id);
384
384
}
385
385
386
- inline bool ReadCanonicalID (leveldb::Slice *contents,
386
+ inline bool ReadCanonicalId (leveldb::Slice *contents,
387
387
std::string *canonical_id) {
388
388
return ReadLabeledString (contents, ComponentLabel::CanonicalId, canonical_id);
389
389
}
390
390
391
- inline void WriteTargetID (std::string *dest, model::TargetId target_id) {
391
+ inline void WriteTargetId (std::string *dest, model::TargetId target_id) {
392
392
WriteLabeledInt32 (dest, ComponentLabel::TargetId, target_id);
393
393
}
394
394
395
- inline bool ReadTargetID (leveldb::Slice *contents, model::TargetId *target_id) {
395
+ inline bool ReadTargetId (leveldb::Slice *contents, model::TargetId *target_id) {
396
396
return ReadLabeledInt32 (contents, ComponentLabel::TargetId, target_id);
397
397
}
398
398
399
- inline void WriteUserID (std::string *dest, absl::string_view user_id) {
399
+ inline void WriteUserId (std::string *dest, absl::string_view user_id) {
400
400
WriteLabeledString (dest, ComponentLabel::UserId, user_id);
401
401
}
402
402
403
- inline bool ReadUserID (leveldb::Slice *contents, std::string *user_id) {
403
+ inline bool ReadUserId (leveldb::Slice *contents, std::string *user_id) {
404
404
return ReadLabeledString (contents, ComponentLabel::UserId, user_id);
405
405
}
406
406
@@ -457,28 +457,28 @@ std::string Describe(leveldb::Slice key) {
457
457
458
458
} else if (label == ComponentLabel::BatchId) {
459
459
model::BatchId batch_id;
460
- if (!ReadBatchID (&tmp, &batch_id)) {
460
+ if (!ReadBatchId (&tmp, &batch_id)) {
461
461
break ;
462
462
}
463
463
absl::StrAppend (&description, " batch_id=" , batch_id);
464
464
465
465
} else if (label == ComponentLabel::CanonicalId) {
466
466
std::string canonical_id;
467
- if (!ReadCanonicalID (&tmp, &canonical_id)) {
467
+ if (!ReadCanonicalId (&tmp, &canonical_id)) {
468
468
break ;
469
469
}
470
470
absl::StrAppend (&description, " canonical_id=" , canonical_id);
471
471
472
472
} else if (label == ComponentLabel::TargetId) {
473
473
model::TargetId target_id;
474
- if (!ReadTargetID (&tmp, &target_id)) {
474
+ if (!ReadTargetId (&tmp, &target_id)) {
475
475
break ;
476
476
}
477
477
absl::StrAppend (&description, " target_id=" , target_id);
478
478
479
479
} else if (label == ComponentLabel::UserId) {
480
480
std::string user_id;
481
- if (!ReadUserID (&tmp, &user_id)) {
481
+ if (!ReadUserId (&tmp, &user_id)) {
482
482
break ;
483
483
}
484
484
absl::StrAppend (&description, " user_id=" , user_id);
@@ -518,25 +518,26 @@ std::string LevelDbMutationKey::KeyPrefix() {
518
518
std::string LevelDbMutationKey::KeyPrefix (absl::string_view user_id) {
519
519
std::string result;
520
520
WriteTableName (&result, kMutationsTable );
521
- WriteUserID (&result, user_id);
521
+ WriteUserId (&result, user_id);
522
522
return result;
523
523
}
524
524
525
525
std::string LevelDbMutationKey::Key (absl::string_view user_id,
526
526
model::BatchId batch_id) {
527
527
std::string result;
528
528
WriteTableName (&result, kMutationsTable );
529
- WriteUserID (&result, user_id);
530
- WriteBatchID (&result, batch_id);
529
+ WriteUserId (&result, user_id);
530
+ WriteBatchId (&result, batch_id);
531
531
WriteTerminator (&result);
532
532
return result;
533
533
}
534
534
535
535
bool LevelDbMutationKey::Decode (leveldb::Slice key) {
536
536
user_id_.clear ();
537
+ batch_id_ = 0 ;
537
538
538
539
return ReadTableNameMatching (&key, kMutationsTable ) &&
539
- ReadUserID (&key, &user_id_) && ReadBatchID (&key, &batch_id_) &&
540
+ ReadUserId (&key, &user_id_) && ReadBatchId (&key, &batch_id_) &&
540
541
ReadTerminator (&key);
541
542
}
542
543
@@ -549,15 +550,15 @@ std::string LevelDbDocumentMutationKey::KeyPrefix() {
549
550
std::string LevelDbDocumentMutationKey::KeyPrefix (absl::string_view user_id) {
550
551
std::string result;
551
552
WriteTableName (&result, kDocumentMutationsTable );
552
- WriteUserID (&result, user_id);
553
+ WriteUserId (&result, user_id);
553
554
return result;
554
555
}
555
556
556
557
std::string LevelDbDocumentMutationKey::KeyPrefix (
557
558
absl::string_view user_id, const ResourcePath &resource_path) {
558
559
std::string result;
559
560
WriteTableName (&result, kDocumentMutationsTable );
560
- WriteUserID (&result, user_id);
561
+ WriteUserId (&result, user_id);
561
562
WriteResourcePath (&result, resource_path);
562
563
return result;
563
564
}
@@ -567,20 +568,21 @@ std::string LevelDbDocumentMutationKey::Key(absl::string_view user_id,
567
568
model::BatchId batch_id) {
568
569
std::string result;
569
570
WriteTableName (&result, kDocumentMutationsTable );
570
- WriteUserID (&result, user_id);
571
+ WriteUserId (&result, user_id);
571
572
WriteResourcePath (&result, document_key.path ());
572
- WriteBatchID (&result, batch_id);
573
+ WriteBatchId (&result, batch_id);
573
574
WriteTerminator (&result);
574
575
return result;
575
576
}
576
577
577
578
bool LevelDbDocumentMutationKey::Decode (leveldb::Slice key) {
578
579
user_id_.clear ();
579
580
document_key_ = DocumentKey{};
581
+ batch_id_ = 0 ;
580
582
581
583
return ReadTableNameMatching (&key, kDocumentMutationsTable ) &&
582
- ReadUserID (&key, &user_id_) && ReadDocumentKey (&key, &document_key_) &&
583
- ReadBatchID (&key, &batch_id_) && ReadTerminator (&key);
584
+ ReadUserId (&key, &user_id_) && ReadDocumentKey (&key, &document_key_) &&
585
+ ReadBatchId (&key, &batch_id_) && ReadTerminator (&key);
584
586
}
585
587
586
588
std::string LevelDbMutationQueueKey::KeyPrefix () {
@@ -592,7 +594,7 @@ std::string LevelDbMutationQueueKey::KeyPrefix() {
592
594
std::string LevelDbMutationQueueKey::Key (absl::string_view user_id) {
593
595
std::string result;
594
596
WriteTableName (&result, kMutationQueuesTable );
595
- WriteUserID (&result, user_id);
597
+ WriteUserId (&result, user_id);
596
598
WriteTerminator (&result);
597
599
return result;
598
600
}
@@ -601,7 +603,7 @@ bool LevelDbMutationQueueKey::Decode(leveldb::Slice key) {
601
603
user_id_.clear ();
602
604
603
605
return ReadTableNameMatching (&key, kMutationQueuesTable ) &&
604
- ReadUserID (&key, &user_id_) && ReadTerminator (&key);
606
+ ReadUserId (&key, &user_id_) && ReadTerminator (&key);
605
607
}
606
608
607
609
std::string LevelDbTargetGlobalKey::Key () {
@@ -625,14 +627,15 @@ std::string LevelDbTargetKey::KeyPrefix() {
625
627
std::string LevelDbTargetKey::Key (model::TargetId target_id) {
626
628
std::string result;
627
629
WriteTableName (&result, kTargetsTable );
628
- WriteTargetID (&result, target_id);
630
+ WriteTargetId (&result, target_id);
629
631
WriteTerminator (&result);
630
632
return result;
631
633
}
632
634
633
635
bool LevelDbTargetKey::Decode (leveldb::Slice key) {
636
+ target_id_ = 0 ;
634
637
return ReadTableNameMatching (&key, kTargetsTable ) &&
635
- ReadTargetID (&key, &target_id_) && ReadTerminator (&key);
638
+ ReadTargetId (&key, &target_id_) && ReadTerminator (&key);
636
639
}
637
640
638
641
std::string LevelDbQueryTargetKey::KeyPrefix () {
@@ -644,26 +647,27 @@ std::string LevelDbQueryTargetKey::KeyPrefix() {
644
647
std::string LevelDbQueryTargetKey::KeyPrefix (absl::string_view canonical_id) {
645
648
std::string result;
646
649
WriteTableName (&result, kQueryTargetsTable );
647
- WriteCanonicalID (&result, canonical_id);
650
+ WriteCanonicalId (&result, canonical_id);
648
651
return result;
649
652
}
650
653
651
654
std::string LevelDbQueryTargetKey::Key (absl::string_view canonical_id,
652
655
model::TargetId target_id) {
653
656
std::string result;
654
657
WriteTableName (&result, kQueryTargetsTable );
655
- WriteCanonicalID (&result, canonical_id);
656
- WriteTargetID (&result, target_id);
658
+ WriteCanonicalId (&result, canonical_id);
659
+ WriteTargetId (&result, target_id);
657
660
WriteTerminator (&result);
658
661
return result;
659
662
}
660
663
661
664
bool LevelDbQueryTargetKey::Decode (leveldb::Slice key) {
662
665
canonical_id_.clear ();
666
+ target_id_ = 0 ;
663
667
664
668
return ReadTableNameMatching (&key, kQueryTargetsTable ) &&
665
- ReadCanonicalID (&key, &canonical_id_) &&
666
- ReadTargetID (&key, &target_id_) && ReadTerminator (&key);
669
+ ReadCanonicalId (&key, &canonical_id_) &&
670
+ ReadTargetId (&key, &target_id_) && ReadTerminator (&key);
667
671
}
668
672
669
673
std::string LevelDbTargetDocumentKey::KeyPrefix () {
@@ -675,25 +679,26 @@ std::string LevelDbTargetDocumentKey::KeyPrefix() {
675
679
std::string LevelDbTargetDocumentKey::KeyPrefix (model::TargetId target_id) {
676
680
std::string result;
677
681
WriteTableName (&result, kTargetDocumentsTable );
678
- WriteTargetID (&result, target_id);
682
+ WriteTargetId (&result, target_id);
679
683
return result;
680
684
}
681
685
682
686
std::string LevelDbTargetDocumentKey::Key (model::TargetId target_id,
683
687
const DocumentKey &document_key) {
684
688
std::string result;
685
689
WriteTableName (&result, kTargetDocumentsTable );
686
- WriteTargetID (&result, target_id);
690
+ WriteTargetId (&result, target_id);
687
691
WriteResourcePath (&result, document_key.path ());
688
692
WriteTerminator (&result);
689
693
return result;
690
694
}
691
695
692
696
bool LevelDbTargetDocumentKey::Decode (leveldb::Slice key) {
697
+ target_id_ = 0 ;
693
698
document_key_ = DocumentKey{};
694
699
695
700
return ReadTableNameMatching (&key, kTargetDocumentsTable ) &&
696
- ReadTargetID (&key, &target_id_) &&
701
+ ReadTargetId (&key, &target_id_) &&
697
702
ReadDocumentKey (&key, &document_key_) && ReadTerminator (&key);
698
703
}
699
704
@@ -716,17 +721,18 @@ std::string LevelDbDocumentTargetKey::Key(const DocumentKey &document_key,
716
721
std::string result;
717
722
WriteTableName (&result, kDocumentTargetsTable );
718
723
WriteResourcePath (&result, document_key.path ());
719
- WriteTargetID (&result, target_id);
724
+ WriteTargetId (&result, target_id);
720
725
WriteTerminator (&result);
721
726
return result;
722
727
}
723
728
724
729
bool LevelDbDocumentTargetKey::Decode (leveldb::Slice key) {
725
730
document_key_ = DocumentKey{};
731
+ target_id_ = 0 ;
726
732
727
733
return ReadTableNameMatching (&key, kDocumentTargetsTable ) &&
728
734
ReadDocumentKey (&key, &document_key_) &&
729
- ReadTargetID (&key, &target_id_) && ReadTerminator (&key);
735
+ ReadTargetId (&key, &target_id_) && ReadTerminator (&key);
730
736
}
731
737
732
738
std::string LevelDbRemoteDocumentKey::KeyPrefix () {
0 commit comments