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

Add internal IsTrained API in service of testing #1630

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Couchbase.Lite.Shared/API/Database/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ private void Save(Document doc, C4Document** outDoc, C4Document* baseDoc, bool d

#region Internal Methods

internal bool IsIndexTrained(string name) => LiteCoreBridge.Check(err => Native.c4coll_isIndexTrained(c4coll, name, err));

/// <summary>
/// Returns false if this collection has been deleted, or its database closed.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/LiteCore/binding_list/c4.def
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ c4coll_getDocExpiration
c4coll_createIndex
c4coll_deleteIndex
c4coll_getIndexesInfo
c4coll_isIndexTrained

c4db_copyNamed
c4db_deleteNamed
Expand Down
48 changes: 48 additions & 0 deletions src/LiteCore/src/LiteCore.Shared/Interop/C4Index_native.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// C4Index_native.cs
//
// 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:https://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.
//

using System;
using System.Linq;
using System.Runtime.InteropServices;

using LiteCore.Util;

namespace LiteCore.Interop
{

internal unsafe static partial class Native
{
public static bool c4coll_isIndexTrained(C4Collection* collection, string? name, C4Error* outError)
{
using(var name_ = new C4String(name)) {
return NativeRaw.c4coll_isIndexTrained(collection, name_.AsFLSlice(), outError);
}
}


}

internal unsafe static partial class NativeRaw
{
[DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool c4coll_isIndexTrained(C4Collection* collection, FLSlice name, C4Error* outError);


}
}
1 change: 1 addition & 0 deletions src/LiteCore/src/LiteCore.Shared/LiteCore.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Interop\C4Error_defs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\C4Error_native.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\C4IndexTypes_defs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\C4Index_native.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\C4Listener.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\C4ListenerTypes_defs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\C4Listener_native.cs" />
Expand Down