Skip to content

Commit

Permalink
CBL-5715 : Implement Lazy Index API
Browse files Browse the repository at this point in the history
* Implemented Lazy Index API.
* Implemented Lazy Index Test ( CBL-5756 ).
* Update LiteCore to 3.2.0-195.
* Reorganized Query and Index headers.
* Fixed mem leak in QueryTest.cc.
  • Loading branch information
pasin committed Jun 11, 2024
1 parent d48ce72 commit 172b003
Show file tree
Hide file tree
Showing 39 changed files with 2,523 additions and 514 deletions.
28 changes: 28 additions & 0 deletions CBL_C.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
40E7CA732BFE7336004BE7E1 /* ContextManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 40E7CA632BFE7336004BE7E1 /* ContextManager.cc */; };
40E7CA742BFE7336004BE7E1 /* ContextManager.hh in Headers */ = {isa = PBXBuildFile; fileRef = 40E7CA722BFE7336004BE7E1 /* ContextManager.hh */; };
40F902D82B9F7B12002EA0A0 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 40F902C82B9F7AF6002EA0A0 /* PrivacyInfo.xcprivacy */; };
40FE2DD12C082465005E99E9 /* CBLQueryIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 40FE2DC22C08245E005E99E9 /* CBLQueryIndex.h */; };
40FE2DD22C082466005E99E9 /* CBLQueryIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 40FE2DC22C08245E005E99E9 /* CBLQueryIndex.h */; settings = {ATTRIBUTES = (Public, ); }; };
40FE2DD62C092578005E99E9 /* CBLQueryIndex_CAPI.cc in Sources */ = {isa = PBXBuildFile; fileRef = 40FE2DD52C092578005E99E9 /* CBLQueryIndex_CAPI.cc */; };
40FE2DD92C0926FF005E99E9 /* CBLQueryIndex.cc in Sources */ = {isa = PBXBuildFile; fileRef = 40FE2DD72C0926FF005E99E9 /* CBLQueryIndex.cc */; };
40FE2DDA2C0926FF005E99E9 /* CBLQueryIndex_Internal.hh in Headers */ = {isa = PBXBuildFile; fileRef = 40FE2DD82C0926FF005E99E9 /* CBLQueryIndex_Internal.hh */; };
40FE2E0E2C12AEF6005E99E9 /* LazyVectorIndexTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 40FE2DFE2C12AEEB005E99E9 /* LazyVectorIndexTest.cc */; };
42D1B69D2978AD31003B9871 /* CBLUserAgent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 42D1B68F2978AD31003B9871 /* CBLUserAgent.mm */; };
6938073022DE96C200727053 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 277CC9B122BC4E2E00B245CB /* Security.framework */; };
932062DB26BC6B43006917A5 /* CBLQuery.cc in Sources */ = {isa = PBXBuildFile; fileRef = 932062DA26BC6B43006917A5 /* CBLQuery.cc */; };
Expand Down Expand Up @@ -470,6 +476,8 @@
4022546D29355576000FBAC8 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = assets; sourceTree = "<group>"; };
406E46D22BACAEFF0088198C /* VectorSearchTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = VectorSearchTest.cc; sourceTree = "<group>"; };
406E46E72BAD3BB30088198C /* cmake */ = {isa = PBXFileReference; lastKnownFileType = folder; path = cmake; sourceTree = "<group>"; };
406F8D6F2C17E191000223FC /* CBLQueryTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLQueryTypes.h; sourceTree = "<group>"; };
406F8D802C17E3B4000223FC /* CBLQueryIndexTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLQueryIndexTypes.h; sourceTree = "<group>"; };
4083FC9F2BA3A4390061509D /* CBLVectorIndexConfig.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CBLVectorIndexConfig.hh; sourceTree = "<group>"; };
4083FCAE2BA3B8B00061509D /* CBLVectorIndexConfig_CAPI.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLVectorIndexConfig_CAPI.cc; sourceTree = "<group>"; };
4083FCB62BA3F6930061509D /* CBLPrediction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLPrediction.h; sourceTree = "<group>"; };
Expand All @@ -479,6 +487,12 @@
40E7CA632BFE7336004BE7E1 /* ContextManager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContextManager.cc; sourceTree = "<group>"; };
40E7CA722BFE7336004BE7E1 /* ContextManager.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ContextManager.hh; sourceTree = "<group>"; };
40F902C82B9F7AF6002EA0A0 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
40FE2DC22C08245E005E99E9 /* CBLQueryIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLQueryIndex.h; sourceTree = "<group>"; };
40FE2DD52C092578005E99E9 /* CBLQueryIndex_CAPI.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLQueryIndex_CAPI.cc; sourceTree = "<group>"; };
40FE2DD72C0926FF005E99E9 /* CBLQueryIndex.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLQueryIndex.cc; sourceTree = "<group>"; };
40FE2DD82C0926FF005E99E9 /* CBLQueryIndex_Internal.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CBLQueryIndex_Internal.hh; sourceTree = "<group>"; };
40FE2DFE2C12AEEB005E99E9 /* LazyVectorIndexTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LazyVectorIndexTest.cc; sourceTree = "<group>"; };
40FE2E0F2C12AF52005E99E9 /* VectorSearchTest.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = VectorSearchTest.hh; sourceTree = "<group>"; };
42D1B68F2978AD31003B9871 /* CBLUserAgent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CBLUserAgent.mm; sourceTree = "<group>"; };
932062DA26BC6B43006917A5 /* CBLQuery.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLQuery.cc; sourceTree = "<group>"; };
9320630126BDB340006917A5 /* CBLPlatform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLPlatform.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -649,6 +663,9 @@
9320630126BDB340006917A5 /* CBLPlatform.h */,
4083FCB62BA3F6930061509D /* CBLPrediction.h */,
271C2A3021CAC98F0045856E /* CBLQuery.h */,
406F8D6F2C17E191000223FC /* CBLQueryTypes.h */,
40FE2DC22C08245E005E99E9 /* CBLQueryIndex.h */,
406F8D802C17E3B4000223FC /* CBLQueryIndexTypes.h */,
271C2A2C21CAC98F0045856E /* CBLReplicator.h */,
FCD829B12835ECE0004AA814 /* CBLScope.h */,
271C2A7021CAD6440045856E /* CBL_Compat.h */,
Expand Down Expand Up @@ -676,6 +693,8 @@
4083FCC12BAA38F30061509D /* CBLPrediction.cc */,
932062DA26BC6B43006917A5 /* CBLQuery.cc */,
27DBCF2E246B4352002FD7A7 /* CBLQuery_Internal.hh */,
40FE2DD72C0926FF005E99E9 /* CBLQueryIndex.cc */,
40FE2DD82C0926FF005E99E9 /* CBLQueryIndex_Internal.hh */,
4083FC9F2BA3A4390061509D /* CBLVectorIndexConfig.hh */,
27D11BFF235140E300C58A70 /* CBLReplicator_Internal.hh */,
FCC063C828588DA6000C5BD7 /* CBLScope.cc */,
Expand Down Expand Up @@ -751,6 +770,7 @@
9320631126BDB5CA006917A5 /* CBLPlatform_CAPI+Android.cc */,
4083FCBB2BA8DE200061509D /* CBLPrediction_CAPI.cc */,
27B61D5521D5ABA60027CCDB /* CBLQuery_CAPI.cc */,
40FE2DD52C092578005E99E9 /* CBLQueryIndex_CAPI.cc */,
277FEE7421ED3C4900B60E3C /* CBLReplicator_CAPI.cc */,
FCD829B22835EE39004AA814 /* CBLScope_CAPI.cc */,
4083FCAE2BA3B8B00061509D /* CBLVectorIndexConfig_CAPI.cc */,
Expand Down Expand Up @@ -801,7 +821,9 @@
FC82CE0428C6E2BD001FA083 /* ReplicatorCollectionTest_Cpp.cc */,
2736A633242E5A74002B9D65 /* ReplicatorEETest.cc */,
93C70D1626CB334D0093E927 /* ReplicatorPropEncTest.cc */,
40FE2E0F2C12AF52005E99E9 /* VectorSearchTest.hh */,
406E46D22BACAEFF0088198C /* VectorSearchTest.cc */,
40FE2DFE2C12AEEB005E99E9 /* LazyVectorIndexTest.cc */,
27D30F9123A2D30500392107 /* PerfTest.cc */,
275B3597234C158400FE9CF0 /* CouchbaseLiteTests.mm */,
27DBCF41246B81EE002FD7A7 /* LibC++Debug.cc */,
Expand Down Expand Up @@ -910,6 +932,8 @@
9320630F26BDB408006917A5 /* CBLPlatform.h in Headers */,
4083FCB02BA3B8C50061509D /* CBLVectorIndexConfig.hh in Headers */,
27DBCF2F246B4352002FD7A7 /* CBLQuery_Internal.hh in Headers */,
40FE2DD12C082465005E99E9 /* CBLQueryIndex.h in Headers */,
40FE2DDA2C0926FF005E99E9 /* CBLQueryIndex_Internal.hh in Headers */,
27D11BEF2351043B00C58A70 /* ConflictResolver.hh in Headers */,
FC5FBBA62821B3450066157F /* CBLCollection_Internal.hh in Headers */,
93C70CE026C4D3F80093E927 /* CBLEncryptable.h in Headers */,
Expand Down Expand Up @@ -954,6 +978,7 @@
27984E312249A247000FE777 /* CouchbaseLite.hh in Headers */,
9320631026BDB409006917A5 /* CBLPlatform.h in Headers */,
27984E322249A247000FE777 /* Base.hh in Headers */,
40FE2DD22C082466005E99E9 /* CBLQueryIndex.h in Headers */,
93C70CE126C4D3F90093E927 /* CBLEncryptable.h in Headers */,
27984E332249A247000FE777 /* Blob.hh in Headers */,
27984E342249A247000FE777 /* Database.hh in Headers */,
Expand Down Expand Up @@ -1526,6 +1551,7 @@
93C70CE326C5B4BC0093E927 /* CBLEncryptable_CAPI.cc in Sources */,
42D1B69D2978AD31003B9871 /* CBLUserAgent.mm in Sources */,
277B77D5245B44E900B222D3 /* CBLLog.cc in Sources */,
40FE2DD92C0926FF005E99E9 /* CBLQueryIndex.cc in Sources */,
271C2A7221CADB170045856E /* CBLDatabase.cc in Sources */,
276633A62602815000B9BD36 /* CBLDatabase_CAPI.cc in Sources */,
27DBD098246C9DE7002FD7A7 /* CBLDatabase+Apple.mm in Sources */,
Expand All @@ -1543,6 +1569,7 @@
27886C8E21F64C1400069BEA /* Listener.cc in Sources */,
FCB96E8329007D37001C4DED /* CBLDefaults_CAPI.cc in Sources */,
4083FCC22BAA38F30061509D /* CBLPrediction.cc in Sources */,
40FE2DD62C092578005E99E9 /* CBLQueryIndex_CAPI.cc in Sources */,
271C2A7621CC4BD60045856E /* Internal.cc in Sources */,
FCC063C928588DA6000C5BD7 /* CBLScope.cc in Sources */,
FC5FBBA52821B3450066157F /* CBLCollection.cc in Sources */,
Expand Down Expand Up @@ -1600,6 +1627,7 @@
275B3594234BDB2700FE9CF0 /* CBLTestsMain.cpp in Sources */,
27C9B5F321F7EE670040BC45 /* CBLTest.c in Sources */,
FCC06403285BCAC9000C5BD7 /* DocumentTest.cc in Sources */,
40FE2E0E2C12AEF6005E99E9 /* LazyVectorIndexTest.cc in Sources */,
27B61DAF21D6E4B70027CCDB /* CBLTest.cc in Sources */,
FCD8298C283591D4004AA814 /* CollectionTest.cc in Sources */,
FC645E2D29088211007D5536 /* Platform_Apple.mm in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ set(
src/CBLPrediction.cc
src/CBLPrediction_CAPI.cc
src/CBLQuery.cc
src/CBLQueryIndex.cc
src/CBLQuery_CAPI.cc
src/CBLQueryIndex_CAPI.cc
src/CBLReplicator_CAPI.cc
src/CBLScope.cc
src/CBLScope_CAPI.cc
Expand Down
13 changes: 11 additions & 2 deletions include/cbl/CBLBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

CBL_CAPI_BEGIN

// #define COUCHBASE_ENTERPRISE 1

/** \defgroup errors Errors
@{
Types and constants for communicating errors from API calls. */
Expand Down Expand Up @@ -220,6 +218,17 @@ typedef struct CBLQuery CBLQuery;
typedef struct CBLResultSet CBLResultSet;
/** @} */

