Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
8796934a
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,发现更多精彩内容 >>
提交
8796934a
编写于
7月 29, 2016
作者:
A
Adam Retter
提交者:
Siying Dong
7月 29, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added missing Java ReadOptions settings (#1109)
* Minor reorganisation * Java API - Added missing ReadOptions settings
上级
5e2c7965
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
351 addition
and
21 deletion
+351
-21
java/rocksjni/options.cc
java/rocksjni/options.cc
+106
-0
java/src/main/java/org/rocksdb/ReadOptions.java
java/src/main/java/org/rocksdb/ReadOptions.java
+157
-21
java/src/main/java/org/rocksdb/ReadTier.java
java/src/main/java/org/rocksdb/ReadTier.java
+48
-0
java/src/test/java/org/rocksdb/ReadOptionsTest.java
java/src/test/java/org/rocksdb/ReadOptionsTest.java
+40
-0
未找到文件。
java/rocksjni/options.cc
浏览文件 @
8796934a
...
...
@@ -3925,6 +3925,90 @@ jboolean Java_org_rocksdb_ReadOptions_tailing(
return
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
tailing
;
}
/*
* Class: org_rocksdb_ReadOptions
* Method: managed
* Signature: (J)Z
*/
jboolean
Java_org_rocksdb_ReadOptions_managed
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
managed
;
}
/*
* Class: org_rocksdb_ReadOptions
* Method: setManaged
* Signature: (JZ)V
*/
void
Java_org_rocksdb_ReadOptions_setManaged
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jboolean
jmanaged
)
{
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
managed
=
static_cast
<
bool
>
(
jmanaged
);
}
/*
* Class: org_rocksdb_ReadOptions
* Method: totalOrderSeek
* Signature: (J)Z
*/
jboolean
Java_org_rocksdb_ReadOptions_totalOrderSeek
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
total_order_seek
;
}
/*
* Class: org_rocksdb_ReadOptions
* Method: setTotalOrderSeek
* Signature: (JZ)V
*/
void
Java_org_rocksdb_ReadOptions_setTotalOrderSeek
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jboolean
jtotal_order_seek
)
{
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
total_order_seek
=
static_cast
<
bool
>
(
jtotal_order_seek
);
}
/*
* Class: org_rocksdb_ReadOptions
* Method: prefixSameAsStart
* Signature: (J)Z
*/
jboolean
Java_org_rocksdb_ReadOptions_prefixSameAsStart
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
prefix_same_as_start
;
}
/*
* Class: org_rocksdb_ReadOptions
* Method: setPrefixSameAsStart
* Signature: (JZ)V
*/
void
Java_org_rocksdb_ReadOptions_setPrefixSameAsStart
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jboolean
jprefix_same_as_start
)
{
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
prefix_same_as_start
=
static_cast
<
bool
>
(
jprefix_same_as_start
);
}
/*
* Class: org_rocksdb_ReadOptions
* Method: pinData
* Signature: (J)Z
*/
jboolean
Java_org_rocksdb_ReadOptions_pinData
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
pin_data
;
}
/*
* Class: org_rocksdb_ReadOptions
* Method: setPinData
* Signature: (JZ)V
*/
void
Java_org_rocksdb_ReadOptions_setPinData
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jboolean
jpin_data
)
{
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
pin_data
=
static_cast
<
bool
>
(
jpin_data
);
}
/*
* Class: org_rocksdb_ReadOptions
* Method: setSnapshot
...
...
@@ -3948,6 +4032,28 @@ jlong Java_org_rocksdb_ReadOptions_snapshot(
return
reinterpret_cast
<
jlong
>
(
snapshot
);
}
/*
* Class: org_rocksdb_ReadOptions
* Method: readTier
* Signature: (J)B
*/
jbyte
Java_org_rocksdb_ReadOptions_readTier
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
static_cast
<
jbyte
>
(
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
read_tier
);
}
/*
* Class: org_rocksdb_ReadOptions
* Method: setReadTier
* Signature: (JB)V
*/
void
Java_org_rocksdb_ReadOptions_setReadTier
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jbyte
jread_tier
)
{
reinterpret_cast
<
rocksdb
::
ReadOptions
*>
(
jhandle
)
->
read_tier
=
static_cast
<
rocksdb
::
ReadTier
>
(
jread_tier
);
}
/////////////////////////////////////////////////////////////////////
// rocksdb::ComparatorOptions
...
...
java/src/main/java/org/rocksdb/ReadOptions.java
浏览文件 @
8796934a
...
...
@@ -15,7 +15,6 @@ public class ReadOptions extends RocksObject {
public
ReadOptions
()
{
super
(
newReadOptions
());
}
private
native
static
long
newReadOptions
();
/**
* If true, all data read from underlying storage will be
...
...
@@ -28,7 +27,6 @@ public class ReadOptions extends RocksObject {
assert
(
isOwningHandle
());
return
verifyChecksums
(
nativeHandle_
);
}
private
native
boolean
verifyChecksums
(
long
handle
);
/**
* If true, all data read from underlying storage will be
...
...
@@ -45,8 +43,6 @@ public class ReadOptions extends RocksObject {
setVerifyChecksums
(
nativeHandle_
,
verifyChecksums
);
return
this
;
}
private
native
void
setVerifyChecksums
(
long
handle
,
boolean
verifyChecksums
);
// TODO(yhchiang): this option seems to be block-based table only.
// move this to a better place?
...
...
@@ -61,7 +57,6 @@ public class ReadOptions extends RocksObject {
assert
(
isOwningHandle
());
return
fillCache
(
nativeHandle_
);
}
private
native
boolean
fillCache
(
long
handle
);
/**
* Fill the cache when loading the block-based sst formatted db.
...
...
@@ -77,8 +72,21 @@ public class ReadOptions extends RocksObject {
setFillCache
(
nativeHandle_
,
fillCache
);
return
this
;
}
private
native
void
setFillCache
(
long
handle
,
boolean
fillCache
);
/**
* Returns the currently assigned Snapshot instance.
*
* @return the Snapshot assigned to this instance. If no Snapshot
* is assigned null.
*/
public
Snapshot
snapshot
()
{
assert
(
isOwningHandle
());
long
snapshotHandle
=
snapshot
(
nativeHandle_
);
if
(
snapshotHandle
!=
0
)
{
return
new
Snapshot
(
snapshotHandle
);
}
return
null
;
}
/**
* <p>If "snapshot" is non-nullptr, read as of the supplied snapshot
...
...
@@ -99,23 +107,30 @@ public class ReadOptions extends RocksObject {
}
return
this
;
}
private
native
void
setSnapshot
(
long
handle
,
long
snapshotHandle
);
/**
* Returns the current
ly assigned Snapshot instance
.
* Returns the current
read tier
.
*
* @return the Snapshot assigned to this instance. If no Snapshot
* is assigned null.
* @return the read tier in use, by default {@link ReadTier#READ_ALL_TIER}
*/
public
Snapshot
snapshot
()
{
public
ReadTier
readTier
()
{
assert
(
isOwningHandle
());
long
snapshotHandle
=
snapshot
(
nativeHandle_
);
if
(
snapshotHandle
!=
0
)
{
return
new
Snapshot
(
snapshotHandle
);
}
return
null
;
return
ReadTier
.
getReadTier
(
readTier
(
nativeHandle_
));
}
/**
* Specify if this read request should process data that ALREADY
* resides on a particular cache. If the required data is not
* found at the specified cache, then {@link RocksDBException} is thrown.
*
* @param readTier {@link ReadTier} instance
* @return the reference to the current ReadOptions.
*/
public
ReadOptions
setReadTier
(
final
ReadTier
readTier
)
{
assert
(
isOwningHandle
());
setReadTier
(
nativeHandle_
,
readTier
.
getValue
());
return
this
;
}
private
native
long
snapshot
(
long
handle
);
/**
* Specify to create a tailing iterator -- a special iterator that has a
...
...
@@ -132,7 +147,6 @@ public class ReadOptions extends RocksObject {
assert
(
isOwningHandle
());
return
tailing
(
nativeHandle_
);
}
private
native
boolean
tailing
(
long
handle
);
/**
* Specify to create a tailing iterator -- a special iterator that has a
...
...
@@ -150,8 +164,130 @@ public class ReadOptions extends RocksObject {
setTailing
(
nativeHandle_
,
tailing
);
return
this
;
}
private
native
void
setTailing
(
long
handle
,
boolean
tailing
);
/**
* Returns whether managed iterators will be used.
*
* @return the setting of whether managed iterators will be used, by default false
*/
public
boolean
managed
()
{
assert
(
isOwningHandle
());
return
managed
(
nativeHandle_
);
}
/**
* Specify to create a managed iterator -- a special iterator that
* uses less resources by having the ability to free its underlying
* resources on request.
*
* @param managed if true, then managed iterators will be enabled.
* @return the reference to the current ReadOptions.
*/
public
ReadOptions
setManaged
(
final
boolean
managed
)
{
assert
(
isOwningHandle
());
setManaged
(
nativeHandle_
,
managed
);
return
this
;
}
/**
* Returns whether a total seek order will be used
*
* @return the setting of whether a total seek order will be used
*/
public
boolean
totalOrderSeek
()
{
assert
(
isOwningHandle
());
return
totalOrderSeek
(
nativeHandle_
);
}
/**
* Enable a total order seek regardless of index format (e.g. hash index)
* used in the table. Some table format (e.g. plain table) may not support
* this option.
*
* @param totalOrderSeek if true, then total order seek will be enabled.
* @return the reference to the current ReadOptions.
*/
public
ReadOptions
setTotalOrderSeek
(
final
boolean
totalOrderSeek
)
{
assert
(
isOwningHandle
());
setTotalOrderSeek
(
nativeHandle_
,
totalOrderSeek
);
return
this
;
}
/**
* Returns whether the iterator only iterates over the same prefix as the seek
*
* @return the setting of whether the iterator only iterates over the same
* prefix as the seek, default is false
*/
public
boolean
prefixSameAsStart
()
{
assert
(
isOwningHandle
());
return
prefixSameAsStart
(
nativeHandle_
);
}
/**
* Enforce that the iterator only iterates over the same prefix as the seek.
* This option is effective only for prefix seeks, i.e. prefix_extractor is
* non-null for the column family and {@link #totalOrderSeek()} is false.
* Unlike iterate_upper_bound, {@link #setPrefixSameAsStart(boolean)} only
* works within a prefix but in both directions.
*
* @param prefixSameAsStart if true, then the iterator only iterates over the
* same prefix as the seek
* @return the reference to the current ReadOptions.
*/
public
ReadOptions
setPrefixSameAsStart
(
final
boolean
prefixSameAsStart
)
{
assert
(
isOwningHandle
());
setPrefixSameAsStart
(
nativeHandle_
,
prefixSameAsStart
);
return
this
;
}
/**
* Returns whether the blocks loaded by the iterator will be pinned in memory
*
* @return the setting of whether the blocks loaded by the iterator will be
* pinned in memory
*/
public
boolean
pinData
()
{
assert
(
isOwningHandle
());
return
pinData
(
nativeHandle_
);
}
/**
* Keep the blocks loaded by the iterator pinned in memory as long as the
* iterator is not deleted, If used when reading from tables created with
* BlockBasedTableOptions::use_delta_encoding = false,
* Iterator's property "rocksdb.iterator.is-key-pinned" is guaranteed to
* return 1.
*
* @param pinData if true, the blocks loaded by the iterator will be pinned
* @return the reference to the current ReadOptions.
*/
public
ReadOptions
setPinData
(
final
boolean
pinData
)
{
assert
(
isOwningHandle
());
setPinData
(
nativeHandle_
,
pinData
);
return
this
;
}
private
native
static
long
newReadOptions
();
private
native
boolean
verifyChecksums
(
long
handle
);
private
native
void
setVerifyChecksums
(
long
handle
,
boolean
verifyChecksums
);
private
native
boolean
fillCache
(
long
handle
);
private
native
void
setFillCache
(
long
handle
,
boolean
fillCache
);
private
native
long
snapshot
(
long
handle
);
private
native
void
setSnapshot
(
long
handle
,
long
snapshotHandle
);
private
native
byte
readTier
(
long
handle
);
private
native
void
setReadTier
(
long
handle
,
byte
readTierValue
);
private
native
boolean
tailing
(
long
handle
);
private
native
void
setTailing
(
long
handle
,
boolean
tailing
);
private
native
boolean
managed
(
long
handle
);
private
native
void
setManaged
(
long
handle
,
boolean
managed
);
private
native
boolean
totalOrderSeek
(
long
handle
);
private
native
void
setTotalOrderSeek
(
long
handle
,
boolean
totalOrderSeek
);
private
native
boolean
prefixSameAsStart
(
long
handle
);
private
native
void
setPrefixSameAsStart
(
long
handle
,
boolean
prefixSameAsStart
);
private
native
boolean
pinData
(
long
handle
);
private
native
void
setPinData
(
long
handle
,
boolean
pinData
);
@Override
protected
final
native
void
disposeInternal
(
final
long
handle
);
...
...
java/src/main/java/org/rocksdb/ReadTier.java
0 → 100644
浏览文件 @
8796934a
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
package
org.rocksdb
;
/**
* RocksDB {@link ReadOptions} read tiers.
*/
public
enum
ReadTier
{
READ_ALL_TIER
((
byte
)
0
),
BLOCK_CACHE_TIER
((
byte
)
1
),
PERSISTED_TIER
((
byte
)
2
);
private
final
byte
value
;
ReadTier
(
final
byte
value
)
{
this
.
value
=
value
;
}
/**
* Returns the byte value of the enumerations value
*
* @return byte representation
*/
public
byte
getValue
()
{
return
value
;
}
/**
* Get ReadTier by byte value.
*
* @param value byte representation of ReadTier.
*
* @return {@link org.rocksdb.ReadTier} instance or null.
* @throws java.lang.IllegalArgumentException if an invalid
* value is provided.
*/
public
static
ReadTier
getReadTier
(
final
byte
value
)
{
for
(
final
ReadTier
readTier
:
ReadTier
.
values
())
{
if
(
readTier
.
getValue
()
==
value
){
return
readTier
;
}
}
throw
new
IllegalArgumentException
(
"Illegal value provided for ReadTier."
);
}
}
java/src/test/java/org/rocksdb/ReadOptionsTest.java
浏览文件 @
8796934a
...
...
@@ -61,6 +61,46 @@ public class ReadOptionsTest {
}
}
@Test
public
void
readTier
()
{
try
(
final
ReadOptions
opt
=
new
ReadOptions
())
{
opt
.
setReadTier
(
ReadTier
.
BLOCK_CACHE_TIER
);
assertThat
(
opt
.
readTier
()).
isEqualTo
(
ReadTier
.
BLOCK_CACHE_TIER
);
}
}
@Test
public
void
managed
()
{
try
(
final
ReadOptions
opt
=
new
ReadOptions
())
{
opt
.
setManaged
(
true
);
assertThat
(
opt
.
managed
()).
isTrue
();
}
}
@Test
public
void
totalOrderSeek
()
{
try
(
final
ReadOptions
opt
=
new
ReadOptions
())
{
opt
.
setTotalOrderSeek
(
true
);
assertThat
(
opt
.
totalOrderSeek
()).
isTrue
();
}
}
@Test
public
void
prefixSameAsStart
()
{
try
(
final
ReadOptions
opt
=
new
ReadOptions
())
{
opt
.
setPrefixSameAsStart
(
true
);
assertThat
(
opt
.
prefixSameAsStart
()).
isTrue
();
}
}
@Test
public
void
pinData
()
{
try
(
final
ReadOptions
opt
=
new
ReadOptions
())
{
opt
.
setPinData
(
true
);
assertThat
(
opt
.
pinData
()).
isTrue
();
}
}
@Test
public
void
failSetVerifyChecksumUninitialized
()
{
try
(
final
ReadOptions
readOptions
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录