Skip to content

Commit

Permalink
Update Core to 2.19. (#364)
Browse files Browse the repository at this point in the history
* Regenerate bindings for 2.19.

* Bump Core to 2.19.0.

* Run nightly builds on release-2.19.

* Bump version to 5.9.0.

* Update the Group class to use the new C APIs.

And expose `tiledb_group_get_member_by_name_v2`.

* Make the group member APIs public (they weren't) and add tests for them.
  • Loading branch information
teo-tsirpanis authored Jan 12, 2024
1 parent d676140 commit 733aaba
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
platform: windows-x86_64
BOOTSTRAP: ../bootstrap.ps1 -EnableS3 -EnableSerialization -EnableVcpkg
- tag: dev
tag: [release-2.18, dev]
tag: [release-2.19, dev]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout TileDB
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tag: [release-2.18, dev]
tag: [release-2.19, dev]
runs-on: ubuntu-latest
steps:
- name: Checkout TileDB-CSharp
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
tag: [release-2.18, dev]
tag: [release-2.19, dev]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout TileDB-CSharp
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TileDBNativePackageName>TileDB.Native</TileDBNativePackageName>
<TileDBNativePackageVersion>[2.18.0,2.19.0)</TileDBNativePackageVersion>
<TileDBNativePackageVersion>[2.19.0,2.20.0)</TileDBNativePackageVersion>

<!-- The DevelopmentBuild property switches to the locally built native packages.
They have a different name to avoid publishing them by mistake, and to
Expand Down
36 changes: 27 additions & 9 deletions sources/TileDB.CSharp/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using TileDB.Interop;
using GroupHandle = TileDB.CSharp.Marshalling.SafeHandles.GroupHandle;
using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle;
using TileDB.CSharp.Marshalling;

namespace TileDB.CSharp;

Expand Down Expand Up @@ -278,23 +279,40 @@ public ulong MemberCount()
/// <summary>
/// Get member by index.
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
(string uri, ObjectType object_type, string name) MemberByIndex(ulong index)
/// <param name="index">The member's index.</param>
public (string Uri, ObjectType ObjectType, string Name) GetMemberByIndex(ulong index)
{
using var ctxHandle = _ctx.Handle.Acquire();
using var handle = _handle.Acquire();
sbyte* uriPtr;
sbyte* namePtr;
using StringHandleHolder uriPtr = new();
using StringHandleHolder namePtr = new();
tiledb_object_t tiledb_objecttype;
_ctx.handle_error(Methods.tiledb_group_get_member_by_index(
ctxHandle, handle, index, &uriPtr, &tiledb_objecttype, &namePtr));
_ctx.handle_error(Methods.tiledb_group_get_member_by_index_v2(
ctxHandle, handle, index, &uriPtr._handle, &tiledb_objecttype, &namePtr._handle));

string uri = MarshaledStringOut.GetStringFromNullTerminated(uriPtr);
string name = MarshaledStringOut.GetStringFromNullTerminated(namePtr);
string uri = uriPtr.ToString();
string name = namePtr.ToString();
return (uri, (ObjectType)tiledb_objecttype, name);
}

/// <summary>
/// Get member by name.
/// </summary>
/// <param name="name">The member's name.</param>
public (string Uri, ObjectType ObjectType) GetMemberByName(string name)
{
using var ctxHandle = _ctx.Handle.Acquire();
using var handle = _handle.Acquire();
using var ms_name = new MarshaledString(name);
using StringHandleHolder uriPtr = new();
tiledb_object_t tiledb_objecttype;
_ctx.handle_error(Methods.tiledb_group_get_member_by_name_v2(
ctxHandle, handle, ms_name, &uriPtr._handle, &tiledb_objecttype));

string uri = uriPtr.ToString();
return (uri, (ObjectType)tiledb_objecttype);
}

/// <summary>
/// Returns if this group is open or not.
/// </summary>
Expand Down
11 changes: 10 additions & 1 deletion sources/TileDB.CSharp/Interop/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ public static int tiledb_status([NativeTypeName("capi_return_t")] int x)

[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
[Obsolete]
public static extern int tiledb_group_create(tiledb_ctx_t* ctx, [NativeTypeName("const char *")] sbyte* group_uri);

[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
Expand Down Expand Up @@ -1417,12 +1416,22 @@ public static int tiledb_status([NativeTypeName("capi_return_t")] int x)

[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
[Obsolete]
public static extern int tiledb_group_get_member_by_index(tiledb_ctx_t* ctx, tiledb_group_t* group, [NativeTypeName("uint64_t")] ulong index, [NativeTypeName("char **")] sbyte** uri, tiledb_object_t* type, [NativeTypeName("char **")] sbyte** name);

[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
public static extern int tiledb_group_get_member_by_index_v2(tiledb_ctx_t* ctx, tiledb_group_t* group, [NativeTypeName("uint64_t")] ulong index, tiledb_string_t** uri, tiledb_object_t* type, tiledb_string_t** name);

[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
[Obsolete]
public static extern int tiledb_group_get_member_by_name(tiledb_ctx_t* ctx, tiledb_group_t* group, [NativeTypeName("const char *")] sbyte* name, [NativeTypeName("char **")] sbyte** uri, tiledb_object_t* type);

[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
public static extern int tiledb_group_get_member_by_name_v2(tiledb_ctx_t* ctx, tiledb_group_t* group, [NativeTypeName("const char *")] sbyte* name, tiledb_string_t** uri, tiledb_object_t* type);

[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
public static extern int tiledb_group_get_is_relative_uri_by_name(tiledb_ctx_t* ctx, tiledb_group_t* group, [NativeTypeName("const char *")] sbyte* name, [NativeTypeName("uint8_t *")] byte* relative);
Expand Down
4 changes: 2 additions & 2 deletions sources/TileDB.CSharp/TileDB.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<RootNamespace>TileDB.CSharp</RootNamespace>
<Version>5.8.0</Version>
<Version>5.9.0</Version>
<Description>C# wrapper of the TileDB Embedded universal data engine.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<EnablePackageValidation>true</EnablePackageValidation>
<PackageValidationBaselineVersion>5.7.0</PackageValidationBaselineVersion>
<PackageValidationBaselineVersion>5.8.0</PackageValidationBaselineVersion>
<NoWarn>$(NoWarn);TILEDB0012;TILEDB0013;TILEDB0014</NoWarn>
</PropertyGroup>

Expand Down
2 changes: 2 additions & 0 deletions tests/TileDB.CSharp.Test/GroupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void TestGroupMember()
//Reopen in read mode
group1.Open(QueryType.Read);
Assert.AreEqual<ulong>(2, group1.MemberCount());
Assert.AreEqual("array1", group1.GetMemberByIndex(0).Name);
Assert.AreEqual(ObjectType.Array, group1.GetMemberByName("array2").ObjectType);
group1.Close();

//Reopen in write mode
Expand Down

0 comments on commit 733aaba

Please sign in to comment.