]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/AbstractCompactionFilterFactory.java
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / AbstractCompactionFilterFactory.java
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).
5
6 package org.rocksdb;
7
8 /**
9 * Each compaction will create a new {@link AbstractCompactionFilter}
10 * allowing the application to know about different compactions
11 *
12 * @param <T> The concrete type of the compaction filter
13 */
14 public abstract class AbstractCompactionFilterFactory<T extends AbstractCompactionFilter<?>>
15 extends RocksCallbackObject {
16
17 public AbstractCompactionFilterFactory() {
18 super(null);
19 }
20
21 @Override
22 protected long initializeNative(final long... nativeParameterHandles) {
23 return createNewCompactionFilterFactory0();
24 }
25
26 /**
27 * Called from JNI, see compaction_filter_factory_jnicallback.cc
28 *
29 * @param fullCompaction {@link AbstractCompactionFilter.Context#fullCompaction}
30 * @param manualCompaction {@link AbstractCompactionFilter.Context#manualCompaction}
31 *
32 * @return native handle of the CompactionFilter
33 */
34 private long createCompactionFilter(final boolean fullCompaction,
35 final boolean manualCompaction) {
36 final T filter = createCompactionFilter(
37 new AbstractCompactionFilter.Context(fullCompaction, manualCompaction));
38
39 // CompactionFilterFactory::CreateCompactionFilter returns a std::unique_ptr
40 // which therefore has ownership of the underlying native object
41 filter.disOwnNativeHandle();
42
43 return filter.nativeHandle_;
44 }
45
46 /**
47 * Create a new compaction filter
48 *
49 * @param context The context describing the need for a new compaction filter
50 *
51 * @return A new instance of {@link AbstractCompactionFilter}
52 */
53 public abstract T createCompactionFilter(
54 final AbstractCompactionFilter.Context context);
55
56 /**
57 * A name which identifies this compaction filter
58 *
59 * The name will be printed to the LOG file on start up for diagnosis
60 */
61 public abstract String name();
62
63 /**
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
67 */
68 @Override
69 protected void disposeInternal() {
70 disposeInternal(nativeHandle_);
71 }
72
73 private native long createNewCompactionFilterFactory0();
74 private native void disposeInternal(final long handle);
75 }