Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
8f01bf80
R
rocksdb
项目概览
kvdb
/
rocksdb
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rocksdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f01bf80
编写于
10月 17, 2014
作者:
Y
Yueh-Hsuan Chiang
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #353 from fyrz/FixBloomfilterRocksJava
[RocksJava] Filters getting disposed by System.gc before EOL
上级
ee80fb4b
bafbc23b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
13 deletion
+40
-13
java/org/rocksdb/Options.java
java/org/rocksdb/Options.java
+6
-0
java/org/rocksdb/test/FilterTest.java
java/org/rocksdb/test/FilterTest.java
+14
-3
java/rocksjni/filter.cc
java/rocksjni/filter.cc
+11
-5
java/rocksjni/portal.h
java/rocksjni/portal.h
+5
-3
java/rocksjni/table.cc
java/rocksjni/table.cc
+4
-2
未找到文件。
java/org/rocksdb/Options.java
浏览文件 @
8f01bf80
...
...
@@ -1154,6 +1154,7 @@ public class Options extends RocksObject {
*/
public
Options
setMemTableConfig
(
MemTableConfig
config
)
throws
RocksDBException
{
memTableConfig_
=
config
;
setMemTableFactory
(
nativeHandle_
,
config
.
newMemTableFactoryHandle
());
return
this
;
}
...
...
@@ -1168,6 +1169,7 @@ public class Options extends RocksObject {
* @throws RocksDBException
*/
public
Options
setRateLimiterConfig
(
RateLimiterConfig
config
)
{
rateLimiterConfig_
=
config
;
setRateLimiter
(
nativeHandle_
,
config
.
newRateLimiterHandle
());
return
this
;
}
...
...
@@ -1191,6 +1193,7 @@ public class Options extends RocksObject {
* @return the reference of the current Options.
*/
public
Options
setTableFormatConfig
(
TableFormatConfig
config
)
{
tableFormatConfig_
=
config
;
setTableFactory
(
nativeHandle_
,
config
.
newTableFactoryHandle
());
return
this
;
}
...
...
@@ -2280,4 +2283,7 @@ public class Options extends RocksObject {
long
cacheSize_
;
int
numShardBits_
;
RocksEnv
env_
;
MemTableConfig
memTableConfig_
;
TableFormatConfig
tableFormatConfig_
;
RateLimiterConfig
rateLimiterConfig_
;
}
java/org/rocksdb/test/FilterTest.java
浏览文件 @
8f01bf80
...
...
@@ -13,19 +13,30 @@ public class FilterTest {
}
public
static
void
main
(
String
[]
args
)
{
Options
options
=
new
Options
();
// test table config
without filter
// test table config
BlockBasedTableConfig
blockConfig
=
new
BlockBasedTableConfig
();
options
.
setTableFormatConfig
(
blockConfig
);
options
.
setTableFormatConfig
(
new
BlockBasedTableConfig
().
setFilter
(
new
BloomFilter
()));
options
.
dispose
();
System
.
gc
();
System
.
runFinalization
();
// new Bloom filter
options
=
new
Options
();
blockConfig
=
new
BlockBasedTableConfig
();
blockConfig
.
setFilter
(
new
BloomFilter
());
options
.
setTableFormatConfig
(
blockConfig
);
blockConfig
.
setFilter
(
new
BloomFilter
(
10
));
BloomFilter
bloomFilter
=
new
BloomFilter
(
10
);
blockConfig
.
setFilter
(
bloomFilter
);
options
.
setTableFormatConfig
(
blockConfig
);
System
.
gc
();
System
.
runFinalization
();
blockConfig
.
setFilter
(
new
BloomFilter
(
10
,
false
));
options
.
setTableFormatConfig
(
blockConfig
);
options
.
dispose
();
options
=
null
;
blockConfig
=
null
;
System
.
gc
();
System
.
runFinalization
();
System
.
out
.
println
(
"Filter test passed"
);
}
}
java/rocksjni/filter.cc
浏览文件 @
8f01bf80
...
...
@@ -24,9 +24,12 @@
void
Java_org_rocksdb_BloomFilter_createNewBloomFilter
(
JNIEnv
*
env
,
jobject
jobj
,
jint
bits_per_key
,
jboolean
use_block_base_builder
)
{
const
rocksdb
::
FilterPolicy
*
fp
=
rocksdb
::
NewBloomFilterPolicy
(
bits_per_key
,
use_block_base_builder
);
rocksdb
::
FilterJni
::
setHandle
(
env
,
jobj
,
fp
);
rocksdb
::
FilterPolicy
*
fp
=
const_cast
<
rocksdb
::
FilterPolicy
*>
(
rocksdb
::
NewBloomFilterPolicy
(
bits_per_key
,
use_block_base_builder
));
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
*
pFilterPolicy
=
new
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
;
*
pFilterPolicy
=
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
(
fp
);
rocksdb
::
FilterJni
::
setHandle
(
env
,
jobj
,
pFilterPolicy
);
}
/*
...
...
@@ -35,6 +38,9 @@ void Java_org_rocksdb_BloomFilter_createNewBloomFilter(
* Signature: (J)V
*/
void
Java_org_rocksdb_Filter_disposeInternal
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
handle
)
{
delete
reinterpret_cast
<
rocksdb
::
FilterPolicy
*>
(
handle
);
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
*
handle
=
reinterpret_cast
<
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
*>
(
jhandle
);
handle
->
reset
();
}
java/rocksjni/portal.h
浏览文件 @
8f01bf80
...
...
@@ -313,14 +313,16 @@ class FilterJni {
}
// Get the pointer to rocksdb::FilterPolicy.
static
rocksdb
::
FilterPolicy
*
getHandle
(
JNIEnv
*
env
,
jobject
jobj
)
{
return
reinterpret_cast
<
rocksdb
::
FilterPolicy
*>
(
static
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>*
getHandle
(
JNIEnv
*
env
,
jobject
jobj
)
{
return
reinterpret_cast
<
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
*>
(
env
->
GetLongField
(
jobj
,
getHandleFieldID
(
env
)));
}
// Pass the rocksdb::FilterPolicy pointer to the java side.
static
void
setHandle
(
JNIEnv
*
env
,
jobject
jobj
,
const
rocksdb
::
FilterPolicy
*
op
)
{
JNIEnv
*
env
,
jobject
jobj
,
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
*
op
)
{
env
->
SetLongField
(
jobj
,
getHandleFieldID
(
env
),
reinterpret_cast
<
jlong
>
(
op
));
...
...
java/rocksjni/table.cc
浏览文件 @
8f01bf80
...
...
@@ -56,8 +56,10 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
options
.
block_restart_interval
=
block_restart_interval
;
options
.
whole_key_filtering
=
whole_key_filtering
;
if
(
jfilterPolicy
>
0
)
{
options
.
filter_policy
.
reset
(
reinterpret_cast
<
rocksdb
::
FilterPolicy
*>
(
jfilterPolicy
));
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
*
pFilterPolicy
=
reinterpret_cast
<
std
::
shared_ptr
<
rocksdb
::
FilterPolicy
>
*>
(
jfilterPolicy
);
options
.
filter_policy
=
*
pFilterPolicy
;
}
options
.
cache_index_and_filter_blocks
=
cache_index_and_filter_blocks
;
options
.
hash_index_allow_collision
=
hash_index_allow_collision
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录