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

CBL-5180: Implement Array Index API #3327

Merged
merged 5 commits into from
Sep 23, 2024
Merged

CBL-5180: Implement Array Index API #3327

merged 5 commits into from
Sep 23, 2024

Conversation

velicuvlad
Copy link
Contributor

No description provided.

@velicuvlad velicuvlad requested review from pasin and borrrden September 6, 2024 19:47
@velicuvlad velicuvlad marked this pull request as ready for review September 9, 2024 15:58
expressions: @[@""]];
} else {
for (NSString* expression in expressions) {
if (!expression) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • NSArray/NSMutableArray doesn't allow nil so there is no need to check this for iOS.
  • The only thing that is needed to evaluate is whether expressions is empty or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for reminding me about NSArray/MutableArray, changing now

Copy link
Member

@borrrden borrrden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine but I also check that there is at least one non-empty element in the array before sending it to Core.

As you know, [""] works, but I would guess more often than not this is an error in the user's logic that ended up with empty string, rather than the user purposefully sending an empty string in the array (as opposed to nil). If there is at least one non-empty string in the list then any empty strings will then be caught and errored by Core.

@velicuvlad
Copy link
Contributor Author

velicuvlad commented Sep 10, 2024

@borrrden if is nil, I pass to Core [""] anyway. IMO, if we go ahead and check whether a non-empty list has any empty values, we might as well fail straight away in the case that is nil as well. Which then makes us handle most, if not all, scenarios, instead of letting Core to do it.

EDIT:
I've read it a couple more times and yes, indeed, from the user's perspective if I want it empty I would just pass nil, meanwhile that being potential empty can be an error my in code.

But what does LiteCore do in that scenario?
I know for nil passed, the path must contain scalar values. If that's not the case, I guess LiteCore throws? (we can't figure that out on client side so we don't care)
If path is not scalar (which again we can't tell), Is it just picking the non-empty values from expressions and computes with it or is throwing?

@velicuvlad
Copy link
Contributor Author

velicuvlad commented Sep 10, 2024

["class", "", "name"] will result into class,,name string representing n1ql. Now, as n1ql, that is invalid, but Jens mentioned on slack that as long as we pass a comma sep string to Core, it should be good enough for Core to sort out if is good or bad.

I've chat with Jianmin, and confirmed that will throw as invalid n1ql, which can be confusing depending of it actually showing where the problem is, but my understanding is that Core shouldn't even query with the above from Jens, but throw.

I will add this additional check if it ends up not being covered by Core.

@velicuvlad velicuvlad requested a review from pasin September 10, 2024 17:25
@pasin
Copy link
Contributor

pasin commented Sep 14, 2024

@velicuvlad

I know for nil passed, the path must contain scalar values. If that's not the case, I guess LiteCore throws? (we can't figure that out on client side so we don't care)

LiteCore will index the complex value which will turn out to be unuseful. There will be no error.

@velicuvlad velicuvlad merged commit 804a927 into release/3.2 Sep 23, 2024
8 checks passed
@velicuvlad velicuvlad deleted the CBL-5180 branch September 23, 2024 17:33
velicuvlad added a commit that referenced this pull request Nov 11, 2024
* CBL-5524 : Add all keys to the Privacy Manifest file (#3258)
* CBL-5541 : Update vector search test per changes in v1.8 (#3260)
* CBL-5365: Remove CBLErrors.h from Swift Public API (#3271)
* CBL-5508: Update Min macOS Support Version to 12.0 (#3272)
* CBL-5693 : Fix missing exported symbols (#3281)
* CBL-5222: MutableDocument should be usable before creating a database instance (#3278)
* CBL-5613: Swift API docs for Scope using Obj-c reference (#3284)
* CBL-5710: Add note that the replicator cannot be started in the inBatch() function (#3286)
* CBL-5514: Swift MutableDocument's collection is not set when a new document is saved (#3287)
* CBL-5660 : Fix a released query context may be used in observer callback (#3285)
* CBL-5668: Get Code Coverage at least 80% (#3289)
* CBL-3385: Allow null expression parameter for Function.count(expression) (#3290)
* CBL-5750  + CBL-5757  Lazy Index - ObjC (#3291)
* CBL-5811 : Support Vector Dimension to 4096 and Vector in Base64 String (#3294)
* CBL-5803 : Implement Lazy Vector Index and Test for Swift (#3295)
* CBL-5567 : Implement log replicator heiroglyphics (#3296)
* CBL-5859 : Allow explicitly enable vector search (#3297)
* CBL-5886: Add missing numProbes and correct min/maxTrainingSize default value (#3298)
* CBL-5932: Update default constants and public symbols (#3299)
* CBL-5928 : CBLErrors.h is not included in the umbrella header (#3301)
* CBL-5927 : Fix Duplicate CBLQueryIndex Interface Definition (#3300)
* CBL-5893: Throw exception for everything if finish() was successfully called beforehand (#3302)
* CBL-5956: Update DistanceMetric (#3303)
* CBL-5690 : Update Distance Metric Enum and VS SQL in Tests (#3304)
* CBL-5990 : Fix _kCBLDefaultLogFileUsePlaintext symbol (#3305)
* CBL-6070: Implement Database Full-Sync Option (#3318)
* CBL-6144: Add testConcurrentCreateAndQuery to verify query's lock (#3320)
* CBL-6191 : Fix null URL for proxy CONNECT request (#3324)
* CBL-5180: Implement Array Index API (#3327)
* CBL-5181: Array Index API tests and adjustments (#3330)
* CBL-5899
* CBL-6307: Database MMap Configuration API and tests (#3333)
* CBL-6349: Implement Document's getRevisionHistory() for E2E Test Server (#3335)
* LiteCore 3.2.1-19
* Export symbol for mmap constant (#3341)
* ArrayIndexConfiguration explicit expressions arg on set (#3342)

---------

Co-authored-by: Pasin Suriyentrakorn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants