-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Firestore VectorValue type #13404
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
Firestore VectorValue type #13404
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d9e2ba6
Stub VectorValue
MarkDuckworth 3ad498a
Porting VectorValue implementation.
MarkDuckworth 0725ad0
VectorValue tests and fixes.
MarkDuckworth 1d69177
Cleanup
MarkDuckworth 1263747
cleanup
MarkDuckworth 707c9f8
Formatting
MarkDuckworth a0c596e
PR feedback on codable.
MarkDuckworth ca625e9
formatting
MarkDuckworth 190ea8c
PR comments c++
MarkDuckworth 5f0b01b
Fixes based on PR feedback.
MarkDuckworth e0fadea
API reference doc comments.
MarkDuckworth e95e913
Merge branch 'main' of github.com:firebase/firebase-ios-sdk into mark…
MarkDuckworth ece38eb
Fix copyright header
MarkDuckworth c1abeb2
Update CHANGELOG.md
MarkDuckworth 7f2aa72
Header ordering
MarkDuckworth 7373969
Merge branch 'markduckworth/vector-type' of github.com:firebase/fireb…
MarkDuckworth 9fc9c7b
Update Firestore/CHANGELOG.md
MarkDuckworth 5f89b41
Merge branch 'main' of github.com:firebase/firebase-ios-sdk into mark…
MarkDuckworth 7b4ff08
Message rename to match API design
MarkDuckworth 7c91869
Fix comment
MarkDuckworth 070136c
Fix CI issues
MarkDuckworth d749fc7
Update run_firestore_emulator.sh to 1.19.7
MarkDuckworth 0fda84e
Code cleanup
MarkDuckworth 72b55e2
Merge branch 'markduckworth/vector-type' of github.com:firebase/fireb…
MarkDuckworth f6b9b1f
Update Firestore/Source/API/FIRVectorValue.mm
MarkDuckworth 3e84c75
PR feedback
MarkDuckworth fb86ecb
Merge branch 'markduckworth/vector-type' of github.com:firebase/fireb…
MarkDuckworth c5d43df
Cleanup
MarkDuckworth 71095ab
comment
MarkDuckworth a4046cd
Fixes
MarkDuckworth 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
15 changes: 15 additions & 0 deletions
15
FirebaseFirestoreInternal/FirebaseFirestore/FIRVectorValue.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,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> |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,48 @@ | ||
/* | ||
* 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 <FirebaseFirestore/FIRFieldValue.h> | ||
#import <FirebaseFirestore/FIRVectorValue.h> | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface FIRVectorValueTests : XCTestCase | ||
@end | ||
|
||
@implementation FIRVectorValueTests | ||
|
||
- (void)testCreateAndReadVectorValue { | ||
FIRVectorValue *vector = [FIRFieldValue vectorWithArray:@[ | ||
@DBL_MIN, @0.0, [NSNumber numberWithLong:((long)pow(2, 53)) + 1], @DBL_MAX, @DBL_EPSILON, | ||
@INT64_MAX | ||
]]; | ||
NSArray<NSNumber *> *outArray = vector.array; | ||
|
||
XCTAssertEqualObjects([outArray objectAtIndex:0], @DBL_MIN); | ||
XCTAssertEqualObjects([outArray objectAtIndex:1], @0.0); | ||
// Assert that if the vector is created with large long values, | ||
// then the data will be truncated as a double. | ||
XCTAssertEqual([outArray objectAtIndex:2].longValue, pow(2, 53)); | ||
XCTAssertEqualObjects([outArray objectAtIndex:3], @DBL_MAX); | ||
XCTAssertEqualObjects([outArray objectAtIndex:4], @DBL_EPSILON); | ||
XCTAssertEqualObjects([outArray objectAtIndex:5], @INT64_MAX); | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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,48 @@ | ||
/* | ||
* 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 "Firestore/Source/Public/FirebaseFirestore/FIRVectorValue.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation FIRVectorValue | ||
|
||
- (instancetype)initWithArray:(NSArray<NSNumber *> *)array { | ||
if (self = [super init]) { | ||
_array = [array valueForKey:@"doubleValue"]; | ||
} | ||
return self; | ||
} | ||
|
||
- (BOOL)isEqual:(nullable id)object { | ||
if (self == object) { | ||
return YES; | ||
} | ||
|
||
if (![object isKindOfClass:[FIRVectorValue class]]) { | ||
return NO; | ||
} | ||
|
||
FIRVectorValue *otherVector = ((FIRVectorValue *)object); | ||
|
||
return [self.array isEqualToArray:otherVector.array]; | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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
41 changes: 41 additions & 0 deletions
41
Firestore/Source/Public/FirebaseFirestore/FIRVectorValue.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,41 @@ | ||
/* | ||
* 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> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* Represents a vector type in Firestore documents. | ||
*/ | ||
NS_SWIFT_NAME(VectorValue) | ||
@interface FIRVectorValue : NSObject | ||
ncooke3 marked this conversation as resolved.
Show resolved
Hide resolved
ncooke3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ncooke3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** Returns a copy of the raw number array that represents the vector. */ | ||
@property(atomic, readonly) NSArray<NSNumber *> *array NS_REFINED_FOR_SWIFT; | ||
|
||
/** :nodoc: */ | ||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
/** | ||
* Creates a `VectorValue` constructed with a copy of the given array of NSNumbrers. | ||
MarkDuckworth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param array An array of NSNumbers that represents a vector. | ||
*/ | ||
- (instancetype)initWithArray:(NSArray<NSNumber *> *)array NS_REFINED_FOR_SWIFT; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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
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.