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 // This file implements the callback "bridge" between Java and C++ for
7 // ROCKSDB_NAMESPACE::WalFilter.
8 
9 #ifndef JAVA_ROCKSJNI_WAL_FILTER_JNICALLBACK_H_
10 #define JAVA_ROCKSJNI_WAL_FILTER_JNICALLBACK_H_
11 
12 #include <jni.h>
13 #include <map>
14 #include <memory>
15 #include <string>
16 
17 #include "rocksdb/wal_filter.h"
18 #include "rocksjni/jnicallback.h"
19 
20 namespace ROCKSDB_NAMESPACE {
21 
22 class WalFilterJniCallback : public JniCallback, public WalFilter {
23  public:
24     WalFilterJniCallback(
25         JNIEnv* env, jobject jwal_filter);
26     virtual void ColumnFamilyLogNumberMap(
27         const std::map<uint32_t, uint64_t>& cf_lognumber_map,
28         const std::map<std::string, uint32_t>& cf_name_id_map);
29     virtual WalFilter::WalProcessingOption LogRecordFound(
30         unsigned long long log_number, const std::string& log_file_name,
31         const WriteBatch& batch, WriteBatch* new_batch, bool* batch_changed);
32     virtual const char* Name() const;
33 
34  private:
35     std::unique_ptr<const char[]> m_name;
36     jmethodID m_column_family_log_number_map_mid;
37     jmethodID m_log_record_found_proxy_mid;
38 };
39 
40 }  // namespace ROCKSDB_NAMESPACE
41 
42 #endif  // JAVA_ROCKSJNI_WAL_FILTER_JNICALLBACK_H_
43