-
Notifications
You must be signed in to change notification settings - Fork 124
Tomandersen/count api #1236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tomandersen/count api #1236
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
de5bc65
Firestore COUNT API (#1174)
tom-andersen fb86fa3
Merge branch 'main' into count
tom-andersen 60ab28d
Fix linking
tom-andersen 3a68030
Cleanup
tom-andersen 558b317
Responding to PR comments.
tom-andersen 0141434
Rename
tom-andersen ff40ac0
Rename
tom-andersen 1a5b1c0
Fixup constructor/assignment parameter naming.
tom-andersen 4e5a847
Add Test
tom-andersen c0f8f9d
Format
tom-andersen d704a5c
Add test
tom-andersen 41f3e43
Add test
tom-andersen 619e38c
Format
tom-andersen a8379ab
Recognize NaN filter probelm
tom-andersen c80337c
Add tests
tom-andersen 0682275
Add tests
tom-andersen eceb451
Add tests
tom-andersen 1af4623
Test is_valid()
tom-andersen 9bceca3
Add constructor and assignment tests.
tom-andersen f0f6af1
Rename variable
tom-andersen 833a2e8
Format
tom-andersen bbf2f4f
Remove extra semicolon
tom-andersen 34ed02b
Firestore COUNT API
tom-andersen b54a046
[macOS sandbox mode] Application group name mangling for semaphores (…
DellaBitta 2426266
Firestore COUNT implementation (WIP)
tom-andersen a493a8a
Firestore COUNT implementation (WIP)
tom-andersen 07c1162
Fix linting
tom-andersen 90a152e
Fix linting
tom-andersen f4ab7fa
Fix linking
tom-andersen cfebc8a
Disable getSessionId test on emulators. (#1193)
jonsimantov 1c25668
Cleanup
tom-andersen ee7fbc0
Fix release notes
tom-andersen 73b3276
Format
tom-andersen c3c8b4e
Fixes from review
tom-andersen 7d878d2
Formatting
tom-andersen e1d1fe7
Responding to PR comments.
tom-andersen 7c235c7
Add Hash
tom-andersen fd40bd2
Add Hash
tom-andersen bc60e1e
Fix copyright year
tom-andersen 6f228f1
Rename
tom-andersen f239437
Format
tom-andersen 8c35acf
Rename
tom-andersen 5ab942a
Fixup constructor/assignment parameter naming.
tom-andersen 6686fd7
Format
tom-andersen ddbb47a
Merge branch 'tomandersen/countTest' into tomandersen/countAPI
tom-andersen 422de73
Stub Android Impl
tom-andersen d403ded
Tomandersen/count test (#1206)
tom-andersen 1ddee51
JNI Count Implementation
tom-andersen 3e5d9c1
Pretty
tom-andersen 062c109
Merge remote-tracking branch 'origin/count' into tomandersen/countAPI
tom-andersen 044da55
Merge branch 'count' into tomandersen/countAPI
tom-andersen db87160
Fix according PR comments
tom-andersen d2b34d4
Pretty
tom-andersen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Task> kGet("get", | ||
"(Lcom/google/firebase/firestore/AggregateSource;)" | ||
"Lcom/google/android/gms/tasks/Task;"); | ||
Method<Object> kGetQuery("getQuery", "()Lcom/google/firebase/firestore/Query;"); | ||
Method<int32_t> kHashCode("hashCode", "()I"); | ||
|
||
} // namespace | ||
|
||
void AggregateQueryInternal::Initialize(jni::Loader& loader) { | ||
loader.LoadClass(kClassName, kGet, kGetQuery, kHashCode); | ||
} | ||
|
||
Query AggregateQueryInternal::query() const { | ||
Env env = GetEnv(); | ||
Local<Object> query = env.Call(obj_, kGetQuery); | ||
return firestore_->NewQuery(env, query); | ||
} | ||
|
||
Future<AggregateQuerySnapshot> AggregateQueryInternal::Get( | ||
AggregateSource aggregate_source) { | ||
Env env = GetEnv(); | ||
Local<Object> java_source = | ||
AggregateSourceInternal::Create(env, aggregate_source); | ||
Local<Task> task = env.Call(obj_, kGet, java_source); | ||
return promises_.NewFuture<AggregateQuerySnapshot>(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AggregateQuerySnapshot> Get(AggregateSource aggregate_source); | ||
|
||
size_t Hash() const; | ||
|
||
private: | ||
PromiseFactory<AsyncFn> 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_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Object> kConstructor( | ||
"(Lcom/google/firebase/firestore/AggregateQuery;J)V"); | ||
Method<int64_t> kGetCount("getCount", "()J"); | ||
Method<Object> kGetQuery("getQuery", | ||
"()Lcom/google/firebase/firestore/AggregateQuery;"); | ||
Method<int32_t> 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<Object> instance = env.New(kConstructor, arg, count); | ||
return aggregate_query_internal.firestore_internal() | ||
->NewAggregateQuerySnapshot(env, instance); | ||
} | ||
|
||
AggregateQuery AggregateQuerySnapshotInternal::query() const { | ||
Env env = GetEnv(); | ||
Local<Object> 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.