Skip to content

Commit

Permalink
Merge branch 'release/3.2' (#3308)
Browse files Browse the repository at this point in the history
* 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-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)
  • Loading branch information
pasin authored Jul 23, 2024
1 parent 0bab912 commit 00e5433
Show file tree
Hide file tree
Showing 88 changed files with 4,553 additions and 1,733 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/xcodebuild-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
build:
name: build-and-test
name: build
runs-on: macOS-latest
strategy:
matrix:
Expand All @@ -32,10 +32,4 @@ jobs:
SCHEME: ${{ matrix.scheme }}
run: |
DEVICE=$(cat device)
xcodebuild build-for-testing -scheme "${SCHEME}" -project CouchbaseLite.xcodeproj -destination "platform=iOS Simulator,name=${DEVICE}"
- name: "Test"
env:
SCHEME: ${{ matrix.scheme }}
run: |
DEVICE=$(cat device)
xcodebuild test-without-building -scheme "${SCHEME}" -project CouchbaseLite.xcodeproj -destination "platform=iOS Simulator,name=${DEVICE}"
xcodebuild build-for-testing -scheme "${SCHEME}" -project CouchbaseLite.xcodeproj -destination "platform=iOS Simulator,name=${DEVICE}"
11 changes: 2 additions & 9 deletions .github/workflows/xcodebuild-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
build:
name: build-and-test
name: build
runs-on: macOS-latest
strategy:
matrix:
Expand All @@ -30,11 +30,4 @@ jobs:
PLATFORM: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
run: |
xcodebuild build-for-testing -scheme "${SCHEME}" -project CouchbaseLite.xcodeproj -destination "${PLATFORM},arch=${ARCH}"
- name: "Test"
env:
SCHEME: ${{ matrix.scheme }}
PLATFORM: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
run: |
xcodebuild test-without-building -scheme "${SCHEME}" -project CouchbaseLite.xcodeproj -destination "${PLATFORM},arch=${ARCH}"
xcodebuild build-for-testing -scheme "${SCHEME}" -project CouchbaseLite.xcodeproj -destination "${PLATFORM},arch=${ARCH}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ frameworks/

# CBL files:
Tests/Extensions/CouchbaseLiteVectorSearch.xcframework
Tests/Extensions/LICENSE.txt
Tests/Extensions/Build
vendor/couchbase-lite-core-EE

# spm
Expand Down
140 changes: 116 additions & 24 deletions CouchbaseLite.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pipeline {
stage('Build'){
steps {
sh """
./couchbase-lite-ios/Scripts/pull_request_build.sh
./couchbase-lite-ios/Scripts/pull_request_build_test.sh
"""
}
}
Expand Down
6 changes: 3 additions & 3 deletions Objective-C/CBLArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ NS_ASSUME_NONNULL_BEGIN

/*
Gets value at the given index. The object types are CBLBlob,
CBLArray, CBLDictionary, NSNumber, or NSString based on the underlying
data type; or nil if the value is nil.
CBLArray, CBLDictionary, NSNumber, NSString, or NSNull based on
the underlying data type.
@param index The index.
@return The object or nil.
@return The value or nil.
*/
- (nullable id) valueAtIndex: (NSUInteger)index;

Expand Down
3 changes: 2 additions & 1 deletion Objective-C/CBLCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// limitations under the License.
//

#import <Foundation/Foundation.h>
#import <CouchbaseLite/CBLCollectionChangeObservable.h>
#import <CouchbaseLite/CBLIndexable.h>
#import <CouchbaseLite/CBLCollectionTypes.h>
Expand Down Expand Up @@ -173,7 +174,7 @@ extern NSString* const kCBLDefaultCollectionName;
@param document The document.
@param error On return, the error if any.
@return /True on success, false on failure.
@return True on success, false on failure.
*/
- (BOOL) deleteDocument: (CBLDocument*)document error: (NSError**)error;

Expand Down
27 changes: 26 additions & 1 deletion Objective-C/CBLCollection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#import "CBLDocumentChangeNotifier.h"
#import "CBLDocument+Internal.h"
#import "CBLErrorMessage.h"
#import "CBLIndexable.h"
#import "CBLIndexConfiguration+Internal.h"
#import "CBLIndex+Internal.h"
#import "CBLQueryIndex+Internal.h"
#import "CBLScope.h"
#import "CBLScope+Internal.h"
#import "CBLStatus.h"
Expand Down Expand Up @@ -951,4 +951,29 @@ - (FLSliceResult) emptyFLSliceResult: (CBLDatabase*)db {
return result;
}

- (nullable CBLQueryIndex*) indexWithName: (nonnull NSString*)name
error: (NSError**)error {
CBLAssertNotNil(name);

CBL_LOCK(_mutex) {
if (![self checkIsValid: error])
return nil;

C4Error c4err = {};
CBLStringBytes iName(name);

C4Index* c4index = c4coll_getIndex(_c4col, iName, &c4err);
if (!c4index) {
if (c4err.code != 0){
if (c4err.domain != LiteCoreDomain || c4err.code != kC4ErrorMissingIndex) {
convertError(c4err, error);
}
}
return nil;
}

return [[CBLQueryIndex alloc] initWithC4Index: c4index name: name collection: self];
}
}

@end
2 changes: 2 additions & 0 deletions Objective-C/CBLCollectionTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// limitations under the License.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
Expand Down
14 changes: 0 additions & 14 deletions Objective-C/CBLDatabase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,9 @@ + (void) CBLInit {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self checkFileLogging];
[self setExtensionPath];
});
}

