Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
06b590dd
R
rocksdb
项目概览
kvdb
/
rocksdb
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
06b590dd
编写于
4月 19, 2014
作者:
A
Ankit Gupta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add doc
上级
dc28a726
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
4 deletion
+73
-4
java/RocksDBSample.java
java/RocksDBSample.java
+1
-1
java/org/rocksdb/Iterator.java
java/org/rocksdb/Iterator.java
+63
-2
java/org/rocksdb/RocksDB.java
java/org/rocksdb/RocksDB.java
+9
-1
未找到文件。
java/RocksDBSample.java
浏览文件 @
06b590dd
...
...
@@ -142,7 +142,7 @@ public class RocksDBSample {
assert
(
false
);
//Should never reach here.
}
Iterator
iterator
=
db
.
i
terator
();
Iterator
iterator
=
db
.
newI
terator
();
boolean
seekToFirstPassed
=
false
;
for
(
iterator
.
seekToFirst
();
iterator
.
isValid
();
iterator
.
next
())
{
...
...
java/org/rocksdb/Iterator.java
浏览文件 @
06b590dd
...
...
@@ -5,6 +5,17 @@
package
org.rocksdb
;
/**
* An iterator yields a sequence of key/value pairs from a source.
* The following class defines the interface. Multiple implementations
* are provided by this library. In particular, iterators are provided
* to access the contents of a Table or a DB.
*
* Multiple threads can invoke const methods on an Iterator without
* external synchronization, but if any of the threads may call a
* non-const method, all threads accessing the same Iterator must use
* external synchronization.
*/
public
class
Iterator
{
private
long
nativeHandle_
;
...
...
@@ -12,51 +23,101 @@ public class Iterator {
nativeHandle_
=
nativeHandle
;
}
/**
* An iterator is either positioned at a key/value pair, or
* not valid. This method returns true iff the iterator is valid.
* @return true if iterator is valid.
*/
public
boolean
isValid
()
{
assert
(
isInitialized
());
return
isValid0
(
nativeHandle_
);
}
/**
* Position at the first key in the source. The iterator is Valid()
* after this call iff the source is not empty.
*/
public
void
seekToFirst
()
{
assert
(
isInitialized
());
seekToFirst0
(
nativeHandle_
);
}
/**
* Position at the last key in the source. The iterator is
* Valid() after this call iff the source is not empty.
*/
public
void
seekToLast
()
{
assert
(
isInitialized
());
seekToLast0
(
nativeHandle_
);
}
/**
* Moves to the next entry in the source. After this call, Valid() is
* true iff the iterator was not positioned at the last entry in the source.
* REQUIRES: Valid()
*/
public
void
next
()
{
assert
(
isInitialized
());
next0
(
nativeHandle_
);
}
/**
* Moves to the previous entry in the source. After this call, Valid() is
* true iff the iterator was not positioned at the first entry in source.
* REQUIRES: Valid()
*/
public
void
prev
()
{
assert
(
isInitialized
());
prev0
(
nativeHandle_
);
}
/**
* Return the key for the current entry. The underlying storage for
* the returned slice is valid only until the next modification of
* the iterator.
* REQUIRES: Valid()
* @return key for the current entry.
*/
public
byte
[]
key
()
{
assert
(
isInitialized
());
return
key0
(
nativeHandle_
);
}
/**
* Return the value for the current entry. The underlying storage for
* the returned slice is valid only until the next modification of
* the iterator.
* REQUIRES: !AtEnd() && !AtStart()
* @return value for the current entry.
*/
public
byte
[]
value
()
{
assert
(
isInitialized
());
return
value0
(
nativeHandle_
);
}
/**
* Position at the first key in the source that at or past target
* The iterator is Valid() after this call iff the source contains
* an entry that comes at or past target.
*/
public
void
seek
(
byte
[]
target
)
{
assert
(
isInitialized
());
seek0
(
nativeHandle_
,
target
,
target
.
length
);
}
/**
* If an error has occurred, return it. Else return an ok status.
* If non-blocking IO is requested and this operation cannot be
* satisfied without doing some IO, then this returns Status::Incomplete().
*/
public
void
status
(){
assert
(
isInitialized
());
status0
(
nativeHandle_
);
}
/**
* Deletes underlying C++ iterator pointer.
*/
public
synchronized
void
close
()
{
if
(
nativeHandle_
!=
0
)
{
close0
(
nativeHandle_
);
...
...
java/org/rocksdb/RocksDB.java
浏览文件 @
06b590dd
...
...
@@ -136,7 +136,15 @@ public class RocksDB {
remove
(
nativeHandle_
,
writeOpt
.
nativeHandle_
,
key
,
key
.
length
);
}
public
Iterator
iterator
()
{
/**
* Return a heap-allocated iterator over the contents of the database.
* The result of newIterator() is initially invalid (caller must
* call one of the Seek methods on the iterator before using it).
*
* Caller should close the iterator when it is no longer needed.
* The returned iterator should be closed before this db is closed.
*/
public
Iterator
newIterator
()
{
return
new
Iterator
(
iterator0
(
nativeHandle_
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录