Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
b39006e3
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,发现更多精彩内容 >>
提交
b39006e3
编写于
1月 25, 2015
作者:
F
fyrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[RocksJava] enable/disable File deletions
上级
9a456fba
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
121 addition
and
0 deletion
+121
-0
java/org/rocksdb/RocksDB.java
java/org/rocksdb/RocksDB.java
+52
-0
java/org/rocksdb/test/RocksDBTest.java
java/org/rocksdb/test/RocksDBTest.java
+21
-0
java/org/rocksdb/test/TransactionLogIteratorTest.java
java/org/rocksdb/test/TransactionLogIteratorTest.java
+3
-0
java/rocksjni/rocksjni.cc
java/rocksjni/rocksjni.cc
+45
-0
未找到文件。
java/org/rocksdb/RocksDB.java
浏览文件 @
b39006e3
...
...
@@ -1588,6 +1588,53 @@ public class RocksDB extends RocksObject {
columnFamilyHandle
.
nativeHandle_
);
}
/**
* <p>The sequence number of the most recent transaction.</p>
*
* @return sequence number of the most
* recent transaction.
*/
public
long
getLatestSequenceNumber
()
{
return
getLatestSequenceNumber
(
nativeHandle_
);
}
/**
* <p>Prevent file deletions. Compactions will continue to occur,
* but no obsolete files will be deleted. Calling this multiple
* times have the same effect as calling it once.</p>
*
* @throws RocksDBException thrown if operation was not performed
* successfully.
*/
public
void
disableFileDeletions
()
throws
RocksDBException
{
disableFileDeletions
(
nativeHandle_
);
}
/**
* <p>Allow compactions to delete obsolete files.
* If force == true, the call to EnableFileDeletions()
* will guarantee that file deletions are enabled after
* the call, even if DisableFileDeletions() was called
* multiple times before.</p>
*
* <p>If force == false, EnableFileDeletions will only
* enable file deletion after it's been called at least
* as many times as DisableFileDeletions(), enabling
* the two methods to be called by two threads
* concurrently without synchronization
* -- i.e., file deletions will be enabled only after both
* threads call EnableFileDeletions()</p>
*
* @param force boolean value described above.
*
* @throws RocksDBException thrown if operation was not performed
* successfully.
*/
public
void
enableFileDeletions
(
boolean
force
)
throws
RocksDBException
{
enableFileDeletions
(
nativeHandle_
,
force
);
}
/**
* <p>Returns an iterator that is positioned at a write-batch containing
* seq_number. If the sequence number is non existent, it returns an iterator
...
...
@@ -1753,6 +1800,11 @@ public class RocksDB extends RocksObject {
private
native
void
compactRange
(
long
handle
,
byte
[]
begin
,
int
beginLen
,
byte
[]
end
,
int
endLen
,
boolean
reduce_level
,
int
target_level
,
int
target_path_id
,
long
cfHandle
)
throws
RocksDBException
;
private
native
long
getLatestSequenceNumber
(
long
handle
);
private
native
void
disableFileDeletions
(
long
handle
)
throws
RocksDBException
;
private
native
void
enableFileDeletions
(
long
handle
,
boolean
force
)
throws
RocksDBException
;
private
native
long
getUpdatesSince
(
long
handle
,
long
sequenceNumber
)
throws
RocksDBException
;
...
...
java/org/rocksdb/test/RocksDBTest.java
浏览文件 @
b39006e3
...
...
@@ -738,4 +738,25 @@ public class RocksDBTest {
}
}
}
@Test
public
void
enableDisableFileDeletions
()
throws
RocksDBException
{
RocksDB
db
=
null
;
Options
options
=
null
;
try
{
options
=
new
Options
().
setCreateIfMissing
(
true
);
db
=
RocksDB
.
open
(
options
,
dbFolder
.
getRoot
().
getAbsolutePath
());
db
.
disableFileDeletions
();
db
.
enableFileDeletions
(
false
);
db
.
disableFileDeletions
();
db
.
enableFileDeletions
(
true
);
}
finally
{
if
(
db
!=
null
)
{
db
.
close
();
}
if
(
options
!=
null
)
{
options
.
dispose
();
}
}
}
}
java/org/rocksdb/test/TransactionLogIteratorTest.java
浏览文件 @
b39006e3
...
...
@@ -57,6 +57,9 @@ public class TransactionLogIteratorTest {
String
.
valueOf
(
i
).
getBytes
());
}
db
.
flush
(
new
FlushOptions
().
setWaitForFlush
(
true
));
assertThat
(
db
.
getLatestSequenceNumber
()).
isEqualTo
(
250
);
transactionLogIterator
=
db
.
getUpdatesSince
(
0
);
assertThat
(
transactionLogIterator
.
isValid
()).
isTrue
();
transactionLogIterator
.
status
();
...
...
java/rocksjni/rocksjni.cc
浏览文件 @
b39006e3
...
...
@@ -1601,6 +1601,51 @@ void Java_org_rocksdb_RocksDB_compactRange__J_3BI_3BIZIIJ(
jend
,
jend_len
,
jreduce_level
,
jtarget_level
,
jtarget_path_id
);
}
//////////////////////////////////////////////////////////////////////////////
// rocksdb::DB::GetLatestSequenceNumber
/*
* Class: org_rocksdb_RocksDB
* Method: getLatestSequenceNumber
* Signature: (J)V
*/
jlong
Java_org_rocksdb_RocksDB_getLatestSequenceNumber
(
JNIEnv
*
env
,
jobject
jdb
,
jlong
jdb_handle
)
{
auto
db
=
reinterpret_cast
<
rocksdb
::
DB
*>
(
jdb_handle
);
return
db
->
GetLatestSequenceNumber
();
}
//////////////////////////////////////////////////////////////////////////////
// rocksdb::DB enable/disable file deletions
/*
* Class: org_rocksdb_RocksDB
* Method: enableFileDeletions
* Signature: (J)V
*/
void
Java_org_rocksdb_RocksDB_disableFileDeletions
(
JNIEnv
*
env
,
jobject
jdb
,
jlong
jdb_handle
)
{
auto
db
=
reinterpret_cast
<
rocksdb
::
DB
*>
(
jdb_handle
);
rocksdb
::
Status
s
=
db
->
DisableFileDeletions
();
if
(
!
s
.
ok
())
{
rocksdb
::
RocksDBExceptionJni
::
ThrowNew
(
env
,
s
);
}
}
/*
* Class: org_rocksdb_RocksDB
* Method: enableFileDeletions
* Signature: (JZ)V
*/
void
Java_org_rocksdb_RocksDB_enableFileDeletions
(
JNIEnv
*
env
,
jobject
jdb
,
jlong
jdb_handle
,
jboolean
jforce
)
{
auto
db
=
reinterpret_cast
<
rocksdb
::
DB
*>
(
jdb_handle
);
rocksdb
::
Status
s
=
db
->
EnableFileDeletions
(
jforce
);
if
(
!
s
.
ok
())
{
rocksdb
::
RocksDBExceptionJni
::
ThrowNew
(
env
,
s
);
}
}
//////////////////////////////////////////////////////////////////////////////
// rocksdb::DB::GetUpdatesSince
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录