/** Detect and set extension path */
+ (void) setExtensionPath {
#ifdef COUCHBASE_ENTERPRISE
// Note: For non app, the bundle will not be found.
NSBundle* vsBundle = [NSBundle bundleWithIdentifier: kVectorSearchExtIdentifier];
if (vsBundle.bundlePath) {
CBLLogInfo(Database, @"Set extension path : %@", vsBundle.bundlePath);
CBLStringBytes path(vsBundle.bundlePath);
c4_setExtensionPath(path);
}
#endif
}

/** Check and show warning if file logging is not configured. */
+ (void) checkFileLogging {
if (!CBLDatabase.log.file.config) {
Expand Down
14 changes: 13 additions & 1 deletion Objective-C/CBLDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,24 @@ extern const BOOL kCBLDefaultReplicatorAcceptParentCookies;

#pragma mark - CBLVectorIndexConfiguration

/** [NO] Vectors are not lazily indexed, by default */
extern const BOOL kCBLDefaultVectorIndexIsLazy;

/** [kCBLSQ8] Vectors are encoded by using 8-bit Scalar Quantizer encoding, by default */
extern const CBLScalarQuantizerType kCBLDefaultVectorIndexEncoding;

/** [kCBLDistanceMetricEuclidean] By default, vectors are compared using Euclidean metrics */
/** [kCBLDistanceMetricEuclideanSquared] By default, vectors are compared using Euclidean metrics */
extern const CBLDistanceMetric kCBLDefaultVectorIndexDistanceMetric;

/** [0] By default, the value will be determined based on the number of centroids, encoding types, and the encoding parameters. */
extern const unsigned int kCBLDefaultVectorIndexMinTrainingSize;

/** [0] By default, the value will be determined based on the number of centroids, encoding types, and the encoding parameters */
extern const unsigned int kCBLDefaultVectorIndexMaxTrainingSize;

/** [0] By default, the value will be determined based on the number of centroids. */
extern const unsigned int kCBLDefaultVectorIndexNumProbes;

#pragma mark - CBLURLEndpointListenerConfiguration

/** [0] No port specified, the OS will assign one */
Expand Down
10 changes: 9 additions & 1 deletion Objective-C/CBLDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@

#pragma mark - CBLVectorIndexConfiguration

const BOOL kCBLDefaultVectorIndexIsLazy = NO;

const CBLScalarQuantizerType kCBLDefaultVectorIndexEncoding = kCBLSQ8;

const CBLDistanceMetric kCBLDefaultVectorIndexDistanceMetric = kCBLDistanceMetricEuclidean;
const CBLDistanceMetric kCBLDefaultVectorIndexDistanceMetric = kCBLDistanceMetricEuclideanSquared;

const unsigned int kCBLDefaultVectorIndexMinTrainingSize = 0;

const unsigned int kCBLDefaultVectorIndexMaxTrainingSize = 0;

const unsigned int kCBLDefaultVectorIndexNumProbes = 0;

#pragma mark - CBLURLEndpointListenerConfiguration

Expand Down
8 changes: 4 additions & 4 deletions Objective-C/CBLDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Type Setters

/**
Gets a property's value. The object types are CBLBlob, CBLArray,
CBLDictionary, NSNumber, or NSString based on the underlying data type; or nil if the
property value is NSNull or the property doesn't exist.
Gets a property's value. The object types are CBLBlob, CBLArray, CBLDictionary,
NSNumber, NSString, or NSNull based on the underlying data type; or nil if the
the property doesn't exist.
@param key The key.
@return The object value or nil.
@return The value or nil.
*/
- (nullable id) valueForKey: (NSString*)key;

Expand Down
12 changes: 10 additions & 2 deletions Objective-C/CBLIndexable.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
// limitations under the License.
//

#import <CouchbaseLite/CBLIndexConfiguration.h>
#import <CouchbaseLite/CBLIndex.h>
#import <Foundation/Foundation.h>

@class CBLIndex;
@class CBLIndexConfiguration;
@class CBLQueryIndex;

NS_ASSUME_NONNULL_BEGIN

/** The Indexable interface defines a set of functions for managing the query indexes. */
@protocol CBLIndexable <NSObject>

Expand All @@ -38,6 +42,10 @@ NS_ASSUME_NONNULL_BEGIN
/** Delete an index by name. */
- (BOOL) deleteIndexWithName: (NSString*)name error: (NSError**)error;

/** Get an index object by name. */
- (nullable CBLQueryIndex*) indexWithName: (NSString*)name
error: (NSError**)error NS_SWIFT_NOTHROW;

@end

NS_ASSUME_NONNULL_END
10 changes: 9 additions & 1 deletion Objective-C/CBLMutableDocument.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CBLMutableDocument.m
// CouchbaseLite
//
// Copyright (c) 2017 Couchbase, Inc All rights reserved.
// Copyright (c) 2024 Couchbase, Inc All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@
#import "CBLDocument+Internal.h"
#import "CBLDatabase+Internal.h"
#import "CBLJSON.h"
#import "CBLLog+Internal.h"
#import "CBLMisc.h"
#import "CBLStringBytes.h"
#import "CBLStatus.h"
Expand All @@ -33,6 +34,13 @@

@implementation CBLMutableDocument

+ (void) initialize {
if (self == [CBLMutableDocument class]) {
// Initialize logging
CBLAssertNotNil(CBLLog.sharedInstance);
}
}

#pragma mark - Initializer

+ (instancetype) document {
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/CBLQueryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
@param expression The expression.
@return The COUNT(expr) function.
*/
+ (CBLQueryExpression*) count: (CBLQueryExpression*)expression;
+ (CBLQueryExpression*) count: (nullable CBLQueryExpression*)expression;

/**
Creates a MIN(expr) function expression that returns the minimum value
Expand Down
6 changes: 4 additions & 2 deletions Objective-C/CBLQueryFunction.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ + (CBLQueryExpression*) avg: (CBLQueryExpression*)expression {
params: @[expression]];
}

+ (CBLQueryExpression*) count: (CBLQueryExpression*)expression {
CBLAssertNotNil(expression);
+ (CBLQueryExpression*) count: (nullable CBLQueryExpression*)expression {
if (expression == nil) {
expression = [CBLQueryExpression all];
}

return [[CBLFunctionExpression alloc] initWithFunction: @"COUNT()"
params: @[expression]];
Expand Down
66 changes: 66 additions & 0 deletions Objective-C/CBLQueryIndex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// CBLQueryIndex.h
// CouchbaseLite
//
// Copyright (c) 2024 Couchbase, Inc All rights reserved.
//
// 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>

#ifdef COUCHBASE_ENTERPRISE
@class CBLIndexUpdater;
#endif

@class CBLCollection;

NS_ASSUME_NONNULL_BEGIN

/**
CBLQueryIndex object representing an existing index in the collection.
*/
@interface CBLQueryIndex : NSObject

/** The collection. */
@property (readonly, nonatomic) CBLCollection* collection;

/** The index name. */
@property (readonly, nonatomic) NSString* name;

#ifdef COUCHBASE_ENTERPRISE
/**
ENTERPRISE EDITION ONLY
For updating lazy vector indexes only.
Finds new or updated documents for which vectors need to be (re)computed and
return a CBLIndexUpdater object used for setting the computed vectors for updating the index.
The limit parameter is for setting the max number of vectors to be computed.
If index is up-to-date, nil will be returned.
If the index is not lazy, an error will be returned.
@param limit The limit per update.
@param error On return, the error if any.
@return CBLIndexUpdater object if there are updates to be done, or nil if the index is up-to-date or if an error occurred.
*/
- (nullable CBLIndexUpdater*) beginUpdateWithLimit: (uint64_t)limit
error: (NSError**)error NS_SWIFT_NOTHROW;
#endif

/** Not available */
- (instancetype) init NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 00e5433

Please sign in to comment.