Skip to content

Commit

Permalink
Add internal IsTrained API in service of testing
Browse files Browse the repository at this point in the history
  • Loading branch information
borrrden committed Jun 18, 2024
1 parent e8c42c8 commit 831da36
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
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

0 comments on commit 831da36

Please sign in to comment.