/** \defgroup indexes Indexes
@{ */
/** A query index. */
typedef struct CBLQueryIndex CBLQueryIndex;

#ifdef COUCHBASE_ENTERPRISE
typedef struct CBLIndexUpdater CBLIndexUpdater;
#endif

/** @} */

/** \defgroup replication Replication
@{ */
/** A background task that syncs a \ref CBLDatabase with a remote server or peer. */
Expand Down
14 changes: 13 additions & 1 deletion include/cbl/CBLCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#pragma once
#include "CBLBase.h"
#include "CBLDocument.h"
#include "CBLQuery.h"
#include "CBLQueryTypes.h"
#include "CBLQueryIndexTypes.h"

CBL_CAPI_BEGIN

Expand Down Expand Up @@ -413,6 +414,17 @@ _cbl_warn_unused
FLMutableArray _cbl_nullable CBLCollection_GetIndexNames(CBLCollection *collection,
CBLError* _cbl_nullable outError) CBLAPI;

/** Returns an index object representing an existing index in the collection.
@note You are responsible for releasing the returned index object.
@param collection The collection.
@param name The name of the index.
@param outError On failure, an error is written here.
@return A \ref CBLQueryIndex instance if the index exists, or NULL if the index doesn't exist or an error occurred. */
_cbl_warn_unused
CBLQueryIndex* _cbl_nullable CBLCollection_GetIndex(CBLCollection* collection,
FLString name,
CBLError* _cbl_nullable outError) CBLAPI;

