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() {}