Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d9e2ba6
Stub VectorValue
MarkDuckworth Jul 18, 2024
3ad498a
Porting VectorValue implementation.
MarkDuckworth Jul 22, 2024
0725ad0
VectorValue tests and fixes.
MarkDuckworth Jul 25, 2024
1d69177
Cleanup
MarkDuckworth Jul 25, 2024
1263747
cleanup
MarkDuckworth Jul 25, 2024
707c9f8
Formatting
MarkDuckworth Jul 25, 2024
a0c596e
PR feedback on codable.
MarkDuckworth Jul 29, 2024
ca625e9
formatting
MarkDuckworth Jul 29, 2024
190ea8c
PR comments c++
MarkDuckworth Jul 29, 2024
5f0b01b
Fixes based on PR feedback.
MarkDuckworth Jul 29, 2024
e0fadea
API reference doc comments.
MarkDuckworth Jul 29, 2024
e95e913
Merge branch 'main' of github.com:firebase/firebase-ios-sdk into mark…
MarkDuckworth Jul 29, 2024
ece38eb
Fix copyright header
MarkDuckworth Jul 29, 2024
c1abeb2
Update CHANGELOG.md
MarkDuckworth Jul 29, 2024
7f2aa72
Header ordering
MarkDuckworth Jul 29, 2024
7373969
Merge branch 'markduckworth/vector-type' of github.com:firebase/fireb…
MarkDuckworth Jul 29, 2024
9fc9c7b
Update Firestore/CHANGELOG.md
MarkDuckworth Aug 1, 2024
5f89b41
Merge branch 'main' of github.com:firebase/firebase-ios-sdk into mark…
MarkDuckworth Aug 6, 2024
7b4ff08
Message rename to match API design
MarkDuckworth Aug 6, 2024
7c91869
Fix comment
MarkDuckworth Aug 6, 2024
070136c
Fix CI issues
MarkDuckworth Aug 7, 2024
d749fc7
Update run_firestore_emulator.sh to 1.19.7
MarkDuckworth Aug 7, 2024
0fda84e
Code cleanup
MarkDuckworth Aug 8, 2024
72b55e2
Merge branch 'markduckworth/vector-type' of github.com:firebase/fireb…
MarkDuckworth Aug 8, 2024
f6b9b1f
Update Firestore/Source/API/FIRVectorValue.mm
MarkDuckworth Aug 9, 2024
3e84c75
PR feedback
MarkDuckworth Aug 9, 2024
fb86ecb
Merge branch 'markduckworth/vector-type' of github.com:firebase/fireb…
MarkDuckworth Aug 9, 2024
c5d43df
Cleanup
MarkDuckworth Aug 9, 2024
71095ab
comment
MarkDuckworth Aug 9, 2024
a4046cd
Fixes
MarkDuckworth Aug 9, 2024
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
15 changes: 15 additions & 0 deletions FirebaseFirestoreInternal/FirebaseFirestore/FIRVectorValue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024 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/FIRVectorValue.h>
14 changes: 11 additions & 3 deletions Firestore/Example/Firestore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,9 @@
EF79998EBE4C72B97AB1880E /* value_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 40F9D09063A07F710811A84F /* value_util_test.cc */; };
EF8C005DC4BEA6256D1DBC6F /* user_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CCC9BD953F121B9E29F9AA42 /* user_test.cc */; };
EFD682178A87513A5F1AEFD9 /* memory_query_engine_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8EF6A33BC2D84233C355F1D0 /* memory_query_engine_test.cc */; };
EFF22EAA2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFF22EA92C5060A4009A369B /* VectorIntegrationTests.swift */; };
EFF22EAB2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFF22EA92C5060A4009A369B /* VectorIntegrationTests.swift */; };
EFF22EAC2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFF22EA92C5060A4009A369B /* VectorIntegrationTests.swift */; };
F05B277F16BDE6A47FE0F943 /* local_serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F8043813A5D16963EC02B182 /* local_serializer_test.cc */; };
F08DA55D31E44CB5B9170CCE /* limbo_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA129E1F315EE100DD57A1 /* limbo_spec_test.json */; };
F091532DEE529255FB008E25 /* snapshot_version_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABA495B9202B7E79008A7851 /* snapshot_version_test.cc */; };
Expand Down Expand Up @@ -1693,7 +1696,7 @@
132E32997D781B896672D30A /* reference_set_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reference_set_test.cc; sourceTree = "<group>"; };
166CE73C03AB4366AAC5201C /* leveldb_index_manager_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = leveldb_index_manager_test.cc; sourceTree = "<group>"; };
1A7D48A017ECB54FD381D126 /* Validation_BloomFilterTest_MD5_5000_1_membership_test_result.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_5000_1_membership_test_result.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_5000_1_membership_test_result.json; sourceTree = "<group>"; };
1A8141230C7E3986EACEF0B6 /* thread_safe_memoizer_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = thread_safe_memoizer_test.cc; sourceTree = "<group>"; };
1A8141230C7E3986EACEF0B6 /* thread_safe_memoizer_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = thread_safe_memoizer_test.cc; sourceTree = "<group>"; };
1B342370EAE3AA02393E33EB /* cc_compilation_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; name = cc_compilation_test.cc; path = api/cc_compilation_test.cc; sourceTree = "<group>"; };
1B9F95EC29FAD3F100EEC075 /* FIRAggregateQueryUnitTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRAggregateQueryUnitTests.mm; sourceTree = "<group>"; };
1C01D8CE367C56BB2624E299 /* index.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = index.pb.h; path = admin/index.pb.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1750,7 +1753,7 @@
4BD051DBE754950FEAC7A446 /* Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; name = Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json; path = bloom_filter_golden_test_data/Validation_BloomFilterTest_MD5_500_01_bloom_filter_proto.json; sourceTree = "<group>"; };
4C73C0CC6F62A90D8573F383 /* string_apple_benchmark.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = string_apple_benchmark.mm; sourceTree = "<group>"; };
4D65F6E69993611D47DC8E7C /* SnapshotListenerSourceTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SnapshotListenerSourceTests.swift; sourceTree = "<group>"; };
4D9E51DA7A275D8B1CAEAEB2 /* listen_source_spec_test.json */ = {isa = PBXFileReference; includeInIndex = 1; path = listen_source_spec_test.json; sourceTree = "<group>"; };
4D9E51DA7A275D8B1CAEAEB2 /* listen_source_spec_test.json */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.json; path = listen_source_spec_test.json; sourceTree = "<group>"; };
4F5B96F3ABCD2CA901DB1CD4 /* bundle_builder.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = bundle_builder.cc; sourceTree = "<group>"; };
526D755F65AC676234F57125 /* target_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = target_test.cc; sourceTree = "<group>"; };
52756B7624904C36FBB56000 /* fake_target_metadata_provider.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = fake_target_metadata_provider.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1904,7 +1907,7 @@
62E54B832A9E910A003347C8 /* IndexingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndexingTests.swift; sourceTree = "<group>"; };
63136A2371C0C013EC7A540C /* target_index_matcher_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = target_index_matcher_test.cc; sourceTree = "<group>"; };
64AA92CFA356A2360F3C5646 /* filesystem_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = filesystem_testing.h; sourceTree = "<group>"; };
65AF0AB593C3AD81A1F1A57E /* FIRCompositeIndexQueryTests.mm */ = {isa = PBXFileReference; includeInIndex = 1; path = FIRCompositeIndexQueryTests.mm; sourceTree = "<group>"; };
65AF0AB593C3AD81A1F1A57E /* FIRCompositeIndexQueryTests.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRCompositeIndexQueryTests.mm; sourceTree = "<group>"; };
67786C62C76A740AEDBD8CD3 /* FSTTestingHooks.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = FSTTestingHooks.h; sourceTree = "<group>"; };
69E6C311558EC77729A16CF1 /* Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS/Pods-Firestore_Example_iOS-Firestore_SwiftTests_iOS.debug.xcconfig"; sourceTree = "<group>"; };
6A7A30A2DB3367E08939E789 /* bloom_filter.pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = bloom_filter.pb.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2090,6 +2093,7 @@
EF6C285029E462A200A7D4F1 /* FIRAggregateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRAggregateTests.mm; sourceTree = "<group>"; };
EF6C286C29E6D22200A7D4F1 /* AggregationIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AggregationIntegrationTests.swift; sourceTree = "<group>"; };
EF83ACD5E1E9F25845A9ACED /* leveldb_migrations_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = leveldb_migrations_test.cc; sourceTree = "<group>"; };
EFF22EA92C5060A4009A369B /* VectorIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VectorIntegrationTests.swift; sourceTree = "<group>"; };
F02F734F272C3C70D1307076 /* filter_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = filter_test.cc; sourceTree = "<group>"; };
F119BDDF2F06B3C0883B8297 /* firebase_app_check_credentials_provider_test.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; name = firebase_app_check_credentials_provider_test.mm; path = credentials/firebase_app_check_credentials_provider_test.mm; sourceTree = "<group>"; };
F354C0FE92645B56A6C6FD44 /* Pods-Firestore_IntegrationTests_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_IntegrationTests_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_IntegrationTests_iOS/Pods-Firestore_IntegrationTests_iOS.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2233,6 +2237,7 @@
62E54B832A9E910A003347C8 /* IndexingTests.swift */,
621D620928F9CE7400D2FA26 /* QueryIntegrationTests.swift */,
4D65F6E69993611D47DC8E7C /* SnapshotListenerSourceTests.swift */,
EFF22EA92C5060A4009A369B /* VectorIntegrationTests.swift */,
);
path = Integration;
sourceTree = "<group>";
Expand Down Expand Up @@ -4638,6 +4643,7 @@
AECCD9663BB3DC52199F954A /* executor_std_test.cc in Sources */,
18F644E6AA98E6D6F3F1F809 /* executor_test.cc in Sources */,
6938575C8B5E6FE0D562547A /* exponential_backoff_test.cc in Sources */,
EFF22EAC2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */,
258B372CF33B7E7984BBA659 /* fake_target_metadata_provider.cc in Sources */,
F8BD2F61EFA35C2D5120D9EB /* field_index_test.cc in Sources */,
F272A8C41D2353700A11D1FB /* field_mask_test.cc in Sources */,
Expand Down Expand Up @@ -4879,6 +4885,7 @@
17DFF30CF61D87883986E8B6 /* executor_std_test.cc in Sources */,
814724DE70EFC3DDF439CD78 /* executor_test.cc in Sources */,
BD6CC8614970A3D7D2CF0D49 /* exponential_backoff_test.cc in Sources */,
EFF22EAB2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */,
4D2655C5675D83205C3749DC /* fake_target_metadata_provider.cc in Sources */,
50C852E08626CFA7DC889EEA /* field_index_test.cc in Sources */,
A1563EFEB021936D3FFE07E3 /* field_mask_test.cc in Sources */,
Expand Down Expand Up @@ -5367,6 +5374,7 @@
125B1048ECB755C2106802EB /* executor_std_test.cc in Sources */,
DABB9FB61B1733F985CBF713 /* executor_test.cc in Sources */,
7BCF050BA04537B0E7D44730 /* exponential_backoff_test.cc in Sources */,
EFF22EAA2C5060A4009A369B /* VectorIntegrationTests.swift in Sources */,
BA1C5EAE87393D8E60F5AE6D /* fake_target_metadata_provider.cc in Sources */,
84285C3F63D916A4786724A8 /* field_index_test.cc in Sources */,
6A40835DB2C02B9F07C02E88 /* field_mask_test.cc in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
enableASanStackUseAfterReturn = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F5AD195388D20070C39A"
BuildableName = "Firestore_Tests_iOS.xctest"
BlueprintName = "Firestore_Tests_iOS"
ReferencedContainer = "container:Firestore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -40,17 +49,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F5AD195388D20070C39A"
BuildableName = "Firestore_Tests_iOS.xctest"
BlueprintName = "Firestore_Tests_iOS"
ReferencedContainer = "container:Firestore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -71,8 +69,6 @@
ReferencedContainer = "container:Firestore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
5 changes: 5 additions & 0 deletions Firestore/Source/API/FIRFieldValue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#import "Firestore/Source/API/FIRFieldValue+Internal.h"
#import "Firestore/Source/API/FIRVectorValue+Internal.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -176,6 +177,10 @@ + (instancetype)fieldValueForIntegerIncrement:(int64_t)l {
return [[FSTNumericIncrementFieldValue alloc] initWithOperand:@(l)];
}

+ (nonnull FIRVectorValue *)vectorFromNSNumbers:(nonnull NSArray<NSNumber *> *)values {
return [[FIRVectorValue alloc] initWithNSNumbers:values];
}

@end

NS_ASSUME_NONNULL_END
26 changes: 26 additions & 0 deletions Firestore/Source/API/FIRVectorValue+Internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2024 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 "FIRVectorValue.h"

NS_ASSUME_NONNULL_BEGIN

@interface FIRVectorValue (Internal)
// - (instancetype)init NS_UNAVAILABLE;
// - (NSArray<NSNumber *> *)toNSArray;
@end

NS_ASSUME_NONNULL_END
82 changes: 82 additions & 0 deletions Firestore/Source/API/FIRVectorValue.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2024 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 <Foundation/Foundation.h>

#include <vector>

#import "Firestore/Source/API/FIRVectorValue+Internal.h"

NS_ASSUME_NONNULL_BEGIN

@interface FIRVectorValue () {
/** Internal vector representation */
std::vector<double> _internalValue;
}