/** @} */

/** \name Change Listeners
Expand Down
41 changes: 40 additions & 1 deletion include/cbl/CBLDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once
#include "CBLBase.h"
#include "CBLQueryIndexTypes.h"

CBL_CAPI_BEGIN

Expand Down Expand Up @@ -228,7 +229,6 @@ bool CBLDatabase_PerformMaintenance(CBLDatabase* db,

/** @} */


#ifdef __APPLE__
#pragma mark - ACCESSORS
#endif
Expand All @@ -253,6 +253,45 @@ const CBLDatabaseConfiguration CBLDatabase_Config(const CBLDatabase*) CBLAPI;

/** @} */

/** \name Query Indexes
@{
Query Index Management
*/

/** Creates a value index.
Indexes are persistent.
If an identical index with that name already exists, nothing happens (and no error is returned.)
If a non-identical index with that name already exists, it is deleted and re-created.
@warning <b>Deprecated :</b> Use CBLCollection_CreateValueIndex on the default collection instead. */
bool CBLDatabase_CreateValueIndex(CBLDatabase *db,
FLString name,
CBLValueIndexConfiguration config,
CBLError* _cbl_nullable outError) CBLAPI;

/** Creates a full-text index.
Indexes are persistent.
If an identical index with that name already exists, nothing happens (and no error is returned.)
If a non-identical index with that name already exists, it is deleted and re-created.
@warning <b>Deprecated :</b> Use CBLCollection_CreateFullTextIndex on the default collection instead. */
bool CBLDatabase_CreateFullTextIndex(CBLDatabase *db,
FLString name,
CBLFullTextIndexConfiguration config,
CBLError* _cbl_nullable outError) CBLAPI;

/** Deletes an index given its name.
@warning <b>Deprecated :</b> Use CBLCollection_DeleteIndex on the default collection instead. */
bool CBLDatabase_DeleteIndex(CBLDatabase *db,
FLString name,
CBLError* _cbl_nullable outError) CBLAPI;

/** Returns the names of the indexes on this database, as a Fleece array of strings.
@note You are responsible for releasing the returned Fleece array.
@warning <b>Deprecated :</b> Use CBLCollection_GetIndexNames on the default collection instead. */
_cbl_warn_unused
FLArray CBLDatabase_GetIndexNames(CBLDatabase *db) CBLAPI;


/** @} */

#ifdef __APPLE__
#pragma mark - LISTENERS
Expand Down
Loading

0 comments on commit 172b003

Please sign in to comment.