@@ -710,9 +710,11 @@ - (id)initWithPercentage:(double)percentage {
710
710
- (std::shared_ptr<api::Stage>)cppStageWithReader : (FSTUserDataReader *)reader {
711
711
if (!isUserDataRead) {
712
712
if ([type isEqualToString: @" count" ]) {
713
- cpp_sample = std::make_shared<Sample>(" count" , _count, 0 );
713
+ cpp_sample =
714
+ std::make_shared<Sample>(Sample::SampleMode (Sample::SampleMode::DOCUMENTS), _count, 0 );
714
715
} else {
715
- cpp_sample = std::make_shared<Sample>(" percentage" , 0 , _percentage);
716
+ cpp_sample =
717
+ std::make_shared<Sample>(Sample::SampleMode (Sample::SampleMode::PERCENT), 0 , _percentage);
716
718
}
717
719
}
718
720
@@ -750,30 +752,35 @@ - (id)initWithOther:(FIRPipelineBridge *)other {
750
752
751
753
@implementation FIRUnnestStageBridge {
752
754
FIRExprBridge *_field;
753
- NSString *_Nullable _indexField;
755
+ FIRExprBridge *_Nullable _index_field;
756
+ FIRExprBridge *_alias;
754
757
Boolean isUserDataRead;
755
758
std::shared_ptr<Unnest> cpp_unnest;
756
759
}
757
760
758
- - (id )initWithField : (FIRExprBridge *)field indexField : (NSString *_Nullable)indexField {
761
+ - (id )initWithField : (FIRExprBridge *)field
762
+ alias : (FIRExprBridge *)alias
763
+ indexField : (FIRExprBridge *_Nullable)index_field {
759
764
self = [super init ];
760
765
if (self) {
761
766
_field = field;
762
- _indexField = indexField;
767
+ _alias = alias;
768
+ _index_field = index_field;
763
769
isUserDataRead = NO ;
764
770
}
765
771
return self;
766
772
}
767
773
768
774
- (std::shared_ptr<api::Stage>)cppStageWithReader : (FSTUserDataReader *)reader {
769
775
if (!isUserDataRead) {
770
- absl::optional<std::string > cpp_index_field;
771
- if (_indexField != nil ) {
772
- cpp_index_field = MakeString (_indexField) ;
776
+ absl::optional<std::shared_ptr<Expr> > cpp_index_field;
777
+ if (_index_field != nil ) {
778
+ cpp_index_field = [_index_field cppExprWithReader: reader] ;
773
779
} else {
774
780
cpp_index_field = absl::nullopt ;
775
781
}
776
- cpp_unnest = std::make_shared<Unnest>([_field cppExprWithReader: reader], cpp_index_field);
782
+ cpp_unnest = std::make_shared<Unnest>([_field cppExprWithReader: reader],
783
+ [_alias cppExprWithReader: reader], cpp_index_field);
777
784
}
778
785
779
786
isUserDataRead = YES ;
@@ -784,14 +791,14 @@ - (id)initWithField:(FIRExprBridge *)field indexField:(NSString *_Nullable)index
784
791
785
792
@implementation FIRRawStageBridge {
786
793
NSString *_name;
787
- NSArray <FIRExprBridge * > *_params;
794
+ NSArray <id > *_params;
788
795
NSDictionary <NSString *, FIRExprBridge *> *_Nullable _options;
789
796
Boolean isUserDataRead;
790
797
std::shared_ptr<RawStage> cpp_generic_stage;
791
798
}
792
799
793
800
- (id )initWithName : (NSString *)name
794
- params : (NSArray <FIRExprBridge * > *)params
801
+ params : (NSArray <id > *)params
795
802
options : (NSDictionary <NSString *, FIRExprBridge *> *_Nullable)options {
796
803
self = [super init ];
797
804
if (self) {
@@ -803,12 +810,43 @@ - (id)initWithName:(NSString *)name
803
810
return self;
804
811
}
805
812
813
+ - (firebase::firestore::google_firestore_v1_Value)convertIdToV1Value : (id )value
814
+ reader : (FSTUserDataReader *)reader {
815
+ if ([value isKindOfClass: [FIRExprBridge class ]]) {
816
+ return [((FIRExprBridge *)value) cppExprWithReader: reader]->to_proto ();
817
+ } else if ([value isKindOfClass: [FIRAggregateFunctionBridge class ]]) {
818
+ return [((FIRAggregateFunctionBridge *)value) cppExprWithReader: reader]->to_proto ();
819
+ } else if ([value isKindOfClass: [NSDictionary class ]]) {
820
+ NSDictionary <NSString *, FIRExprBridge *> *dictionary =
821
+ (NSDictionary <NSString *, FIRExprBridge *> *)value;
822
+
823
+ std::unordered_map<std::string, firebase::firestore::google_firestore_v1_Value> cpp_dictionary;
824
+ for (NSString *key in dictionary) {
825
+ cpp_dictionary[MakeString (key)] = [dictionary[key] cppExprWithReader: reader]->to_proto ();
826
+ }
827
+
828
+ firebase::firestore::google_firestore_v1_Value result;
829
+ result.which_value_type = google_firestore_v1_Value_map_value_tag;
830
+
831
+ nanopb::SetRepeatedField (
832
+ &result.map_value .fields , &result.map_value .fields_count , cpp_dictionary,
833
+ [](const std::pair<std::string, firebase::firestore::google_firestore_v1_Value> &entry) {
834
+ return firebase::firestore::_google_firestore_v1_MapValue_FieldsEntry{
835
+ nanopb::MakeBytesArray (entry.first ), entry.second };
836
+ });
837
+ return result;
838
+ } else {
839
+ ThrowInvalidArgument (" Subscript key must be an NSString or FIRFieldPath." );
840
+ }
841
+ }
842
+
806
843
- (std::shared_ptr<api::Stage>)cppStageWithReader : (FSTUserDataReader *)reader {
807
844
if (!isUserDataRead) {
808
- std::vector<std::shared_ptr<Expr> > cpp_params;
809
- for (FIRExprBridge * param in _params) {
810
- cpp_params.push_back ([param cppExprWithReader : reader]);
845
+ std::vector<firebase::firestore::google_firestore_v1_Value > cpp_params;
846
+ for (id param in _params) {
847
+ cpp_params.push_back ([self convertIdToV1Value: param reader : reader]);
811
848
}
849
+
812
850
std::unordered_map<std::string, std::shared_ptr<Expr>> cpp_options;
813
851
if (_options) {
814
852
for (NSString *key in _options) {
0 commit comments