@end

@implementation FIRVectorValue

- (instancetype)initWithNSNumbers:(NSArray<NSNumber *> *)data {
if (self = [super init]) {
std::vector<double> converted;
converted.reserve(data.count);
for (NSNumber *value in data) {
converted.emplace_back([value doubleValue]);
}

_internalValue = std::move(converted);
}
return self;
}

- (nonnull NSArray<NSNumber *> *)toNSArray {
size_t length = _internalValue.size();
NSMutableArray<NSNumber *> *outArray =
[[NSMutableArray<NSNumber *> alloc] initWithCapacity:length];
for (size_t i = 0; i < length; i++) {
[outArray addObject:[[NSNumber alloc] initWithDouble:self->_internalValue.at(i)]];
}

return outArray;
}

- (BOOL)isEqual:(nullable id)object {
if (self == object) {
return YES;
}

if (![object isKindOfClass:[FIRVectorValue class]]) {
return NO;
}

FIRVectorValue *otherVector = ((FIRVectorValue *)object);

if (self->_internalValue.size() != otherVector->_internalValue.size()) {
return NO;
}

for (size_t i = 0; i < self->_internalValue.size(); i++) {
if (self->_internalValue[i] != otherVector->_internalValue[i]) return NO;
}

return YES;
}

@end

