Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
3e684aa6
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,发现更多精彩内容 >>
提交
3e684aa6
编写于
12月 02, 2014
作者:
F
fyrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Integrated changes from D29571
上级
a15169f2
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
85 addition
and
47 deletion
+85
-47
java/org/rocksdb/CompressionType.java
java/org/rocksdb/CompressionType.java
+44
-10
java/org/rocksdb/RocksDB.java
java/org/rocksdb/RocksDB.java
+10
-6
java/org/rocksdb/benchmark/DbBenchmark.java
java/org/rocksdb/benchmark/DbBenchmark.java
+9
-26
java/org/rocksdb/test/CompressionOptionsTest.java
java/org/rocksdb/test/CompressionOptionsTest.java
+22
-0
java/org/rocksdb/test/MixedOptionsTest.java
java/org/rocksdb/test/MixedOptionsTest.java
+0
-1
java/org/rocksdb/test/PlainTableConfigTest.java
java/org/rocksdb/test/PlainTableConfigTest.java
+0
-4
未找到文件。
java/org/rocksdb/CompressionType.java
浏览文件 @
3e684aa6
...
@@ -14,25 +14,59 @@ package org.rocksdb;
...
@@ -14,25 +14,59 @@ package org.rocksdb;
* compression method (if any) is used to compress a block.</p>
* compression method (if any) is used to compress a block.</p>
*/
*/
public
enum
CompressionType
{
public
enum
CompressionType
{
NO_COMPRESSION
((
byte
)
0
),
SNAPPY_COMPRESSION
((
byte
)
1
),
ZLIB_COMPRESSION
((
byte
)
2
),
BZLIB2_COMPRESSION
((
byte
)
3
),
LZ4_COMPRESSION
((
byte
)
4
),
LZ4HC_COMPRESSION
((
byte
)
5
);
private
final
byte
value_
;
NO_COMPRESSION
((
byte
)
0
,
null
),
SNAPPY_COMPRESSION
((
byte
)
1
,
"snappy"
),
ZLIB_COMPRESSION
((
byte
)
2
,
"z"
),
BZLIB2_COMPRESSION
((
byte
)
3
,
"bzip2"
),
LZ4_COMPRESSION
((
byte
)
4
,
"lz4"
),
LZ4HC_COMPRESSION
((
byte
)
5
,
"lz4hc"
);
private
CompressionType
(
byte
value
)
{
/**
value_
=
value
;
* <p>Get the CompressionType enumeration value by
* passing the library name to this method.</p>
*
* <p>If library cannot be found the enumeration
* value {@code NO_COMPRESSION} will be returned.</p>
*
* @return CompressionType instance.
*/
public
static
CompressionType
getCompressionType
(
String
libraryName
)
{
if
(
libraryName
!=
null
)
{
for
(
CompressionType
compressionType
:
CompressionType
.
values
())
{
if
(
compressionType
.
getLibraryName
()
!=
null
&&
compressionType
.
getLibraryName
().
equals
(
libraryName
))
{
return
compressionType
;
}
}
}
return
CompressionType
.
NO_COMPRESSION
;
}
}
/**
/**
*
Returns the byte value of the enumerations value
*
<p>Returns the byte value of the enumerations value.</p>
*
*
* @return byte representation
* @return byte representation
*/
*/
public
byte
getValue
()
{
public
byte
getValue
()
{
return
value_
;
return
value_
;
}
}
/**
* <p>Returns the library name of the compression type
* identified by the enumeration value.</p>
*
* @return library name
*/
public
String
getLibraryName
()
{
return
libraryName_
;
}
private
CompressionType
(
byte
value
,
final
String
libraryName
)
{
value_
=
value
;
libraryName_
=
libraryName
;
}
private
final
byte
value_
;
private
final
String
libraryName_
;
}
}
java/org/rocksdb/RocksDB.java
浏览文件 @
3e684aa6
...
@@ -18,8 +18,6 @@ import org.rocksdb.util.Environment;
...
@@ -18,8 +18,6 @@ import org.rocksdb.util.Environment;
public
class
RocksDB
extends
RocksObject
{
public
class
RocksDB
extends
RocksObject
{
public
static
final
String
DEFAULT_COLUMN_FAMILY
=
"default"
;
public
static
final
String
DEFAULT_COLUMN_FAMILY
=
"default"
;
public
static
final
int
NOT_FOUND
=
-
1
;
public
static
final
int
NOT_FOUND
=
-
1
;
private
static
final
String
[]
compressionLibs_
=
{
"snappy"
,
"z"
,
"bzip2"
,
"lz4"
,
"lz4hc"
};
static
{
static
{
RocksDB
.
loadLibrary
();
RocksDB
.
loadLibrary
();
...
@@ -35,9 +33,11 @@ public class RocksDB extends RocksObject {
...
@@ -35,9 +33,11 @@ public class RocksDB extends RocksObject {
public
static
synchronized
void
loadLibrary
()
{
public
static
synchronized
void
loadLibrary
()
{
String
tmpDir
=
System
.
getenv
(
"ROCKSDB_SHAREDLIB_DIR"
);
String
tmpDir
=
System
.
getenv
(
"ROCKSDB_SHAREDLIB_DIR"
);
// loading possibly necessary libraries.
// loading possibly necessary libraries.
for
(
String
lib
:
compressionLibs_
)
{
for
(
CompressionType
compressionType
:
CompressionType
.
values
()
)
{
try
{
try
{
System
.
loadLibrary
(
lib
);
if
(
compressionType
.
getLibraryName
()
!=
null
)
{
System
.
loadLibrary
(
compressionType
.
getLibraryName
());
}
}
catch
(
UnsatisfiedLinkError
e
)
{
}
catch
(
UnsatisfiedLinkError
e
)
{
// since it may be optional, we ignore its loading failure here.
// since it may be optional, we ignore its loading failure here.
}
}
...
@@ -60,10 +60,14 @@ public class RocksDB extends RocksObject {
...
@@ -60,10 +60,14 @@ public class RocksDB extends RocksObject {
* of a library.
* of a library.
*/
*/
public
static
synchronized
void
loadLibrary
(
List
<
String
>
paths
)
{
public
static
synchronized
void
loadLibrary
(
List
<
String
>
paths
)
{
for
(
String
lib
:
compressionLibs_
)
{
for
(
CompressionType
compressionType
:
CompressionType
.
values
())
{
if
(
compressionType
.
equals
(
CompressionType
.
NO_COMPRESSION
))
{
continue
;
}
for
(
String
path
:
paths
)
{
for
(
String
path
:
paths
)
{
try
{
try
{
System
.
load
(
path
+
"/"
+
Environment
.
getSharedLibraryName
(
lib
));
System
.
load
(
path
+
"/"
+
Environment
.
getSharedLibraryName
(
compressionType
.
getLibraryName
()));
break
;
break
;
}
catch
(
UnsatisfiedLinkError
e
)
{
}
catch
(
UnsatisfiedLinkError
e
)
{
// since they are optional, we ignore loading fails.
// since they are optional, we ignore loading fails.
...
...
java/org/rocksdb/benchmark/DbBenchmark.java
浏览文件 @
3e684aa6
...
@@ -163,15 +163,6 @@ public class DbBenchmark {
...
@@ -163,15 +163,6 @@ public class DbBenchmark {
EXISTING
EXISTING
}
}
enum
CompressionType
{
NONE
,
SNAPPY
,
ZLIB
,
BZIP2
,
LZ4
,
LZ4HC
}
static
{
static
{
RocksDB
.
loadLibrary
();
RocksDB
.
loadLibrary
();
}
}
...
@@ -457,24 +448,16 @@ public class DbBenchmark {
...
@@ -457,24 +448,16 @@ public class DbBenchmark {
// options.setPrefixSize((Integer)flags_.get(Flag.prefix_size));
// options.setPrefixSize((Integer)flags_.get(Flag.prefix_size));
// options.setKeysPerPrefix((Long)flags_.get(Flag.keys_per_prefix));
// options.setKeysPerPrefix((Long)flags_.get(Flag.keys_per_prefix));
compressionType_
=
(
String
)
flags
.
get
(
Flag
.
compression_type
);
compressionType_
=
(
String
)
flags
.
get
(
Flag
.
compression_type
);
compression_
=
CompressionType
.
NO
NE
;
compression_
=
CompressionType
.
NO
_COMPRESSION
;
try
{
try
{
switch
(
compressionType_
)
{
if
(
compressionType_
!=
null
)
{
case
"snappy"
:
final
CompressionType
compressionType
=
System
.
loadLibrary
(
"snappy"
);
CompressionType
.
getCompressionType
(
compressionType_
);
break
;
if
(
compressionType
!=
null
&&
case
"zlib"
:
compressionType
!=
CompressionType
.
NO_COMPRESSION
)
{
System
.
loadLibrary
(
"z"
);
System
.
loadLibrary
(
compressionType
.
getLibraryName
());
break
;
}
case
"bzip2"
:
System
.
loadLibrary
(
"bzip2"
);
break
;
case
"lz4"
:
System
.
loadLibrary
(
"lz4"
);
break
;
case
"lz4hc"
:
System
.
loadLibrary
(
"lz4hc"
);
break
;
}
}
}
catch
(
UnsatisfiedLinkError
e
)
{
}
catch
(
UnsatisfiedLinkError
e
)
{
System
.
err
.
format
(
"Unable to load %s library:%s%n"
+
System
.
err
.
format
(
"Unable to load %s library:%s%n"
+
...
...
java/org/rocksdb/test/CompressionOptionsTest.java
0 → 100644
浏览文件 @
3e684aa6
// Copyright (c) 2014, 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.test
;
import
org.junit.Test
;
import
org.rocksdb.CompressionType
;
public
class
CompressionOptionsTest
{
@Test
public
void
getCompressionType
()
{
for
(
CompressionType
compressionType
:
CompressionType
.
values
())
{
String
libraryName
=
compressionType
.
getLibraryName
();
compressionType
.
equals
(
CompressionType
.
getCompressionType
(
libraryName
));
}
}
}
java/org/rocksdb/test/MixedOptionsTest.java
浏览文件 @
3e684aa6
...
@@ -53,6 +53,5 @@ public class MixedOptionsTest {
...
@@ -53,6 +53,5 @@ public class MixedOptionsTest {
options
.
optimizeUniversalStyleCompaction
(
400
);
options
.
optimizeUniversalStyleCompaction
(
400
);
options
.
optimizeForPointLookup
(
1024
);
options
.
optimizeForPointLookup
(
1024
);
options
.
prepareForBulkLoad
();
options
.
prepareForBulkLoad
();
System
.
out
.
println
(
"Mixed options test passed"
);
}
}
}
}
java/org/rocksdb/test/PlainTableConfigTest.java
浏览文件 @
3e684aa6
...
@@ -63,10 +63,6 @@ public class PlainTableConfigTest {
...
@@ -63,10 +63,6 @@ public class PlainTableConfigTest {
public
void
encodingType
()
{
public
void
encodingType
()
{
PlainTableConfig
plainTableConfig
=
new
PlainTableConfig
();
PlainTableConfig
plainTableConfig
=
new
PlainTableConfig
();
plainTableConfig
.
setEncodingType
(
EncodingType
.
kPrefix
);
plainTableConfig
.
setEncodingType
(
EncodingType
.
kPrefix
);
assertThat
(
EncodingType
.
valueOf
(
"kPrefix"
)).
isEqualTo
(
EncodingType
.
kPrefix
);
assertThat
(
EncodingType
.
values
().
length
).
isEqualTo
(
2
);
assertThat
(
plainTableConfig
.
encodingType
()).
isEqualTo
(
assertThat
(
plainTableConfig
.
encodingType
()).
isEqualTo
(
EncodingType
.
kPrefix
);
EncodingType
.
kPrefix
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录