Skip to content
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

End-to-end minimalistic ppl #14546

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions FirebaseFirestoreInternal/FirebaseFirestore/FIRPipelineBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2025 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.
*/

#import <FirebaseFirestoreInternal/FIRPipelineBridge.h>

Check failure on line 17 in FirebaseFirestoreInternal/FirebaseFirestore/FIRPipelineBridge.h

View workflow job for this annotation

GitHub Actions / spm-binary

'FirebaseFirestoreInternal/FIRPipelineBridge.h' file not found

Check failure on line 17 in FirebaseFirestoreInternal/FirebaseFirestore/FIRPipelineBridge.h

View workflow job for this annotation

GitHub Actions / spm-binary

'FirebaseFirestoreInternal/FIRPipelineBridge.h' file not found

Check failure on line 17 in FirebaseFirestoreInternal/FirebaseFirestore/FIRPipelineBridge.h

View workflow job for this annotation

GitHub Actions / spm-binary

'FirebaseFirestoreInternal/FIRPipelineBridge.h' file not found

Check failure on line 17 in FirebaseFirestoreInternal/FirebaseFirestore/FIRPipelineBridge.h

View workflow job for this annotation

GitHub Actions / spm-binary

'FirebaseFirestoreInternal/FIRPipelineBridge.h' file not found

Check failure on line 17 in FirebaseFirestoreInternal/FirebaseFirestore/FIRPipelineBridge.h

View workflow job for this annotation

GitHub Actions / spm-binary

