diff --git a/firestore/CMakeLists.txt b/firestore/CMakeLists.txt index b0a3b222c5..919d902ce4 100644 --- a/firestore/CMakeLists.txt +++ b/firestore/CMakeLists.txt @@ -67,6 +67,12 @@ binary_to_array("firestore_resources" set(android_SRCS ${firestore_resources_source} + src/android/aggregate_query_android.cc + src/android/aggregate_query_android.h + src/android/aggregate_query_snapshot_android.cc + src/android/aggregate_query_snapshot_android.h + src/android/aggregate_source_android.cc + src/android/aggregate_source_android.h src/android/blob_android.cc src/android/blob_android.h src/android/collection_reference_android.cc diff --git a/firestore/integration_test_internal/src/aggregate_query_snapshot_test.cc b/firestore/integration_test_internal/src/aggregate_query_snapshot_test.cc index 101811ef46..2e73d9cc49 100644 --- a/firestore/integration_test_internal/src/aggregate_query_snapshot_test.cc +++ b/firestore/integration_test_internal/src/aggregate_query_snapshot_test.cc @@ -14,13 +14,17 @@ * limitations under the License. */ -#include "firebase/firestore.h" #include "firestore_integration_test.h" +#include "firebase/firestore.h" + #include "gtest/gtest.h" #if defined(__ANDROID__) +#include "firestore/src/android/aggregate_query_android.h" +#include "firestore/src/android/aggregate_query_snapshot_android.h" #include "firestore/src/android/converter_android.h" +#include "firestore/src/jni/object.h" #else #include "firestore/src/main/aggregate_query_snapshot_main.h" #include "firestore/src/main/converter_main.h" @@ -32,14 +36,27 @@ namespace firestore { class AggregateQuerySnapshotTest : public FirestoreIntegrationTest { protected: static AggregateQuerySnapshot TestAggregateQuerySnapshot( - AggregateQuery aggregate_query, const int count) { - api::AggregateQuery aggregateQuery = - GetInternal(&aggregate_query)->aggregate_query_; - return MakePublic( - AggregateQuerySnapshotInternal(std::move(aggregateQuery), count)); - } + AggregateQuery aggregate_query, const int count); }; +#if defined(__ANDROID__) +AggregateQuerySnapshot AggregateQuerySnapshotTest::TestAggregateQuerySnapshot( + firebase::firestore::AggregateQuery aggregate_query, const int count) { + AggregateQueryInternal* internal = GetInternal(&aggregate_query); + FirestoreInternal* firestoreInternal = internal->firestore_internal(); + jni::Env env = firestoreInternal->GetEnv(); + return AggregateQuerySnapshotInternal::Create(env, *internal, count); +} +#else +AggregateQuerySnapshot AggregateQuerySnapshotTest::TestAggregateQuerySnapshot( + firebase::firestore::AggregateQuery aggregate_query, const int count) { + api::AggregateQuery aggregateQuery = + GetInternal(&aggregate_query)->aggregate_query_; + return MakePublic( + AggregateQuerySnapshotInternal(std::move(aggregateQuery), count)); +} +#endif // defined(__ANDROID__) + std::size_t AggregateQuerySnapshotHash(const AggregateQuerySnapshot& snapshot) { return snapshot.Hash(); } @@ -135,7 +152,7 @@ TEST_F( EXPECT_EQ(snapshot_copy_dest.query(), AggregateQuery()); EXPECT_FALSE(snapshot_copy_dest.is_valid()); - snapshot_copy_dest; + snapshot_copy_dest = snapshot; EXPECT_EQ(snapshot_copy_dest.count(), 0); EXPECT_EQ(snapshot_copy_dest.query(), AggregateQuery()); diff --git a/firestore/integration_test_internal/src/aggregate_query_test.cc b/firestore/integration_test_internal/src/aggregate_query_test.cc index 7320be516f..11d2c3c573 100644 --- a/firestore/integration_test_internal/src/aggregate_query_test.cc +++ b/firestore/integration_test_internal/src/aggregate_query_test.cc @@ -104,7 +104,7 @@ TEST_F( EXPECT_EQ(copied_aggregate_query.query(), Query()); EXPECT_FALSE(copied_aggregate_query.is_valid()); - copied_aggregate_query; + copied_aggregate_query = aggregate_query; EXPECT_EQ(aggregate_query.query(), Query()); EXPECT_FALSE(aggregate_query.is_valid()); diff --git a/firestore/src/android/aggregate_query_android.cc b/firestore/src/android/aggregate_query_android.cc new file mode 100644 index 0000000000..d9d6da0144 --- /dev/null +++ b/firestore/src/android/aggregate_query_android.cc @@ -0,0 +1,75 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "firestore/src/android/aggregate_query_android.h" + +#include "firestore/src/android/aggregate_source_android.h" +#include "firestore/src/jni/compare.h" +#include "firestore/src/jni/env.h" +#include "firestore/src/jni/loader.h" +#include "firestore/src/jni/task.h" + +namespace firebase { +namespace firestore { +namespace { + +using jni::Env; +using jni::Local; +using jni::Method; +using jni::Object; +using jni::Task; + +constexpr char kClassName[] = + PROGUARD_KEEP_CLASS "com/google/firebase/firestore/AggregateQuery"; +Method kGet("get", + "(Lcom/google/firebase/firestore/AggregateSource;)" + "Lcom/google/android/gms/tasks/Task;"); +Method kGetQuery("getQuery", "()Lcom/google/firebase/firestore/Query;"); +Method kHashCode("hashCode", "()I"); + +} // namespace + +void AggregateQueryInternal::Initialize(jni::Loader& loader) { + loader.LoadClass(kClassName, kGet, kGetQuery, kHashCode); +} + +Query AggregateQueryInternal::query() const { + Env env = GetEnv(); + Local query = env.Call(obj_, kGetQuery); + return firestore_->NewQuery(env, query); +} + +Future AggregateQueryInternal::Get( + AggregateSource aggregate_source) { + Env env = GetEnv(); + Local java_source = + AggregateSourceInternal::Create(env, aggregate_source); + Local task = env.Call(obj_, kGet, java_source); + return promises_.NewFuture(env, AsyncFn::kGet, task); +} + +std::size_t AggregateQueryInternal::Hash() const { + Env env = GetEnv(); + return env.Call(obj_, kHashCode); +} + +bool operator==(const AggregateQueryInternal& lhs, + const AggregateQueryInternal& rhs) { + return jni::EqualityCompareJni(lhs, rhs); +} + +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/android/aggregate_query_android.h b/firestore/src/android/aggregate_query_android.h new file mode 100644 index 0000000000..7545d62f72 --- /dev/null +++ b/firestore/src/android/aggregate_query_android.h @@ -0,0 +1,78 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_QUERY_ANDROID_H_ +#define FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_QUERY_ANDROID_H_ + +#include "firestore/src/android/promise_factory_android.h" +#include "firestore/src/android/query_android.h" +#include "firestore/src/android/wrapper.h" +#include "firestore/src/include/firebase/firestore/aggregate_source.h" + +namespace firebase { +namespace firestore { + +class AggregateQueryInternal : public Wrapper { + public: + // Each API of AggregateQuery that returns a Future needs to define an enum + // value here. For example, a Future-returning method Foo() relies on the enum + // value kFoo. The enum values are used to identify and manage Future in the + // Firestore Future manager. + enum class AsyncFn { + kGet = 0, + kCount, // Must be the last enum value. + }; + + static void Initialize(jni::Loader& loader); + + AggregateQueryInternal(FirestoreInternal* firestore, + const jni::Object& object) + : Wrapper(firestore, object), promises_(firestore) {} + + /** + * @brief Returns the query whose aggregations will be calculated by this + * object. + */ + Query query() const; + + /** + * @brief Executes the aggregate query and returns the results as a + * AggregateQuerySnapshot. + * + * @param[in] aggregate_source A value to configure the get behavior. + * + * @return A Future that will be resolved with the results of the + * AggregateQuery. + */ + Future Get(AggregateSource aggregate_source); + + size_t Hash() const; + + private: + PromiseFactory promises_; +}; + +bool operator==(const AggregateQueryInternal& lhs, + const AggregateQueryInternal& rhs); +inline bool operator!=(const AggregateQueryInternal& lhs, + const AggregateQueryInternal& rhs) { + return !(lhs == rhs); +} + +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_QUERY_ANDROID_H_ diff --git a/firestore/src/android/aggregate_query_snapshot_android.cc b/firestore/src/android/aggregate_query_snapshot_android.cc new file mode 100644 index 0000000000..8dbf1ab22a --- /dev/null +++ b/firestore/src/android/aggregate_query_snapshot_android.cc @@ -0,0 +1,79 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "firestore/src/android/aggregate_query_snapshot_android.h" + +#include "firestore/src/android/aggregate_query_android.h" +#include "firestore/src/jni/compare.h" +#include "firestore/src/jni/env.h" +#include "firestore/src/jni/loader.h" + +namespace firebase { +namespace firestore { +namespace { + +using jni::Constructor; +using jni::Env; +using jni::Local; +using jni::Method; +using jni::Object; + +constexpr char kClassName[] = + PROGUARD_KEEP_CLASS "com/google/firebase/firestore/AggregateQuerySnapshot"; +Constructor kConstructor( + "(Lcom/google/firebase/firestore/AggregateQuery;J)V"); +Method kGetCount("getCount", "()J"); +Method kGetQuery("getQuery", + "()Lcom/google/firebase/firestore/AggregateQuery;"); +Method kHashCode("hashCode", "()I"); + +} // namespace + +void AggregateQuerySnapshotInternal::Initialize(jni::Loader& loader) { + loader.LoadClass(kClassName, kConstructor, kGetCount, kGetQuery, kHashCode); +} + +AggregateQuerySnapshot AggregateQuerySnapshotInternal::Create( + Env& env, AggregateQueryInternal& aggregate_query_internal, int64_t count) { + const Object& arg = aggregate_query_internal.ToJava(); + Local instance = env.New(kConstructor, arg, count); + return aggregate_query_internal.firestore_internal() + ->NewAggregateQuerySnapshot(env, instance); +} + +AggregateQuery AggregateQuerySnapshotInternal::query() const { + Env env = GetEnv(); + Local query = env.Call(obj_, kGetQuery); + return firestore_->NewAggregateQuery(env, query); +} + +int64_t AggregateQuerySnapshotInternal::count() const { + Env env = GetEnv(); + return env.Call(obj_, kGetCount); +} + +std::size_t AggregateQuerySnapshotInternal::Hash() const { + Env env = GetEnv(); + return env.Call(obj_, kHashCode); +} + +bool operator==(const AggregateQuerySnapshotInternal& lhs, + const AggregateQuerySnapshotInternal& rhs) { + return jni::EqualityCompareJni(lhs, rhs); +} + +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/android/aggregate_query_snapshot_android.h b/firestore/src/android/aggregate_query_snapshot_android.h new file mode 100644 index 0000000000..6ebad41a3e --- /dev/null +++ b/firestore/src/android/aggregate_query_snapshot_android.h @@ -0,0 +1,58 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_QUERY_SNAPSHOT_ANDROID_H_ +#define FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_QUERY_SNAPSHOT_ANDROID_H_ + +#include "firestore/src/android/wrapper.h" +#include "firestore/src/include/firebase/firestore/aggregate_query.h" +#include "firestore/src/include/firebase/firestore/aggregate_query_snapshot.h" + +namespace firebase { +namespace firestore { + +class AggregateQuery; + +class AggregateQuerySnapshotInternal : public Wrapper { + public: + using Wrapper::Wrapper; + + static void Initialize(jni::Loader& loader); + + AggregateQuery query() const; + int64_t count() const; + + std::size_t Hash() const; + + private: + friend class AggregateQuerySnapshotTest; + static AggregateQuerySnapshot Create( + jni::Env& env, + AggregateQueryInternal& aggregate_query_internal, + int64_t count); +}; + +bool operator==(const AggregateQuerySnapshotInternal& lhs, + const AggregateQuerySnapshotInternal& rhs); +inline bool operator!=(const AggregateQuerySnapshotInternal& lhs, + const AggregateQuerySnapshotInternal& rhs) { + return !(lhs == rhs); +} + +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_QUERY_SNAPSHOT_ANDROID_H_ diff --git a/firestore/src/android/aggregate_source_android.cc b/firestore/src/android/aggregate_source_android.cc new file mode 100644 index 0000000000..c65e8d66ad --- /dev/null +++ b/firestore/src/android/aggregate_source_android.cc @@ -0,0 +1,51 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "firestore/src/android/aggregate_source_android.h" + +#include "firestore/src/jni/env.h" +#include "firestore/src/jni/loader.h" + +namespace firebase { +namespace firestore { +namespace { + +using jni::Env; +using jni::Local; +using jni::Object; +using jni::StaticField; + +constexpr char kClass[] = + PROGUARD_KEEP_CLASS "com/google/firebase/firestore/AggregateSource"; +StaticField kServer("SERVER", + "Lcom/google/firebase/firestore/AggregateSource;"); + +} // namespace + +void AggregateSourceInternal::Initialize(jni::Loader& loader) { + loader.LoadClass(kClass, kServer); +} + +Local AggregateSourceInternal::Create( + Env& env, AggregateSource aggregate_source) { + switch (aggregate_source) { + case AggregateSource::kServer: + return env.Get(kServer); + } +} + +} // namespace firestore +} // namespace firebase diff --git a/firestore/src/android/aggregate_source_android.h b/firestore/src/android/aggregate_source_android.h new file mode 100644 index 0000000000..9db5d35477 --- /dev/null +++ b/firestore/src/android/aggregate_source_android.h @@ -0,0 +1,36 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_SOURCE_ANDROID_H_ +#define FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_SOURCE_ANDROID_H_ + +#include "firestore/src/include/firebase/firestore/aggregate_source.h" +#include "firestore/src/jni/jni_fwd.h" + +namespace firebase { +namespace firestore { + +class AggregateSourceInternal { + public: + static void Initialize(jni::Loader& loader); + + static jni::Local Create(jni::Env& env, AggregateSource source); +}; + +} // namespace firestore +} // namespace firebase + +#endif // FIREBASE_FIRESTORE_SRC_ANDROID_AGGREGATE_SOURCE_ANDROID_H_ diff --git a/firestore/src/android/firestore_android.cc b/firestore/src/android/firestore_android.cc index 62917accd8..4b9926ce09 100644 --- a/firestore/src/android/firestore_android.cc +++ b/firestore/src/android/firestore_android.cc @@ -22,6 +22,9 @@ #include "app/src/include/firebase/future.h" #include "app/src/reference_counted_future_impl.h" #include "firestore/firestore_resources.h" +#include "firestore/src/android/aggregate_query_android.h" +#include "firestore/src/android/aggregate_query_snapshot_android.h" +#include "firestore/src/android/aggregate_source_android.h" #include "firestore/src/android/blob_android.h" #include "firestore/src/android/collection_reference_android.h" #include "firestore/src/android/converter_android.h" @@ -318,6 +321,9 @@ bool FirestoreInternal::Initialize(App* app) { InitializeFirestoreTasks(loader); InitializeUserCallbackExecutor(loader); + AggregateQueryInternal::Initialize(loader); + AggregateQuerySnapshotInternal::Initialize(loader); + AggregateSourceInternal::Initialize(loader); BlobInternal::Initialize(loader); CollectionReferenceInternal::Initialize(loader); DirectionInternal::Initialize(loader); @@ -620,6 +626,17 @@ Env FirestoreInternal::GetEnv() { return env; } +AggregateQuery FirestoreInternal::NewAggregateQuery( + Env& env, const jni::Object& aggregate_query) const { + return MakePublic(env, mutable_this(), aggregate_query); +} + +AggregateQuerySnapshot FirestoreInternal::NewAggregateQuerySnapshot( + Env& env, const jni::Object& aggregate_query_snapshot) const { + return MakePublic(env, mutable_this(), + aggregate_query_snapshot); +} + CollectionReference FirestoreInternal::NewCollectionReference( Env& env, const jni::Object& reference) const { return MakePublic(env, mutable_this(), reference); diff --git a/firestore/src/android/firestore_android.h b/firestore/src/android/firestore_android.h index 5c5367a8f5..d5079c7533 100644 --- a/firestore/src/android/firestore_android.h +++ b/firestore/src/android/firestore_android.h @@ -144,6 +144,12 @@ class FirestoreInternal { static jni::Env GetEnv(); + AggregateQuery NewAggregateQuery(jni::Env& env, + const jni::Object& aggregate_query) const; + + AggregateQuerySnapshot NewAggregateQuerySnapshot( + jni::Env& env, const jni::Object& aggregate_query_snapshot) const; + CollectionReference NewCollectionReference( jni::Env& env, const jni::Object& reference) const; DocumentReference NewDocumentReference(jni::Env& env, diff --git a/firestore/src/android/load_bundle_task_progress_android.cc b/firestore/src/android/load_bundle_task_progress_android.cc index 1593a4a022..00a0005249 100644 --- a/firestore/src/android/load_bundle_task_progress_android.cc +++ b/firestore/src/android/load_bundle_task_progress_android.cc @@ -25,7 +25,6 @@ namespace firestore { namespace { using jni::Class; -using jni::Constructor; using jni::Env; using jni::Local; using jni::Method; diff --git a/firestore/src/android/promise_android.h b/firestore/src/android/promise_android.h index 37df349945..b1f9c6ec5e 100644 --- a/firestore/src/android/promise_android.h +++ b/firestore/src/android/promise_android.h @@ -22,6 +22,7 @@ #include "app/src/reference_counted_future_impl.h" #include "app/src/util_android.h" +#include "firestore/src/android/aggregate_query_snapshot_android.h" #include "firestore/src/android/converter_android.h" #include "firestore/src/android/document_snapshot_android.h" #include "firestore/src/android/exception_android.h" diff --git a/firestore/src/android/query_android.cc b/firestore/src/android/query_android.cc index b28de7eb81..81fdd418e0 100644 --- a/firestore/src/android/query_android.cc +++ b/firestore/src/android/query_android.cc @@ -51,6 +51,8 @@ using jni::Task; constexpr char kClassName[] = PROGUARD_KEEP_CLASS "com/google/firebase/firestore/Query"; +Method kCount("count", + "()Lcom/google/firebase/firestore/AggregateQuery;"); Method kEqualTo( "whereEqualTo", "(Lcom/google/firebase/firestore/FieldPath;Ljava/lang/Object;)" @@ -136,7 +138,7 @@ Method kHashCode("hashCode", "()I"); void QueryInternal::Initialize(jni::Loader& loader) { loader.LoadClass( - kClassName, kEqualTo, kNotEqualTo, kLessThan, kLessThanOrEqualTo, + kClassName, kCount, kEqualTo, kNotEqualTo, kLessThan, kLessThanOrEqualTo, kGreaterThan, kGreaterThanOrEqualTo, kArrayContains, kArrayContainsAny, kIn, kNotIn, kOrderBy, kLimit, kLimitToLast, kStartAtSnapshot, kStartAt, kStartAfterSnapshot, kStartAfter, kEndBeforeSnapshot, kEndBefore, @@ -148,6 +150,12 @@ Firestore* QueryInternal::firestore() { return firestore_->firestore_public(); } +AggregateQuery QueryInternal::Count() const { + Env env = GetEnv(); + Local aggregate_query = env.Call(obj_, kCount); + return firestore_->NewAggregateQuery(env, aggregate_query); +} + Query QueryInternal::WhereEqualTo(const FieldPath& field, const FieldValue& value) const { return Where(field, kEqualTo, value); diff --git a/firestore/src/android/query_android.h b/firestore/src/android/query_android.h index 34b7ad4bee..abb3dea8e3 100644 --- a/firestore/src/android/query_android.h +++ b/firestore/src/android/query_android.h @@ -55,6 +55,22 @@ class QueryInternal : public Wrapper { /** Gets the Firestore instance associated with this query. */ Firestore* firestore(); + /** + * @brief Returns a query that counts the documents in the result set of this + * query. + * + * The returned query, when executed, counts the documents in the result set + * of this query without actually downloading the documents. + * + * Using the returned query to count the documents is efficient because only + * the final count, not the documents' data, is downloaded. The returned query + * can even count the documents if the result set would be prohibitively large + * to download entirely (e.g. thousands of documents). + * + * @return A query that counts the documents in the result set of this query. + */ + virtual AggregateQuery Count() const; + /** * @brief Creates and returns a new Query with the additional filter that * documents must contain the specified field and the value should be equal to diff --git a/firestore/src/common/aggregate_query.cc b/firestore/src/common/aggregate_query.cc index cb20323775..043af1748f 100644 --- a/firestore/src/common/aggregate_query.cc +++ b/firestore/src/common/aggregate_query.cc @@ -17,11 +17,12 @@ #include "firestore/src/include/firebase/firestore/aggregate_query.h" #include "firestore/src/common/cleanup.h" #include "firestore/src/common/futures.h" +#include "firestore/src/common/hard_assert_common.h" #include "firestore/src/common/util.h" #include "firestore/src/include/firebase/firestore/aggregate_query_snapshot.h" #if defined(__ANDROID__) -// TODO(tomandersen) #include "firestore/src/android/aggregate_query_android.h" +#include "firestore/src/android/aggregate_query_android.h" #else #include "firestore/src/main/aggregate_query_main.h" #endif // defined(__ANDROID__) diff --git a/firestore/src/common/aggregate_query_snapshot.cc b/firestore/src/common/aggregate_query_snapshot.cc index d86dd44863..a4ce874f33 100644 --- a/firestore/src/common/aggregate_query_snapshot.cc +++ b/firestore/src/common/aggregate_query_snapshot.cc @@ -17,12 +17,12 @@ #include "firestore/src/include/firebase/firestore/aggregate_query_snapshot.h" #include "firestore/src/common/cleanup.h" +#include "firestore/src/common/hard_assert_common.h" #include "firestore/src/common/util.h" #include "firestore/src/include/firebase/firestore/aggregate_query.h" #if defined(__ANDROID__) -// TODO(tomandersen) #include -// "firestore/src/android/aggregate_query_snapshot_android.h" +#include "firestore/src/android/aggregate_query_snapshot_android.h" #else #include "firestore/src/main/aggregate_query_snapshot_main.h" #endif // defined(__ANDROID__) diff --git a/firestore/src/include/firebase/firestore/query.h b/firestore/src/include/firebase/firestore/query.h index 1a6c0c398c..5223917262 100644 --- a/firestore/src/include/firebase/firestore/query.h +++ b/firestore/src/include/firebase/firestore/query.h @@ -156,7 +156,8 @@ class Query { * can even count the documents if the result set would be prohibitively large * to download entirely (e.g. thousands of documents). * - * @return A query that counts the documents in the result set of this query. + * @return An aggregate query that counts the documents in the result set of + * this query. */ virtual AggregateQuery Count() const; diff --git a/firestore/src/main/aggregate_query_main.h b/firestore/src/main/aggregate_query_main.h index 84f62dee67..3fb47cb095 100644 --- a/firestore/src/main/aggregate_query_main.h +++ b/firestore/src/main/aggregate_query_main.h @@ -18,7 +18,7 @@ #define FIREBASE_FIRESTORE_SRC_MAIN_AGGREGATE_QUERY_MAIN_H_ #include "Firestore/core/src/api/aggregate_query.h" -#include "firestore/src/include/firebase/firestore/aggregate_query.h" +#include "firestore/src/include/firebase/firestore/aggregate_source.h" #include "firestore/src/main/firestore_main.h" #if defined(__ANDROID__) @@ -28,6 +28,8 @@ namespace firebase { namespace firestore { +class AggregateQuerySnapshot; + class AggregateQueryInternal { public: explicit AggregateQueryInternal(api::AggregateQuery&& aggregate_query);