Skip to content

Commit 254a394

Browse files
committed
Add comments.
1 parent 2289364 commit 254a394

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

Firestore/core/src/local/leveldb_key.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,15 +730,34 @@ class LevelDbNamedQueryKey {
730730
std::string name_;
731731
};
732732

733+
/**
734+
* A key in the index_configuration table, storing the index definition proto,
735+
* and the collection (group) it applies to.
736+
*/
733737
class LevelDbIndexConfigurationKey {
734738
public:
739+
/**
740+
* Creates a key prefix that points just before the first key of the table.
741+
*/
735742
static std::string KeyPrefix();
736743

744+
/**
745+
* Creates a key that points to the key for the given index id.
746+
*/
737747
static std::string Key(int32_t id);
738748

749+
/**
750+
* Decodes the given complete key, storing the decoded values in this
751+
* instance.
752+
*
753+
* @return true if the key successfully decoded, false otherwise. If false is
754+
* returned, this instance is in an undefined state until the next call to
755+
* `Decode()`.
756+
*/
739757
ABSL_MUST_USE_RESULT
740758
bool Decode(absl::string_view key);
741759

760+
/** The index id for this entry. */
742761
int32_t index_id() const {
743762
return index_id_;
744763
}
@@ -747,19 +766,39 @@ class LevelDbIndexConfigurationKey {
747766
int32_t index_id_;
748767
};
749768

769+
/**
770+
* A key in the index_state table, storing the per index per user state tracking
771+
* backfilling state for each index.
772+
*/
750773
class LevelDbIndexStateKey {
751774
public:
775+
/**
776+
* Creates a key prefix that points just before the first key of the table.
777+
*/
752778
static std::string KeyPrefix();
753779

780+
/**
781+
* Creates a key that points to the key for the given index id and user id.
782+
*/
754783
static std::string Key(int32_t index_id, absl::string_view user_id);
755784

785+
/**
786+
* Decodes the given complete key, storing the decoded values in this
787+
* instance.
788+
*
789+
* @return true if the key successfully decoded, false otherwise. If false is
790+
* returned, this instance is in an undefined state until the next call to
791+
* `Decode()`.
792+
*/
756793
ABSL_MUST_USE_RESULT
757794
bool Decode(absl::string_view key);
758795

796+
/** The index id for this entry. */
759797
int32_t index_id() const {
760798
return index_id_;
761799
}
762800

801+
/** The user id for this entry. */
763802
const std::string& user_id() const {
764803
return user_id_;
765804
}
@@ -769,34 +808,60 @@ class LevelDbIndexStateKey {
769808
std::string user_id_;
770809
};
771810

811+
/**
812+
* A key in the index_entries table, storing the the encoded entries for all
813+
* fields used by a given index.
814+
*
815+
* Note: `array_value` is expected to be set for all queries.
816+
*/
772817
class LevelDbIndexEntryKey {
773818
public:
819+
/**
820+
* Creates a key prefix that points just before the first key of the table.
821+
*/
774822
static std::string KeyPrefix();
775823

824+
/**
825+
* Creates a key that points to the key for the given index entry fields.
826+
*/
776827
static std::string Key(int32_t index_id,
777828
absl::string_view user_id,
778829
absl::string_view array_value,
779830
absl::string_view directional_value,
780831
absl::string_view document_name);
781832

833+
/**
834+
* Decodes the given complete key, storing the decoded values in this
835+
* instance.
836+
*
837+
* @return true if the key successfully decoded, false otherwise. If false is
838+
* returned, this instance is in an undefined state until the next call to
839+
* `Decode()`.
840+
*/
782841
ABSL_MUST_USE_RESULT
783842
bool Decode(absl::string_view key);
784843

844+
/** The index id for this entry. */
785845
int32_t index_id() const {
786846
return index_id_;
787847
}
788848

849+
/** The user id for this entry. */
789850
const std::string& user_id() const {
790851
return user_id_;
791852
}
792853

854+
/** The array index value encoded for this entry. */
793855
const std::string& array_value() const {
794856
return array_value_;
795857
}
796858

859+
/** The directional index value encoded for this entry. */
797860
const std::string& directional_value() const {
798861
return directional_value_;
799862
}
863+
864+
/** The document name this entry points to. */
800865
const std::string& document_name() const {
801866
return document_name_;
802867
}

0 commit comments

Comments
 (0)