NS_ASSUME_NONNULL_END
41 changes: 40 additions & 1 deletion Firestore/Source/API/FSTUserDataReader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#import "FIRGeoPoint.h"
#import "FIRTimestamp.h"
#import "FIRVectorValue.h"

#import "Firestore/Source/API/FIRDocumentReference+Internal.h"
#import "Firestore/Source/API/FIRFieldPath+Internal.h"
Expand Down Expand Up @@ -340,6 +341,42 @@ - (ParsedUpdateData)parsedUpdateData:(id)input {
return std::move(result);
}

- (Message<google_firestore_v1_Value>)parseVectorValue:(FIRVectorValue *)vectorValue
context:(ParseContext &&)context {
__block Message<google_firestore_v1_Value> result;
result->which_value_type = google_firestore_v1_Value_map_value_tag;
result->map_value = {};

result->map_value.fields_count = 2;
result->map_value.fields = nanopb::MakeArray<google_firestore_v1_MapValue_FieldsEntry>(2);

result->map_value.fields[0].key = nanopb::CopyBytesArray(model::kTypeValueFieldKey);
result->map_value.fields[0].value = *[self encodeStringValue:MakeString(@"__vector__")].release();

NSArray<NSNumber *> *vectorArray = [vectorValue toNSArray];

__block Message<google_firestore_v1_Value> arrayMessage;
arrayMessage->which_value_type = google_firestore_v1_Value_array_value_tag;
arrayMessage->array_value.values_count = CheckedSize([vectorArray count]);
arrayMessage->array_value.values =
nanopb::MakeArray<google_firestore_v1_Value>(arrayMessage->array_value.values_count);

[vectorArray enumerateObjectsUsingBlock:^(id entry, NSUInteger idx, BOOL *) {
if (![entry isKindOfClass:[NSNumber class]]) {
ThrowInvalidArgument("VectorValues must only contain numeric values.",
context.FieldDescription());
}

// Vector values must always use Double encoding
arrayMessage->array_value.values[idx] = *[self encodeDouble:[entry doubleValue]].release();
}];

result->map_value.fields[1].key = nanopb::CopyBytesArray(model::kVectorValueFieldKey);
result->map_value.fields[1].value = *arrayMessage.release();

return std::move(result);
}

- (Message<google_firestore_v1_Value>)parseArray:(NSArray<id> *)array
context:(ParseContext &&)context {
__block Message<google_firestore_v1_Value> result;
Expand Down Expand Up @@ -528,7 +565,9 @@ - (void)parseSentinelFieldValue:(FIRFieldValue *)fieldValue context:(ParseContex
_databaseID.database_id(), context.FieldDescription());
}
return [self encodeReference:_databaseID key:reference.key];

} else if ([input isKindOfClass:[FIRVectorValue class]]) {
FIRVectorValue *vector = input;
return [self parseVectorValue:vector context:std::move(context)];
} else {
ThrowInvalidArgument("Unsupported type: %s%s", NSStringFromClass([input class]),
context.FieldDescription());
Expand Down
Loading