From cbd8fd230ccae9d5ab6e13922fc14cab6c4f5f18 Mon Sep 17 00:00:00 2001 From: Kirill Abrosimov Date: Fri, 26 Jul 2019 11:45:02 +0300 Subject: [PATCH 1/4] added NewNoopPrefixTransform --- slice_transform.go | 5 +++++ slice_transform_test.go | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/slice_transform.go b/slice_transform.go index e66e4d84..67bd0b25 100644 --- a/slice_transform.go +++ b/slice_transform.go @@ -23,6 +23,11 @@ func NewFixedPrefixTransform(prefixLen int) SliceTransform { return NewNativeSliceTransform(C.rocksdb_slicetransform_create_fixed_prefix(C.size_t(prefixLen))) } +// NewNoopPrefixTransform creates a new no-op prefix transform. +func NewNoopPrefixTransform() SliceTransform { + return NewNativeSliceTransform(C.rocksdb_slicetransform_create_noop()) +} + // NewNativeSliceTransform creates a SliceTransform object. func NewNativeSliceTransform(c *C.rocksdb_slicetransform_t) SliceTransform { return nativeSliceTransform{c} diff --git a/slice_transform_test.go b/slice_transform_test.go index 1c551183..d60c7326 100644 --- a/slice_transform_test.go +++ b/slice_transform_test.go @@ -35,6 +35,13 @@ func TestFixedPrefixTransformOpen(t *testing.T) { defer db.Close() } +func TestNewNoopPrefixTransform(t *testing.T) { + db := newTestDB(t, "TestNewNoopPrefixTransform", func(opts *Options) { + opts.SetPrefixExtractor(NewNoopPrefixTransform()) + }) + defer db.Close() +} + type testSliceTransform struct { initiated bool } From 66c8e724b220eda4721e7c0efe62d0d8127c1c2a Mon Sep 17 00:00:00 2001 From: Kirill Abrosimov Date: Fri, 26 Jul 2019 11:47:05 +0300 Subject: [PATCH 2/4] added SetMemTablePrefixBloomSizeRatio() --- options.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/options.go b/options.go index 586e1f04..c1a22251 100644 --- a/options.go +++ b/options.go @@ -1166,6 +1166,17 @@ func (opts *Options) SetAllowIngestBehind(value bool) { C.rocksdb_options_set_allow_ingest_behind(opts.c, boolToChar(value)) } +// SetMemTablePrefixBloomSizeRatio sets memtable_prefix_bloom_size_ratio +// if prefix_extractor is set and memtable_prefix_bloom_size_ratio is not 0, +// create prefix bloom for memtable with the size of +// write_buffer_size * memtable_prefix_bloom_size_ratio. +// If it is larger than 0.25, it is sanitized to 0.25. +// +// Default: 0 (disable) +func (opts *Options) SetMemTablePrefixBloomSizeRatio(value float64) { + C.rocksdb_options_set_memtable_prefix_bloom_size_ratio(opts.c, C.double(value)) +} + // Destroy deallocates the Options object. func (opts *Options) Destroy() { C.rocksdb_options_destroy(opts.c) From c59f9365e2619083ee79f100e16f9c273a24170c Mon Sep 17 00:00:00 2001 From: Kirill Abrosimov Date: Fri, 26 Jul 2019 11:59:18 +0300 Subject: [PATCH 3/4] added SetOptimizeFiltersForHits() --- options.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/options.go b/options.go index c1a22251..1947aa0a 100644 --- a/options.go +++ b/options.go @@ -1177,6 +1177,25 @@ func (opts *Options) SetMemTablePrefixBloomSizeRatio(value float64) { C.rocksdb_options_set_memtable_prefix_bloom_size_ratio(opts.c, C.double(value)) } +// SetOptimizeFiltersForHits sets optimize_filters_for_hits +// This flag specifies that the implementation should optimize the filters +// mainly for cases where keys are found rather than also optimize for keys +// missed. This would be used in cases where the application knows that +// there are very few misses or the performance in the case of misses is not +// important. +// +// For now, this flag allows us to not store filters for the last level i.e +// the largest level which contains data of the LSM store. For keys which +// are hits, the filters in this level are not useful because we will search +// for the data anyway. NOTE: the filters in other levels are still useful +// even for key hit because they tell us whether to look in that level or go +// to the higher level. +// +// Default: false +func (opts *Options) SetOptimizeFiltersForHits(value bool) { + C.rocksdb_options_set_optimize_filters_for_hits(opts.c, C.boolToChar(value)) +} + // Destroy deallocates the Options object. func (opts *Options) Destroy() { C.rocksdb_options_destroy(opts.c) From 616329e3fa8aeddb6c4020e92eed50c8f01d3ada Mon Sep 17 00:00:00 2001 From: Kirill Abrosimov Date: Fri, 26 Jul 2019 12:05:04 +0300 Subject: [PATCH 4/4] fix build --- options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options.go b/options.go index 1947aa0a..d27e84f1 100644 --- a/options.go +++ b/options.go @@ -1193,7 +1193,7 @@ func (opts *Options) SetMemTablePrefixBloomSizeRatio(value float64) { // // Default: false func (opts *Options) SetOptimizeFiltersForHits(value bool) { - C.rocksdb_options_set_optimize_filters_for_hits(opts.c, C.boolToChar(value)) + C.rocksdb_options_set_optimize_filters_for_hits(opts.c, C.int(btoi(value))) } // Destroy deallocates the Options object.