'FirebaseFirestoreInternal/FIRPipelineBridge.h' file not found
12 changes: 10 additions & 2 deletions Firestore/Example/Firestore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
11F8EE69182C9699E90A9E3D /* database_info_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D92E20235D22000A432D /* database_info_test.cc */; };
12158DFCEE09D24B7988A340 /* maybe_document.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE7E20B89AAC00B5BCE7 /* maybe_document.pb.cc */; };
121F0FB9DCCBFB7573C7AF48 /* bundle_serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5C2A94EE24E60543F62CC35 /* bundle_serializer_test.cc */; };
12260A2A2D56A3CE001766EB /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12260A292D56A3CE001766EB /* PipelineTests.swift */; };
12260A2B2D56A3CE001766EB /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12260A292D56A3CE001766EB /* PipelineTests.swift */; };
12260A2C2D56A3CE001766EB /* PipelineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12260A292D56A3CE001766EB /* PipelineTests.swift */; };
124AAEE987451820F24EEA8E /* user_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CCC9BD953F121B9E29F9AA42 /* user_test.cc */; };
125B1048ECB755C2106802EB /* executor_std_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB4687208F9B9100554BA2 /* executor_std_test.cc */; };
1290FA77A922B76503AE407C /* lru_garbage_collector_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 277EAACC4DD7C21332E8496A /* lru_garbage_collector_test.cc */; };
Expand Down Expand Up @@ -1735,6 +1738,7 @@
0D964D4936953635AC7E0834 /* Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_1_01_bloom_filter_proto.json; sourceTree = "<group>"; };
0EE5300F8233D14025EF0456 /* string_apple_test.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = string_apple_test.mm; sourceTree = "<group>"; };
11984BA0A99D7A7ABA5B0D90 /* Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.release.xcconfig"; sourceTree = "<group>"; };
12260A292D56A3CE001766EB /* PipelineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PipelineTests.swift; sourceTree = "<group>"; };
1235769122B7E915007DDFA9 /* EncodableFieldValueTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncodableFieldValueTests.swift; sourceTree = "<group>"; };
1235769422B86E65007DDFA9 /* FirestoreEncoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirestoreEncoderTests.swift; sourceTree = "<group>"; };
124C932B22C1642C00CA8C2D /* CodableIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodableIntegrationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1797,7 +1801,7 @@
4334F87873015E3763954578 /* status_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = status_testing.h; sourceTree = "<group>"; };
4375BDCDBCA9938C7F086730 /* Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_5000_1_bloom_filter_proto.json; sourceTree = "<group>"; };
444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = hard_assert_test.cc; sourceTree = "<group>"; };
4564AD9C55EC39C080EB9476 /* globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = globals_cache_test.cc; sourceTree = "<group>"; };
4564AD9C55EC39C080EB9476 /* globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = globals_cache_test.cc; sourceTree = "<group>"; };
478DC75A0DCA6249A616DD30 /* Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_500_0001_membership_test_result.json; sourceTree = "<group>"; };
48D0915834C3D234E5A875A9 /* grpc_stream_tester.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = grpc_stream_tester.h; sourceTree = "<group>"; };
4B3E4A77493524333133C5DC /* Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1915,7 +1919,7 @@
5B5414D28802BC76FDADABD6 /* stream_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = stream_test.cc; sourceTree = "<group>"; };
5B96CC29E9946508F022859C /* Validation_BloomFilterTest_MD5_50000_0001_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_50000_0001_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_50000_0001_membership_test_result.json; sourceTree = "<group>"; };
5C68EE4CB94C0DD6E333F546 /* Validation_BloomFilterTest_MD5_1_01_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_1_01_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_1_01_membership_test_result.json; sourceTree = "<group>"; };
5C6DEA63FBDE19D841291723 /* memory_globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = memory_globals_cache_test.cc; sourceTree = "<group>"; };
5C6DEA63FBDE19D841291723 /* memory_globals_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = memory_globals_cache_test.cc; sourceTree = "<group>"; };
5C7942B6244F4C416B11B86C /* leveldb_mutation_queue_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = leveldb_mutation_queue_test.cc; sourceTree = "<group>"; };
5CAE131920FFFED600BE9A4A /* Firestore_Benchmarks_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Firestore_Benchmarks_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5CAE131D20FFFED600BE9A4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2296,6 +2300,7 @@
124C932B22C1642C00CA8C2D /* CodableIntegrationTests.swift */,
3355BE9391CC4857AF0BDAE3 /* DatabaseTests.swift */,
62E54B832A9E910A003347C8 /* IndexingTests.swift */,
12260A292D56A3CE001766EB /* PipelineTests.swift */,
621D620928F9CE7400D2FA26 /* QueryIntegrationTests.swift */,
4D65F6E69993611D47DC8E7C /* SnapshotListenerSourceTests.swift */,
EFF22EA92C5060A4009A369B /* VectorIntegrationTests.swift */,
Expand Down Expand Up @@ -4685,6 +4690,7 @@
432056C4D1259F76C80FC2A8 /* FSTUserDataReaderTests.mm in Sources */,
3B1E27D951407FD237E64D07 /* FirestoreEncoderTests.swift in Sources */,
62E54B862A9E910B003347C8 /* IndexingTests.swift in Sources */,
12260A2C2D56A3CE001766EB /* PipelineTests.swift in Sources */,
621D620C28F9CE7400D2FA26 /* QueryIntegrationTests.swift in Sources */,
1CFBD4563960D8A20C4679A3 /* SnapshotListenerSourceTests.swift in Sources */,
EFF22EAC2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */,
Expand Down Expand Up @@ -4935,6 +4941,7 @@
75A176239B37354588769206 /* FSTUserDataReaderTests.mm in Sources */,
5E89B1A5A5430713C79C4854 /* FirestoreEncoderTests.swift in Sources */,
62E54B852A9E910B003347C8 /* IndexingTests.swift in Sources */,
12260A2B2D56A3CE001766EB /* PipelineTests.swift in Sources */,
621D620B28F9CE7400D2FA26 /* QueryIntegrationTests.swift in Sources */,
A0BC30D482B0ABD1A3A24CDC /* SnapshotListenerSourceTests.swift in Sources */,
EFF22EAB2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */,
Expand Down Expand Up @@ -5440,6 +5447,7 @@
F5BDECEB3B43BD1591EEADBD /* FSTUserDataReaderTests.mm in Sources */,
6F45846C159D3C063DBD3CBE /* FirestoreEncoderTests.swift in Sources */,
62E54B842A9E910B003347C8 /* IndexingTests.swift in Sources */,
12260A2A2D56A3CE001766EB /* PipelineTests.swift in Sources */,
621D620A28F9CE7400D2FA26 /* QueryIntegrationTests.swift in Sources */,
B00F8D1819EE20C45B660940 /* SnapshotListenerSourceTests.swift in Sources */,
EFF22EAA2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/API/FIRFirestore+Internal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Google
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
49 changes: 49 additions & 0 deletions Firestore/Source/API/FIRPipelineBridge+Internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2025 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.
*/

#import "FIRPipelineBridge.h"

#include <memory>

#include "Firestore/core/src/api/expressions.h"
#include "Firestore/core/src/api/pipeline.h"
#include "Firestore/core/src/api/stages.h"

@class FIRFilter;

namespace api = firebase::firestore::api;

NS_ASSUME_NONNULL_BEGIN

@interface FIRExprBridge (Internal)

- (std::shared_ptr<api::Expr>)cpp_expr;

@end

@interface FIRStageBridge (Internal)

- (std::shared_ptr<api::Stage>)cpp_stage;

@end

@interface __FIRPipelineSnapshotBridge (Internal)

- (id)initWithCppSnapshot:(api::PipelineSnapshot)snapshot;

@end

