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 BloomFilter to levelDB #253

Merged
merged 12 commits into from
Jul 16, 2020
3 changes: 3 additions & 0 deletions src/LevelDBStore/IO/Data/LevelDB/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public static class Native

[DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern void leveldb_options_set_filter_policy(IntPtr /*Options*/ options, IntPtr /*FilterPolicy*/ policy);

[DllImport("libleveldb", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr leveldb_filterpolicy_create_bloom(int bits_per_key);
#endregion

#region ReadOptions
Expand Down
2 changes: 1 addition & 1 deletion src/LevelDBStore/LevelDBStore/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"PluginConfiguration": {
"Path": "Data_LevelDB_{0}"
}
Expand Down
2 changes: 1 addition & 1 deletion src/LevelDBStore/Plugins/Storage/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class Store : IStore

public Store(string path)
{
this.db = DB.Open(path, new Options { CreateIfMissing = true });
this.db = DB.Open(path, new Options { CreateIfMissing = true, FilterPolicy = Native.leveldb_filterpolicy_create_bloom(15) });
byte[] value = db.Get(ReadOptions.Default, LHelper.CreateKey(SYS_Version));
if (value != null && Version.TryParse(Encoding.ASCII.GetString(value), out Version version) && version >= Version.Parse("3.0.0"))
return;
Expand Down