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 * Base class for WAL Filters.
11 public abstract class AbstractWalFilter
12 extends RocksCallbackObject
implements WalFilter
{
15 protected long initializeNative(final long... nativeParameterHandles
) {
16 return createNewWalFilter();
20 * Called from JNI, proxy for
21 * {@link WalFilter#logRecordFound(long, String, WriteBatch, WriteBatch)}.
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)
29 * @return short (2 bytes) where the first byte is the
30 * {@link WalFilter.LogRecordFoundResult#walProcessingOption}
31 * {@link WalFilter.LogRecordFoundResult#batchChanged}.
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
);
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));
48 private native long createNewWalFilter();