Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
2e0d4321
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,发现更多精彩内容 >>
提交
2e0d4321
编写于
4月 08, 2014
作者:
Y
Yueh-Hsuan Chiang
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #110 from ankgup87/jni
[JNI] Add JNI bindings for rocksdb Options
上级
3699fda6
8a509717
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
278 addition
and
3 deletion
+278
-3
java/RocksDBSample.java
java/RocksDBSample.java
+13
-0
java/org/rocksdb/Options.java
java/org/rocksdb/Options.java
+154
-3
java/rocksjni/options.cc
java/rocksjni/options.cc
+111
-0
未找到文件。
java/RocksDBSample.java
浏览文件 @
2e0d4321
...
...
@@ -33,6 +33,19 @@ public class RocksDBSample {
}
options
.
setCreateIfMissing
(
true
);
options
.
setWriteBufferSize
(
8
*
1024
);
options
.
setMaxWriteBufferNumber
(
3
);
options
.
setDisableSeekCompaction
(
true
);
options
.
setBlockSize
(
64
*
1024
);
options
.
setMaxBackgroundCompactions
(
10
);
assert
(
options
.
createIfMissing
()
==
true
);
assert
(
options
.
writeBufferSize
()
==
8192
);
assert
(
options
.
maxWriteBufferNumber
()
==
3
);
assert
(
options
.
disableSeekCompaction
()
==
true
);
assert
(
options
.
blockSize
()
==
65536
);
assert
(
options
.
maxBackgroundCompactions
()
==
10
);
try
{
db
=
RocksDB
.
open
(
options
,
db_path_not_found
);
db
.
put
(
"hello"
.
getBytes
(),
"world"
.
getBytes
());
...
...
java/org/rocksdb/Options.java
浏览文件 @
2e0d4321
...
...
@@ -34,7 +34,7 @@ public class Options {
* @see RocksDB::Open()
*/
public
void
setCreateIfMissing
(
boolean
flag
)
{
assert
(
nativeHandle_
!=
0
);
assert
(
isInitialized
()
);
setCreateIfMissing
(
nativeHandle_
,
flag
);
}
...
...
@@ -45,11 +45,145 @@ public class Options {
* @return return true if the create_if_missing flag is set to true.
* @see setCreateIfMissing()
*/
public
boolean
cr
ae
teIfMissing
()
{
assert
(
nativeHandle_
!=
0
);
public
boolean
cr
ea
teIfMissing
()
{
assert
(
isInitialized
()
);
return
createIfMissing
(
nativeHandle_
);
}
/**
* Amount of data to build up in memory (backed by an unsorted log
* on disk) before converting to a sorted on-disk file.
*
* Larger values increase performance, especially during bulk loads.
* Up to max_write_buffer_number write buffers may be held in memory
* at the same time, so you may wish to adjust this parameter
* to control memory usage.
*
* Also, a larger write buffer will result in a longer recovery time
* the next time the database is opened.
*
* Default: 4MB
* @param size of write buffer.
* @see RocksDB::Open()
*/
public
void
setWriteBufferSize
(
int
writeBufferSize
)
{
assert
(
isInitialized
());
setWriteBufferSize
(
nativeHandle_
,
writeBufferSize
);
}
/**
* Return size of write buffer size.
*
* @return size of write buffer.
* @see setWriteBufferSize()
*/
public
int
writeBufferSize
()
{
assert
(
isInitialized
());
return
writeBufferSize
(
nativeHandle_
);
}
/**
* The maximum number of write buffers that are built up in memory.
* The default is 2, so that when 1 write buffer is being flushed to
* storage, new writes can continue to the other write buffer.
* Default: 2
*
* @param maximum number of write buffers.
* @see RocksDB::Open()
*/
public
void
setMaxWriteBufferNumber
(
int
maxWriteBufferNumber
)
{
assert
(
isInitialized
());
setMaxWriteBufferNumber
(
nativeHandle_
,
maxWriteBufferNumber
);
}
/**
* Returns maximum number of write buffers.
*
* @return maximum number of write buffers.
* @see setMaxWriteBufferNumber()
*/
public
int
maxWriteBufferNumber
()
{
assert
(
isInitialized
());
return
maxWriteBufferNumber
(
nativeHandle_
);
}
/*
* Approximate size of user data packed per block. Note that the
* block size specified here corresponds to uncompressed data. The
* actual size of the unit read from disk may be smaller if
* compression is enabled. This parameter can be changed dynamically.
*
* Default: 4K
*
* @param block size.
* @see RocksDB::Open()
*/
public
void
setBlockSize
(
int
blockSize
)
{
assert
(
isInitialized
());
setBlockSize
(
nativeHandle_
,
blockSize
);
}
/*
* Returns block size.
*
* @return block size.
* @see setBlockSize()
*/
public
int
blockSize
()
{
assert
(
isInitialized
());
return
blockSize
(
nativeHandle_
);
}
/*
* Disable compaction triggered by seek.
* With bloomfilter and fast storage, a miss on one level
* is very cheap if the file handle is cached in table cache
* (which is true if max_open_files is large).
* Default: true
*
* @param disable seek compaction.
* @see RocksDB::Open()
*/
public
void
setDisableSeekCompaction
(
boolean
disableSeekCompaction
)
{
assert
(
isInitialized
());
setDisableSeekCompaction
(
nativeHandle_
,
disableSeekCompaction
);
}
/*
* Returns true if disable seek compaction is set to true.
*
* @return true if disable seek compaction is set to true.
* @see setDisableSeekCompaction()
*/
public
boolean
disableSeekCompaction
()
{
assert
(
isInitialized
());
return
disableSeekCompaction
(
nativeHandle_
);
}
/*
* Maximum number of concurrent background jobs, submitted to
* the default LOW priority thread pool.
* Default: 1
*
* @param maximum number of concurrent background jobs.
* @see RocksDB::Open()
*/
public
void
setMaxBackgroundCompactions
(
int
maxBackgroundCompactions
)
{
assert
(
isInitialized
());
setMaxBackgroundCompactions
(
nativeHandle_
,
maxBackgroundCompactions
);
}
/*
* Returns maximum number of background concurrent jobs.
*
* @return maximum number of background concurrent jobs.
* @see setMaxBackgroundCompactions
*/
public
int
maxBackgroundCompactions
()
{
assert
(
isInitialized
());
return
maxBackgroundCompactions
(
nativeHandle_
);
}
/**
* Release the memory allocated for the current instance
* in the c++ side.
...
...
@@ -60,10 +194,27 @@ public class Options {
}
}
private
boolean
isInitialized
()
{
return
(
nativeHandle_
!=
0
);
}
private
native
void
newOptions
();
private
native
void
dispose0
();
private
native
void
setCreateIfMissing
(
long
handle
,
boolean
flag
);
private
native
boolean
createIfMissing
(
long
handle
);
private
native
void
setWriteBufferSize
(
long
handle
,
int
writeBufferSize
);
private
native
int
writeBufferSize
(
long
handle
);
private
native
void
setMaxWriteBufferNumber
(
long
handle
,
int
maxWriteBufferNumber
);
private
native
int
maxWriteBufferNumber
(
long
handle
);
private
native
void
setBlockSize
(
long
handle
,
int
blockSize
);
private
native
int
blockSize
(
long
handle
);
private
native
void
setDisableSeekCompaction
(
long
handle
,
boolean
disableSeekCompaction
);
private
native
boolean
disableSeekCompaction
(
long
handle
);
private
native
void
setMaxBackgroundCompactions
(
long
handle
,
int
maxBackgroundCompactions
);
private
native
int
maxBackgroundCompactions
(
long
handle
);
long
nativeHandle_
;
}
java/rocksjni/options.cc
浏览文件 @
2e0d4321
...
...
@@ -58,6 +58,117 @@ jboolean Java_org_rocksdb_Options_createIfMissing(
return
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
create_if_missing
;
}
/*
* Class: org_rocksdb_Options
* Method: setWriteBufferSize
* Signature: (JZ)I
*/
void
Java_org_rocksdb_Options_setWriteBufferSize
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jint
jwrite_buffer_size
)
{
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
write_buffer_size
=
static_cast
<
size_t
>
(
jwrite_buffer_size
);
}
/*
* Class: org_rocksdb_Options
* Method: writeBufferSize
* Signature: (J)I
*/
jint
Java_org_rocksdb_Options_writeBufferSize
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
write_buffer_size
;
}
/*
* Class: org_rocksdb_Options
* Method: setMaxWriteBufferNumber
* Signature: (JI)V
*/
void
Java_org_rocksdb_Options_setMaxWriteBufferNumber
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jint
jmax_write_buffer_number
)
{
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
max_write_buffer_number
=
jmax_write_buffer_number
;
}
/*
* Class: org_rocksdb_Options
* Method: maxWriteBufferNumber
* Signature: (J)I
*/
jint
Java_org_rocksdb_Options_maxWriteBufferNumber
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
max_write_buffer_number
;
}
/*
* Class: org_rocksdb_Options
* Method: setBlockSize
* Signature: (JI)V
*/
void
Java_org_rocksdb_Options_setBlockSize
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jint
jblock_size
)
{
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
block_size
=
static_cast
<
size_t
>
(
jblock_size
);
}
/*
* Class: org_rocksdb_Options
* Method: blockSize
* Signature: (J)I
*/
jint
Java_org_rocksdb_Options_blockSize
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
block_size
;
}
/*
* Class: org_rocksdb_Options
* Method: setDisableSeekCompaction
* Signature: (JZ)V
*/
void
Java_org_rocksdb_Options_setDisableSeekCompaction
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jboolean
jdisable_seek_compaction
)
{
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
disable_seek_compaction
=
jdisable_seek_compaction
;
}
/*
* Class: org_rocksdb_Options
* Method: disableSeekCompaction
* Signature: (J)Z
*/
jboolean
Java_org_rocksdb_Options_disableSeekCompaction
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
disable_seek_compaction
;
}
/*
* Class: org_rocksdb_Options
* Method: setMaxBackgroundCompactions
* Signature: (JI)V
*/
void
Java_org_rocksdb_Options_setMaxBackgroundCompactions
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jint
jmax_background_compactions
)
{
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
max_background_compactions
=
jmax_background_compactions
;
}
/*
* Class: org_rocksdb_Options
* Method: maxBackgroundCompactions
* Signature: (J)I
*/
jint
Java_org_rocksdb_Options_maxBackgroundCompactions
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
max_background_compactions
;
}
//////////////////////////////////////////////////////////////////////////////
// WriteOptions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录