Skip to content

Commit 51e17ac

Browse files
authored
Rename QueryData|Cache to TargetData|Cache (#4670)
* Rename done by CLion QueryCache -> TargetCache QueryData -> TargetData * Fix cmake list indention * Fixing ordering.
1 parent e3b4289 commit 51e17ac

File tree

67 files changed

+889
-875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+889
-875
lines changed

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 46 additions & 46 deletions
Large diffs are not rendered by default.

Firestore/Example/Tests/Integration/FSTDatastoreTests.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
3232
#include "Firestore/core/src/firebase/firestore/local/local_store.h"
3333
#include "Firestore/core/src/firebase/firestore/local/memory_persistence.h"
34-
#include "Firestore/core/src/firebase/firestore/local/query_data.h"
3534
#include "Firestore/core/src/firebase/firestore/local/simple_query_engine.h"
35+
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
3636
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
3737
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
3838
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
@@ -57,8 +57,8 @@
5757
using firebase::firestore::local::LocalStore;
5858
using firebase::firestore::local::MemoryPersistence;
5959
using firebase::firestore::local::Persistence;
60-
using firebase::firestore::local::QueryData;
6160
using firebase::firestore::local::SimpleQueryEngine;
61+
using firebase::firestore::local::TargetData;
6262
using firebase::firestore::model::BatchId;
6363
using firebase::firestore::model::DatabaseId;
6464
using firebase::firestore::model::DocumentKey;

Firestore/Example/Tests/SpecTests/FSTMockDatastore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class MockDatastore : public Datastore {
7171
void FailWatchStream(const util::Status& error);
7272

7373
/** Returns the set of active targets on the watch stream. */
74-
const std::unordered_map<model::TargetId, local::QueryData>& ActiveTargets() const;
74+
const std::unordered_map<model::TargetId, local::TargetData>& ActiveTargets() const;
7575
/** Helper method to expose watch stream state to verify in tests. */
7676
bool IsWatchStreamOpen() const;
7777

Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
2525
#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
2626
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
27-
#include "Firestore/core/src/firebase/firestore/local/query_data.h"
27+
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
2828
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
2929
#include "Firestore/core/src/firebase/firestore/model/mutation.h"
3030
#include "Firestore/core/src/firebase/firestore/remote/connectivity_monitor.h"
@@ -44,7 +44,7 @@
4444
using firebase::firestore::auth::CredentialsProvider;
4545
using firebase::firestore::auth::EmptyCredentialsProvider;
4646
using firebase::firestore::core::DatabaseInfo;
47-
using firebase::firestore::local::QueryData;
47+
using firebase::firestore::local::TargetData;
4848
using firebase::firestore::model::DatabaseId;
4949
using firebase::firestore::model::Mutation;
5050
using firebase::firestore::model::MutationResult;
@@ -78,7 +78,7 @@
7878
callback_{callback} {
7979
}
8080

81-
const std::unordered_map<TargetId, QueryData>& ActiveTargets() const {
81+
const std::unordered_map<TargetId, TargetData>& ActiveTargets() const {
8282
return active_targets_;
8383
}
8484

@@ -101,14 +101,15 @@ bool IsOpen() const override {
101101
return open_;
102102
}
103103

104-
void WatchQuery(const QueryData& query) override {
104+
void WatchQuery(const TargetData& query) override {
105105
LOG_DEBUG("WatchQuery: %s: %s, %s", query.target_id(), query.target().ToString(),
106106
query.resume_token().ToString());
107107

108108
// Snapshot version is ignored on the wire
109-
QueryData sentQueryData = query.WithResumeToken(query.resume_token(), SnapshotVersion::None());
109+
TargetData sentTargetData =
110+
query.WithResumeToken(query.resume_token(), SnapshotVersion::None());
110111
datastore_->IncrementWatchStreamRequests();
111-
active_targets_[query.target_id()] = sentQueryData;
112+
active_targets_[query.target_id()] = sentTargetData;
112113
}
113114

114115
void UnwatchTargetId(model::TargetId target_id) override {
@@ -150,7 +151,7 @@ void WriteWatchChange(const WatchChange& change, SnapshotVersion snap) {
150151

151152
private:
152153
bool open_ = false;
153-
std::unordered_map<TargetId, QueryData> active_targets_;
154+
std::unordered_map<TargetId, TargetData> active_targets_;
154155
MockDatastore* datastore_ = nullptr;
155156
WatchStreamCallback* callback_ = nullptr;
156157
};
@@ -273,7 +274,7 @@ int sent_mutations_count() const {
273274
watch_stream_->FailStream(error);
274275
}
275276

276-
const std::unordered_map<TargetId, QueryData>& MockDatastore::ActiveTargets() const {
277+
const std::unordered_map<TargetId, TargetData>& MockDatastore::ActiveTargets() const {
277278
return watch_stream_->ActiveTargets();
278279
}
279280

Firestore/Example/Tests/SpecTests/FSTSpecTests.mm

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "Firestore/core/include/firebase/firestore/firestore_errors.h"
3434
#include "Firestore/core/src/firebase/firestore/auth/user.h"
3535
#include "Firestore/core/src/firebase/firestore/local/persistence.h"
36-
#include "Firestore/core/src/firebase/firestore/local/query_data.h"
36+
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
3737
#include "Firestore/core/src/firebase/firestore/model/document.h"
3838
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
3939
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
@@ -67,7 +67,7 @@
6767
using firebase::firestore::core::DocumentViewChange;
6868
using firebase::firestore::core::Query;
6969
using firebase::firestore::local::Persistence;
70-
using firebase::firestore::local::QueryData;
70+
using firebase::firestore::local::TargetData;
7171
using firebase::firestore::local::QueryPurpose;
7272
using firebase::firestore::model::Document;
7373
using firebase::firestore::model::DocumentKey;
@@ -665,15 +665,15 @@ - (void)validateExpectedState:(nullable NSDictionary *)expectedState {
665665
TargetId targetID = [targetIDString intValue];
666666
ByteString resumeToken = MakeResumeToken(queryData[@"resumeToken"]);
667667
NSArray *queriesJson = queryData[@"queries"];
668-
std::vector<QueryData> queries;
668+
std::vector<TargetData> queries;
669669
for (id queryJson in queriesJson) {
670670
Query query = [self parseQuery:queryJson];
671671
// TODO(mcg): populate the purpose of the target once it's possible to encode that in
672672
// the spec tests. For now, hard-code that it's a listen despite the fact that it's
673673
// not always the right value.
674-
queries.push_back(QueryData(query.ToTarget(), targetID, 0, QueryPurpose::Listen,
675-
SnapshotVersion::None(), SnapshotVersion::None(),
676-
std::move(resumeToken)));
674+
queries.push_back(TargetData(query.ToTarget(), targetID, 0, QueryPurpose::Listen,
675+
SnapshotVersion::None(), SnapshotVersion::None(),
676+
std::move(resumeToken)));
677677
}
678678
expectedActiveTargets[targetID] = std::make_pair(std::move(queries), resumeToken);
679679
}];
@@ -736,26 +736,26 @@ - (void)validateActiveTargets {
736736
}
737737

738738
// Create a copy so we can modify it below
739-
std::unordered_map<TargetId, QueryData> actualTargets = [self.driver activeTargets];
739+
std::unordered_map<TargetId, TargetData> actualTargets = [self.driver activeTargets];
740740

741741
for (const auto &kv : [self.driver expectedActiveTargets]) {
742742
TargetId targetID = kv.first;
743-
const std::pair<std::vector<QueryData>, ByteString> &queries = kv.second;
744-
const QueryData &queryData = queries.first[0];
743+
const std::pair<std::vector<TargetData>, ByteString> &queries = kv.second;
744+
const TargetData &targetData = queries.first[0];
745745

746746
auto found = actualTargets.find(targetID);
747747
XCTAssertNotEqual(found, actualTargets.end(), @"Expected active target not found: %s",
748-
queryData.ToString().c_str());
748+
targetData.ToString().c_str());
749749

750750
// TODO(mcg): validate the purpose of the target once it's possible to encode that in the
751751
// spec tests. For now, only validate properties that can be validated.
752-
// XCTAssertEqualObjects(actualTargets[targetID], queryData);
752+
// XCTAssertEqualObjects(actualTargets[targetID], TargetData);
753753

754-
const QueryData &actual = found->second;
755-
XCTAssertEqual(actual.target(), queryData.target());
756-
XCTAssertEqual(actual.target_id(), queryData.target_id());
757-
XCTAssertEqual(actual.snapshot_version(), queryData.snapshot_version());
758-
XCTAssertEqual(actual.resume_token(), queryData.resume_token());
754+
const TargetData &actual = found->second;
755+
XCTAssertEqual(actual.target(), targetData.target());
756+
XCTAssertEqual(actual.target_id(), targetData.target_id());
757+
XCTAssertEqual(actual.snapshot_version(), targetData.snapshot_version());
758+
XCTAssertEqual(actual.resume_token(), targetData.resume_token());
759759

760760
actualTargets.erase(targetID);
761761
}

Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "Firestore/core/src/firebase/firestore/core/event_listener.h"
2727
#include "Firestore/core/src/firebase/firestore/core/query.h"
2828
#include "Firestore/core/src/firebase/firestore/core/view_snapshot.h"
29-
#include "Firestore/core/src/firebase/firestore/local/query_data.h"
29+
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
3030
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
3131
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
3232
#include "Firestore/core/src/firebase/firestore/model/mutation.h"
@@ -54,11 +54,11 @@ namespace model = firebase::firestore::model;
5454
namespace nanopb = firebase::firestore::nanopb;
5555

5656
// A map holds expected information about currently active targets. The keys are
57-
// target ID, and the values are a vector of `QueryData`s mapped to the target and
57+
// target ID, and the values are a vector of `TargetData`s mapped to the target and
5858
// the target's resume token.
5959
using ActiveTargetMap =
6060
std::unordered_map<model::TargetId,
61-
std::pair<std::vector<local::QueryData>, nanopb::ByteString>>;
61+
std::pair<std::vector<local::TargetData>, nanopb::ByteString>>;
6262

6363
NS_ASSUME_NONNULL_BEGIN
6464

@@ -345,7 +345,8 @@ typedef std::unordered_map<firebase::firestore::auth::User,
345345
- (void)removeSnapshotsInSyncListener;
346346

347347
/** The set of active targets as observed on the watch stream. */
348-
- (const std::unordered_map<firebase::firestore::model::TargetId, local::QueryData> &)activeTargets;
348+
- (const std::unordered_map<firebase::firestore::model::TargetId, local::TargetData> &)
349+
activeTargets;
349350

350351
/** The expected set of active targets, keyed by target ID. */
351352
- (const ActiveTargetMap &)expectedActiveTargets;

Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
using firebase::firestore::local::IndexFreeQueryEngine;
7070
using firebase::firestore::local::LocalStore;
7171
using firebase::firestore::local::Persistence;
72-
using firebase::firestore::local::QueryData;
72+
using firebase::firestore::local::TargetData;
7373
using firebase::firestore::model::DatabaseId;
7474
using firebase::firestore::model::DocumentKey;
7575
using firebase::firestore::model::DocumentKeySet;
@@ -165,7 +165,7 @@ @implementation FSTSyncEngineTestDriver {
165165
DelayedConstructor<EventManager> _eventManager;
166166

167167
// Set of active targets, keyed by target Id, mapped to corresponding resume token,
168-
// and list of `QueryData`.
168+
// and list of `TargetData`.
169169
ActiveTargetMap _expectedActiveTargets;
170170

171171
// ivar is declared as mutable.
@@ -474,7 +474,7 @@ - (void)receiveWatchStreamError:(int)errorCode userInfo:(NSDictionary<NSString *
474474
return _syncEngine->GetCurrentLimboDocuments();
475475
}
476476

477-
- (const std::unordered_map<TargetId, QueryData> &)activeTargets {
477+
- (const std::unordered_map<TargetId, TargetData> &)activeTargets {
478478
return _datastore->ActiveTargets();
479479
}
480480

Firestore/core/src/firebase/firestore/core/sync_engine.cc

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "Firestore/core/include/firebase/firestore/firestore_errors.h"
2020
#include "Firestore/core/src/firebase/firestore/core/transaction.h"
2121
#include "Firestore/core/src/firebase/firestore/core/transaction_runner.h"
22-
#include "Firestore/core/src/firebase/firestore/local/query_data.h"
2322
#include "Firestore/core/src/firebase/firestore/local/query_result.h"
23+
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
2424
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
2525
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
2626
#include "Firestore/core/src/firebase/firestore/model/document_map.h"
@@ -41,9 +41,9 @@ using firestore::Error;
4141
using local::LocalStore;
4242
using local::LocalViewChanges;
4343
using local::LocalWriteResult;
44-
using local::QueryData;
4544
using local::QueryPurpose;
4645
using local::QueryResult;
46+
using local::TargetData;
4747
using model::BatchId;
4848
using model::DocumentKey;
4949
using model::DocumentKeySet;
@@ -94,17 +94,17 @@ TargetId SyncEngine::Listen(Query query) {
9494
HARD_ASSERT(query_views_by_query_.find(query) == query_views_by_query_.end(),
9595
"We already listen to query: %s", query.ToString());
9696

97-
QueryData query_data = local_store_->AllocateTarget(query.ToTarget());
97+
TargetData target_data = local_store_->AllocateTarget(query.ToTarget());
9898
ViewSnapshot view_snapshot =
99-
InitializeViewAndComputeSnapshot(query, query_data.target_id());
99+
InitializeViewAndComputeSnapshot(query, target_data.target_id());
100100
std::vector<ViewSnapshot> snapshots;
101101
// Not using the `std::initializer_list` constructor to avoid extra copies.
102102
snapshots.push_back(std::move(view_snapshot));
103103
sync_engine_callback_->OnViewSnapshots(std::move(snapshots));
104104

105-
// TODO(wuandy): move `query_data` into `Listen`.
106-
remote_store_->Listen(query_data);
107-
return query_data.target_id();
105+
// TODO(wuandy): move `target_data` into `Listen`.
106+
remote_store_->Listen(target_data);
107+
return target_data.target_id();
108108
}
109109

110110
ViewSnapshot SyncEngine::InitializeViewAndComputeSnapshot(const Query& query,
@@ -528,12 +528,11 @@ void SyncEngine::TrackLimboChange(const LimboDocumentChange& limbo_change) {
528528

529529
TargetId limbo_target_id = target_id_generator_.NextId();
530530
Query query(key.path());
531-
QueryData query_data(query.ToTarget(), limbo_target_id,
532-
kIrrelevantSequenceNumber,
533-
QueryPurpose::LimboResolution);
531+
TargetData target_data(query.ToTarget(), limbo_target_id,
532+
kIrrelevantSequenceNumber,
533+
QueryPurpose::LimboResolution);
534534
limbo_resolutions_by_target_.emplace(limbo_target_id, LimboResolution{key});
535-
// TODO(wuandy): move `query_data` into `Listen`.
536-
remote_store_->Listen(query_data);
535+
remote_store_->Listen(target_data);
537536
limbo_targets_by_key_[key] = limbo_target_id;
538537
}
539538
}

Firestore/core/src/firebase/firestore/core/sync_engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include "Firestore/core/src/firebase/firestore/core/view.h"
3030
#include "Firestore/core/src/firebase/firestore/core/view_snapshot.h"
3131
#include "Firestore/core/src/firebase/firestore/local/local_store.h"
32-
#include "Firestore/core/src/firebase/firestore/local/query_data.h"
3332
#include "Firestore/core/src/firebase/firestore/local/reference_set.h"
33+
#include "Firestore/core/src/firebase/firestore/local/target_data.h"
3434
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
3535
#include "Firestore/core/src/firebase/firestore/model/maybe_document.h"
3636
#include "Firestore/core/src/firebase/firestore/remote/remote_store.h"

Firestore/core/src/firebase/firestore/core/target_id_generator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace firestore {
2424
namespace core {
2525

2626
/** The set of all valid generators. */
27-
enum class TargetIdGeneratorId { QueryCache = 0, SyncEngine = 1 };
27+
enum class TargetIdGeneratorId { TargetCache = 0, SyncEngine = 1 };
2828

2929
/**
3030
* Generates monotonically increasing target IDs for sending targets to the
@@ -57,8 +57,8 @@ class TargetIdGenerator {
5757
* @param after An ID to start at. Every call to NextId returns a larger id.
5858
* @return An instance of TargetIdGenerator.
5959
*/
60-
static TargetIdGenerator QueryCacheTargetIdGenerator(model::TargetId after) {
61-
TargetIdGenerator generator(TargetIdGeneratorId::QueryCache, after);
60+
static TargetIdGenerator TargetCacheTargetIdGenerator(model::TargetId after) {
61+
TargetIdGenerator generator(TargetIdGeneratorId::TargetCache, after);
6262
// Make sure that the next call to `NextId()` returns the first value after
6363
// 'after'.
6464
generator.NextId();

Firestore/core/src/firebase/firestore/local/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ cc_library(
2424
lru_garbage_collector.h
2525
memory_index_manager.cc
2626
memory_index_manager.h
27-
query_data.cc
28-
query_data.h
2927
reference_set.cc
3028
reference_set.h
29+
target_data.cc
30+
target_data.h
3131
DEPENDS
3232
absl_strings
3333
firebase_firestore_core_query
@@ -53,10 +53,10 @@ cc_library(
5353
leveldb_mutation_queue.h
5454
leveldb_persistence.cc
5555
leveldb_persistence.h
56-
leveldb_query_cache.cc
57-
leveldb_query_cache.h
5856
leveldb_remote_document_cache.cc
5957
leveldb_remote_document_cache.h
58+
leveldb_target_cache.cc
59+
leveldb_target_cache.h
6060
leveldb_transaction.cc
6161
leveldb_transaction.h
6262
leveldb_util.cc
@@ -98,22 +98,22 @@ cc_library(
9898
memory_mutation_queue.h
9999
memory_persistence.cc
100100
memory_persistence.h
101-
memory_query_cache.cc
102-
memory_query_cache.h
103101
memory_remote_document_cache.cc
104102
memory_remote_document_cache.h
103+
memory_target_cache.cc
104+
memory_target_cache.h
105105
mutation_queue.h
106106
persistence.h
107107
proto_sizer.cc
108108
proto_sizer.h
109-
query_cache.h
110109
query_engine.h
111110
query_result.h
112111
reference_delegate.h
113112
remote_document_cache.h
114113
simple_query_engine.cc
115114
simple_query_engine.h
116115
sizer.h
116+
target_cache.h
117117
DEPENDS
118118
absl_strings
119119
firebase_firestore_auth

Firestore/core/src/firebase/firestore/local/index_free_query_engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace local {
3636

3737
/**
3838
* A query engine that takes advantage of the target document mapping in the
39-
* QueryCache. The IndexFreeQueryEngine optimizes query execution by only
39+
* TargetCache. The IndexFreeQueryEngine optimizes query execution by only
4040
* reading the documents that previously matched a query plus any documents that
4141
* were edited after the query was last listened to.
4242
*

0 commit comments

Comments
 (0)