1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
9 * Each compaction will create a new {@link AbstractCompactionFilter}
10 * allowing the application to know about different compactions
12 * @param <T> The concrete type of the compaction filter
14 public abstract class AbstractCompactionFilterFactory
<T
extends AbstractCompactionFilter
<?
>>
15 extends RocksCallbackObject
{
17 public AbstractCompactionFilterFactory() {
22 protected long initializeNative(final long... nativeParameterHandles
) {
23 return createNewCompactionFilterFactory0();
27 * Called from JNI, see compaction_filter_factory_jnicallback.cc
29 * @param fullCompaction {@link AbstractCompactionFilter.Context#fullCompaction}
30 * @param manualCompaction {@link AbstractCompactionFilter.Context#manualCompaction}
32 * @return native handle of the CompactionFilter
34 private long createCompactionFilter(final boolean fullCompaction
,
35 final boolean manualCompaction
) {
36 final T filter
= createCompactionFilter(
37 new AbstractCompactionFilter
.Context(fullCompaction
, manualCompaction
));
39 // CompactionFilterFactory::CreateCompactionFilter returns a std::unique_ptr
40 // which therefore has ownership of the underlying native object
41 filter
.disOwnNativeHandle();
43 return filter
.nativeHandle_
;
47 * Create a new compaction filter
49 * @param context The context describing the need for a new compaction filter
51 * @return A new instance of {@link AbstractCompactionFilter}
53 public abstract T
createCompactionFilter(
54 final AbstractCompactionFilter
.Context context
);
57 * A name which identifies this compaction filter
59 * The name will be printed to the LOG file on start up for diagnosis
61 public abstract String
name();
64 * We override {@link RocksCallbackObject#disposeInternal()}
65 * as disposing of a rocksdb::AbstractCompactionFilterFactory requires
66 * a slightly different approach as it is a std::shared_ptr
69 protected void disposeInternal() {
70 disposeInternal(nativeHandle_
);
73 private native long createNewCompactionFilterFactory0();
74 private native void disposeInternal(final long handle
);