From 92024078af0563d82641814ce82d1ce408225d84 Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Fri, 19 Mar 2021 18:17:25 +0800 Subject: [PATCH] add `FilterPolicy.Destroy`, #132 --- filter_policy.go | 4 ++++ filter_policy_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/filter_policy.go b/filter_policy.go index a9c222b0..2034238c 100644 --- a/filter_policy.go +++ b/filter_policy.go @@ -19,6 +19,9 @@ type FilterPolicy interface { // Return the name of this policy. Name() string + + // Destroy deallocates the policy filter. + Destroy() } // NewNativeFilterPolicy creates a FilterPolicy object. @@ -33,6 +36,7 @@ type nativeFilterPolicy struct { func (fp nativeFilterPolicy) CreateFilter(keys [][]byte) []byte { return nil } func (fp nativeFilterPolicy) KeyMayMatch(key []byte, filter []byte) bool { return false } func (fp nativeFilterPolicy) Name() string { return "" } +func (fp nativeFilterPolicy) Destroy() { C.rocksdb_filterpolicy_destroy(fp.c) } // NewBloomFilter returns a new filter policy that uses a bloom filter with approximately // the specified number of bits per key. A good value for bits_per_key diff --git a/filter_policy_test.go b/filter_policy_test.go index c15aa1b6..d7e0a151 100644 --- a/filter_policy_test.go +++ b/filter_policy_test.go @@ -74,3 +74,4 @@ func (m *mockFilterPolicy) CreateFilter(keys [][]byte) []byte { func (m *mockFilterPolicy) KeyMayMatch(key, filter []byte) bool { return m.keyMayMatch(key, filter) } +func (m *mockFilterPolicy) Destroy() {}