Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
3f8b4129
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,发现更多精彩内容 >>
提交
3f8b4129
编写于
4月 25, 2014
作者:
A
Ankit Gupta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix formatting
上级
e96e71be
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
37 deletion
+37
-37
java/org/rocksdb/RocksDB.java
java/org/rocksdb/RocksDB.java
+19
-19
java/rocksjni/portal.h
java/rocksjni/portal.h
+6
-6
java/rocksjni/rocksjni.cc
java/rocksjni/rocksjni.cc
+12
-12
未找到文件。
java/org/rocksdb/RocksDB.java
浏览文件 @
3f8b4129
...
...
@@ -154,58 +154,58 @@ public class RocksDB {
public
byte
[]
get
(
ReadOptions
opt
,
byte
[]
key
)
throws
RocksDBException
{
return
get
(
nativeHandle_
,
opt
.
nativeHandle_
,
key
,
key
.
length
);
}
/**
* Returns a map of keys for which values were found in DB.
*
*
* @param keys List of keys for which values need to be retrieved.
* @return Map where key of map is the key passed by user and value for map
* @return Map where key of map is the key passed by user and value for map
* entry is the corresponding value in DB.
*
* @see RocksDBException
*
* @see RocksDBException
*/
public
Map
<
byte
[],
byte
[]>
multiGet
(
List
<
byte
[]>
keys
)
throws
RocksDBException
{
List
<
byte
[]>
values
=
multiGet
(
nativeHandle_
,
keys
,
keys
.
size
());
Map
<
byte
[],
byte
[]>
keyValueMap
=
new
HashMap
<
byte
[],
byte
[]>();
Map
<
byte
[],
byte
[]>
keyValueMap
=
new
HashMap
<
byte
[],
byte
[]>();
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
if
(
values
.
get
(
i
)
==
null
)
{
continue
;
}
keyValueMap
.
put
(
keys
.
get
(
i
),
values
.
get
(
i
));
}
return
keyValueMap
;
}
/**
* Returns a map of keys for which values were found in DB.
*
*
* @param List of keys for which values need to be retrieved.
* @param opt Read options.
* @return Map where key of map is the key passed by user and value for map
* @return Map where key of map is the key passed by user and value for map
* entry is the corresponding value in DB.
*
* @see RocksDBException
*
* @see RocksDBException
*/
public
Map
<
byte
[],
byte
[]>
multiGet
(
ReadOptions
opt
,
List
<
byte
[]>
keys
)
throws
RocksDBException
{
List
<
byte
[]>
values
=
multiGet
(
nativeHandle_
,
opt
.
nativeHandle_
,
keys
,
keys
.
size
());
Map
<
byte
[],
byte
[]>
keyValueMap
=
new
HashMap
<
byte
[],
byte
[]>();
Map
<
byte
[],
byte
[]>
keyValueMap
=
new
HashMap
<
byte
[],
byte
[]>();
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
{
if
(
values
.
get
(
i
)
==
null
)
{
continue
;
}
keyValueMap
.
put
(
keys
.
get
(
i
),
values
.
get
(
i
));
}
return
keyValueMap
;
}
...
...
java/rocksjni/portal.h
浏览文件 @
3f8b4129
...
...
@@ -324,7 +324,7 @@ class ListJni {
assert
(
jclazz
!=
nullptr
);
return
jclazz
;
}
// Get the java class id of java.util.ArrayList.
static
jclass
getArrayListClass
(
JNIEnv
*
env
)
{
static
jclass
jclazz
=
env
->
FindClass
(
"java/util/ArrayList"
);
...
...
@@ -338,7 +338,7 @@ class ListJni {
assert
(
jclazz
!=
nullptr
);
return
jclazz
;
}
// Get the java method id of java.util.List.iterator().
static
jmethodID
getIteratorMethod
(
JNIEnv
*
env
)
{
static
jmethodID
mid
=
env
->
GetMethodID
(
...
...
@@ -346,7 +346,7 @@ class ListJni {
assert
(
mid
!=
nullptr
);
return
mid
;
}
// Get the java method id of java.util.Iterator.hasNext().
static
jmethodID
getHasNextMethod
(
JNIEnv
*
env
)
{
static
jmethodID
mid
=
env
->
GetMethodID
(
...
...
@@ -354,7 +354,7 @@ class ListJni {
assert
(
mid
!=
nullptr
);
return
mid
;
}
// Get the java method id of java.util.Iterator.next().
static
jmethodID
getNextMethod
(
JNIEnv
*
env
)
{
static
jmethodID
mid
=
env
->
GetMethodID
(
...
...
@@ -362,7 +362,7 @@ class ListJni {
assert
(
mid
!=
nullptr
);
return
mid
;
}
// Get the java method id of arrayList constructor.
static
jmethodID
getArrayListConstructorMethodId
(
JNIEnv
*
env
,
jclass
jclazz
)
{
static
jmethodID
mid
=
env
->
GetMethodID
(
...
...
@@ -370,7 +370,7 @@ class ListJni {
assert
(
mid
!=
nullptr
);
return
mid
;
}
// Get the java method id of java.util.List.add().
static
jmethodID
getListAddMethodId
(
JNIEnv
*
env
)
{
static
jmethodID
mid
=
env
->
GetMethodID
(
...
...
java/rocksjni/rocksjni.cc
浏览文件 @
3f8b4129
...
...
@@ -249,37 +249,37 @@ jobject multi_get_helper(JNIEnv* env, jobject jdb, rocksdb::DB* db,
const
rocksdb
::
ReadOptions
&
rOpt
,
jobject
jkey_list
,
jint
jkeys_count
)
{
std
::
vector
<
rocksdb
::
Slice
>
keys
;
std
::
vector
<
jbyte
*>
keys_to_free
;
// get iterator
jobject
iteratorObj
=
env
->
CallObjectMethod
(
jkey_list
,
rocksdb
::
ListJni
::
getIteratorMethod
(
env
));
// iterate over keys and convert java byte array to slice
while
(
env
->
CallBooleanMethod
(
iteratorObj
,
rocksdb
::
ListJni
::
getHasNextMethod
(
env
))
==
JNI_TRUE
)
{
jbyteArray
jkey
=
(
jbyteArray
)
env
->
CallObjectMethod
(
iteratorObj
,
rocksdb
::
ListJni
::
getNextMethod
(
env
));
jint
key_length
=
env
->
GetArrayLength
(
jkey
);
jbyte
*
key
=
new
jbyte
[
key_length
];
env
->
GetByteArrayRegion
(
jkey
,
0
,
key_length
,
key
);
// store allocated jbyte to free it after multiGet call
keys_to_free
.
push_back
(
key
);
keys_to_free
.
push_back
(
key
);
rocksdb
::
Slice
key_slice
(
reinterpret_cast
<
char
*>
(
key
),
key_length
);
keys
.
push_back
(
key_slice
);
}
std
::
vector
<
std
::
string
>
values
;
std
::
vector
<
rocksdb
::
Status
>
s
=
db
->
MultiGet
(
rOpt
,
keys
,
&
values
);
// Don't reuse class pointer
jclass
jclazz
=
env
->
FindClass
(
"java/util/ArrayList"
);
jclass
jclazz
=
env
->
FindClass
(
"java/util/ArrayList"
);
jmethodID
mid
=
rocksdb
::
ListJni
::
getArrayListConstructorMethodId
(
env
,
jclazz
);
env
,
jclazz
);
jobject
jvalue_list
=
env
->
NewObject
(
jclazz
,
mid
,
jkeys_count
);
// insert in java list
for
(
std
::
vector
<
rocksdb
::
Status
>::
size_type
i
=
0
;
i
!=
s
.
size
();
i
++
)
{
if
(
s
[
i
].
ok
())
{
...
...
@@ -295,13 +295,13 @@ jobject multi_get_helper(JNIEnv* env, jobject jdb, rocksdb::DB* db,
jvalue_list
,
rocksdb
::
ListJni
::
getListAddMethodId
(
env
),
nullptr
);
}
}
// free up allocated byte arrays
for
(
std
::
vector
<
jbyte
*>::
size_type
i
=
0
;
i
!=
keys_to_free
.
size
();
i
++
)
{
delete
[]
keys_to_free
[
i
];
}
keys_to_free
.
clear
();
return
jvalue_list
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录