curiosity-ai / rocksdb-sharp

.net bindings for the rocksdb by facebook
BSD 2-Clause "Simplified" License
155 stars 38 forks source link

Question: Exception when setting merge operator #42

Closed yoonsanghyeuk closed 9 months ago

yoonsanghyeuk commented 1 year ago

When i set merge operator using MergeOperators.Create below exception is occurred. And i don't know this is my fault or not.

Unhandled exception. System.ArgumentException: The specified Type must not be a generic type. (Parameter 'delegate')
   at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegateInternal(Delegate d)
   at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(Delegate d)
   at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate[TDelegate](TDelegate d)
   at Transitional.CurrentFramework.GetFunctionPointerForDelegate[T](T func)
   at RocksDbSharp.Options`1.SetMergeOperator(MergeOperator mergeOperator)
   at HeatmapReader.ReadInferenceList() in /home/yoon/Develop/dotnet_heatmap/HeatmapReader.cs:line 67
   at HeatmapReaderSample.Main(String[] args) in /home/yoon/Develop/dotnet_heatmap/Program.cs:line 269

Merge operator for test

public byte[] EmptyMerge(ReadOnlySpan<byte> key, MergeOperators.OperandsEnumerator operands, out bool success)
{
  success = true;
  return new byte[0];
}

And column family option

var cfOptions = new ColumnFamilyOptions();
cfOptions.SetMergeOperator(MergeOperators.Create(
  name: "test",
  partialMerge: EmptyMerge,
  fullMerge: null
));

var cfs = new ColumnFamilies();
cfs.Add("inf_cf", cfOptions);
yoonsanghyeuk commented 1 year ago

Append more information. dotnet version is 6 and rocksdbsharp version is 8.1.1.38086 And i opened db as secondary.