]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/AbstractWalFilter.java
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / AbstractWalFilter.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 * Base class for WAL Filters.
10 */
11 public abstract class AbstractWalFilter
12 extends RocksCallbackObject implements WalFilter {
13
14 @Override
15 protected long initializeNative(final long... nativeParameterHandles) {
16 return createNewWalFilter();
17 }
18
19 /**
20 * Called from JNI, proxy for
21 * {@link WalFilter#logRecordFound(long, String, WriteBatch, WriteBatch)}.
22 *
23 * @param logNumber the log handle.
24 * @param logFileName the log file name
25 * @param batchHandle the native handle of a WriteBatch (which we do not own)
26 * @param newBatchHandle the native handle of a
27 * new WriteBatch (which we do not own)
28 *
29 * @return short (2 bytes) where the first byte is the
30 * {@link WalFilter.LogRecordFoundResult#walProcessingOption}
31 * {@link WalFilter.LogRecordFoundResult#batchChanged}.
32 */
33 private short logRecordFoundProxy(final long logNumber,
34 final String logFileName, final long batchHandle,
35 final long newBatchHandle) {
36 final LogRecordFoundResult logRecordFoundResult = logRecordFound(
37 logNumber, logFileName, new WriteBatch(batchHandle),
38 new WriteBatch(newBatchHandle));
39 return logRecordFoundResultToShort(logRecordFoundResult);
40 }
41
42 private static short logRecordFoundResultToShort(
43 final LogRecordFoundResult logRecordFoundResult) {
44 short result = (short)(logRecordFoundResult.walProcessingOption.getValue() << 8);
45 return (short)(result | (logRecordFoundResult.batchChanged ? 1 : 0));
46 }
47
48 private native long createNewWalFilter();
49 }