NS_ASSUME_NONNULL_END
191 changes: 191 additions & 0 deletions Firestore/Source/API/FIRPipelineBridge.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
/*
* Copyright 2025 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.
*/

#import "FIRPipelineBridge.h"

#include <memory>

#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/API/FIRPipelineBridge+Internal.h"

#include "Firestore/core/src/api/expressions.h"
#include "Firestore/core/src/api/pipeline.h"
#include "Firestore/core/src/api/pipeline_result.h"
#include "Firestore/core/src/api/pipeline_snapshot.h"
#include "Firestore/core/src/api/stages.h"
#include "Firestore/core/src/util/error_apple.h"
#include "Firestore/core/src/util/status.h"
#include "Firestore/core/src/util/string_apple.h"

using firebase::firestore::api::CollectionSource;
using firebase::firestore::api::Constant;
using firebase::firestore::api::Expr;
using firebase::firestore::api::Field;
using firebase::firestore::api::FunctionExpr;
using firebase::firestore::api::Pipeline;
using firebase::firestore::api::Where;
using firebase::firestore::util::MakeCallback;
using firebase::firestore::util::MakeString;

NS_ASSUME_NONNULL_BEGIN

@implementation FIRExprBridge
@end

@implementation FIRFieldBridge {
std::shared_ptr<Field> field;
}

- (id)init:(NSString *)name {
self = [super init];
if (self) {
field = std::make_shared<Field>(MakeString(name));
}
return self;
}

- (std::shared_ptr<api::Expr>)cpp_expr {
return field;
}

@end

@implementation FIRConstantBridge {
std::shared_ptr<Constant> constant;
}
- (id)init:(NSNumber *)value {
self = [super init];
if (self) {
constant = std::make_shared<Constant>(value.doubleValue);
}
return self;
}

- (std::shared_ptr<api::Expr>)cpp_expr {
return constant;
}

@end

@implementation FIRFunctionExprBridge {
std::shared_ptr<FunctionExpr> eq;
}

- (nonnull id)initWithName:(NSString *)name Args:(nonnull NSArray<FIRExprBridge *> *)args {
self = [super init];
if (self) {
std::vector<std::shared_ptr<Expr>> cpp_args;
for (FIRExprBridge *arg in args) {
cpp_args.push_back(arg.cpp_expr);
}

eq = std::make_shared<FunctionExpr>(MakeString(name), std::move(cpp_args));
}
return self;
}

- (std::shared_ptr<api::Expr>)cpp_expr {
return eq;
}

@end

@implementation FIRStageBridge
@end

@implementation FIRCollectionSourceStageBridge {
std::shared_ptr<CollectionSource> collection_source;
}

- (id)initWithPath:(NSString *)path {
self = [super init];
if (self) {
collection_source = std::make_shared<CollectionSource>(MakeString(path));
}
return self;
}

- (std::shared_ptr<api::Stage>)cpp_stage {
return collection_source;
}

@end

@implementation FIRWhereStageBridge {
std::shared_ptr<Where> where;
}

- (id)initWithExpr:(FIRExprBridge *)expr {
self = [super init];
if (self) {
where = std::make_shared<Where>(expr.cpp_expr);
}
return self;
}

- (std::shared_ptr<api::Stage>)cpp_stage {
return where;
}

@end

@implementation __FIRPipelineSnapshotBridge {
absl::optional<api::PipelineSnapshot> pipeline;
}

- (id)initWithCppSnapshot:(api::PipelineSnapshot)snapshot {
self = [super init];
if (self) {
pipeline = std::move(snapshot);
}

return self;
}

@end

@implementation FIRPipelineBridge {
std::shared_ptr<Pipeline> pipeline;
}

- (id)initWithStages:(NSArray<FIRStageBridge *> *)stages db:(FIRFirestore *)db {
self = [super init];
if (self) {
std::vector<std::shared_ptr<firebase::firestore::api::Stage>> cpp_stages;
for (FIRStageBridge *stage in stages) {
cpp_stages.push_back(stage.cpp_stage);
}
pipeline = std::make_shared<Pipeline>(cpp_stages, db.wrapped);
}
return self;
}

- (void)executeWithCompletion:(void (^)(__FIRPipelineSnapshotBridge *_Nullable result,
NSError *_Nullable error))completion {
pipeline->execute([completion](StatusOr<api::PipelineSnapshot> maybe_value) {
if (maybe_value.ok()) {
__FIRPipelineSnapshotBridge *bridge = [[__FIRPipelineSnapshotBridge alloc]
initWithCppSnapshot:std::move(maybe_value).ValueOrDie()];
completion(bridge, nil);
} else {
completion(nil, MakeNSError(std::move(maybe_value).status()));
}
});
}

@end

NS_ASSUME_NONNULL_END
Loading
Loading