(Note, I'd be willing to contribute these implementations if the project is interested in accepting them)
// TryListColumnFamilies can be implemented by RocksDbSharp users, but it would be nice if it was built in
private static bool TryListColumnFamilies(DbOptions options, string name, [MaybeNullWhen(false)] out string[] strings)
{
var result = Native.Instance.rocksdb_list_column_families(options.Handle, name, out UIntPtr lencf, out IntPtr errptr);
if (errptr != IntPtr.Zero)
{
strings = null!;
return false;
}
try
{
IntPtr[] ptrs = new IntPtr[(ulong)lencf];
Marshal.Copy(result, ptrs, 0, (int)lencf);
strings = new string[(ulong)lencf];
for (ulong i = 0; i < (ulong)lencf; i++)
strings[i] = Marshal.PtrToStringAnsi(ptrs[i]) ?? throw new Exception("Marshal.PtrToStringAnsi failed");
return true;
}
finally
{
Native.Instance.rocksdb_list_column_families_destroy(result, lencf);
}
}
Suggestions:
(Note, I'd be willing to contribute these implementations if the project is interested in accepting them)
Other