Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
rust-rocksdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
rust-rocksdb
Commits
5e80fbd4
Commit
5e80fbd4
authored
May 11, 2017
by
ShuYu Wang
Committed by
siddontang
May 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add circleci and travisci (#54)
parent
9e402e8f
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
174 additions
and
93 deletions
+174
-93
.travis.yml
.travis.yml
+21
-6
circle.yml
circle.yml
+65
-0
rocksdb.rs
src/rocksdb.rs
+19
-24
test_column_family.rs
tests/test_column_family.rs
+7
-6
test_compact_range.rs
tests/test_compact_range.rs
+5
-7
test_compaction_filter.rs
tests/test_compaction_filter.rs
+12
-11
test_ingest_external_file.rs
tests/test_ingest_external_file.rs
+6
-3
test_iterator.rs
tests/test_iterator.rs
+6
-4
test_multithreaded.rs
tests/test_multithreaded.rs
+17
-23
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+8
-5
test_slice_transform.rs
tests/test_slice_transform.rs
+4
-2
test_statistics.rs
tests/test_statistics.rs
+4
-2
No files found.
.travis.yml
View file @
5e80fbd4
language
:
rust
language
:
rust
dist
:
trusty
sudo
:
required
rust
:
rust
:
-
stable
-
beta
-
beta
-
nightly
-
nightly
-
stable
cache
:
directories
:
-
target
os
:
os
:
-
linux
-
linux
-
osx
# - osx
before_script
:
-
cargo install --force --vers 0.6.1 rustfmt ||
true
script
:
script
:
-
rustc -Z parse-only src/lib.rs
-
cargo fmt && git diff-index --quiet HEAD -- || (echo please make format and run tests before creating a pr!; exit 1)
-
cargo build --features static-link
-
cargo test --all --features static-link
env
:
global
:
-
RUST_TEST_THREADS=1
-
LD_LIBRARY_PATH
:
"
/usr/local/lib"
circle.yml
0 → 100644
View file @
5e80fbd4
machine
:
environment
:
PATH
:
"
$HOME/.cargo/bin:$HOME/.local/bin:$PATH"
LD_LIBRARY_PATH
:
"
$LD_LIBRARY_PATH:$HOME/.local/lib"
LD_RUN_PATH
:
"
$LD_RUN_PATH:$HOME/.local/lib"
DYLD_LIBRARY_PATH
:
"
$DYLD_LIBRARY_PATH:$HOME/.local/lib"
LDFLAGS
:
"
-L$HOME/.local/lib"
CPPFLAGS
:
"
-I$HOME/.local/include"
CXXFLAGS
:
"
-I$HOME/.local/include"
PKG_CONFIG_PATH
:
"
$PKG_CONFIG_PATH:$HOME/.local/lib/pkgconfig"
RUSTC_DATE
:
"
2017-03-28"
LOCAL_PREFIX
:
"
$HOME/.local"
# used by cargo
LIBRARY_PATH
:
"
$LIBRARY_PATH:$HOME/.local/lib"
RUST_TEST_THREADS
:
1
RUST_BACKTRACE
:
1
RUSTFLAGS
:
"
-Dwarnings"
RUSTFMT_VERSION
:
"
v0.6.0"
pre
:
-
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y;
sudo apt-get update -y;
sudo apt-get install -y g++-4.8 zlib1g-dev libbz2-dev libsnappy-dev curl libdw-dev libelf-dev elfutils binutils-dev
post
:
# Fixes: cargo under CircleCI
-
sed -i 's/github/git-non-exist-hub/g' ~/.gitconfig
dependencies
:
cache_directories
:
-
~/.multirust
-
~/.cargo
-
~/.local
-
target
pre
:
# install rust/cargo
-
|
if [[ ! -e $HOME/.cargo ]]; then
curl https://sh.rustup.rs -sSf |
sh -s -- --no-modify-path --default-toolchain "nightly-${RUSTC_DATE}" -y;
rustup default "nightly-${RUSTC_DATE}";
else
rustup default "nightly-${RUSTC_DATE}";
fi
-
cargo install --force --vers 0.6.1 rustfmt ||
true
-
|
if [[ ! -e $HOME/.local/lib/librocksdb.so ]]; then
export CPLUS_INCLUDE_PATH="${LOCAL_PREFIX}/include" && \
cd /tmp && \
curl -L https://github.com/facebook/rocksdb/archive/v5.2.1.tar.gz -o rocksdb.tar.gz && \
tar xf rocksdb.tar.gz && \
cd rocksdb-5.2.1 && \
INSTALL_PATH=${LOCAL_PREFIX} make -j install-shared;
fi
post
:
# cargo test also use debug
-
cargo build -v
:
timeout
:
1800
-
cargo test -v --no-run
:
timeout
:
1800
test
:
override
:
-
cargo fmt && git diff-index --quiet HEAD -- || (echo please make format and run tests before creating a pr!; git diff HEAD; exit 1)
-
cargo test -- --nocapture
src/rocksdb.rs
View file @
5e80fbd4
...
@@ -42,7 +42,9 @@ impl Drop for CFHandle {
...
@@ -42,7 +42,9 @@ impl Drop for CFHandle {
}
}
fn
build_cstring_list
(
str_list
:
&
[
&
str
])
->
Vec
<
CString
>
{
fn
build_cstring_list
(
str_list
:
&
[
&
str
])
->
Vec
<
CString
>
{
str_list
.into_iter
()
.map
(|
s
|
CString
::
new
(
s
.as_bytes
())
.unwrap
())
.collect
()
str_list
.into_iter
()
.map
(|
s
|
CString
::
new
(
s
.as_bytes
())
.unwrap
())
.collect
()
}
}
pub
struct
DB
{
pub
struct
DB
{
...
@@ -342,14 +344,10 @@ impl DB {
...
@@ -342,14 +344,10 @@ impl DB {
// so that their pointers remain valid.
// so that their pointers remain valid.
let
c_cfs
=
build_cstring_list
(
&
cfs_v
);
let
c_cfs
=
build_cstring_list
(
&
cfs_v
);
let
cfnames
:
Vec
<*
const
_
>
=
c_cfs
.iter
()
let
cfnames
:
Vec
<*
const
_
>
=
c_cfs
.iter
()
.map
(|
cf
|
cf
.as_ptr
())
.collect
();
.map
(|
cf
|
cf
.as_ptr
())
.collect
();
// These handles will be populated by DB.
// These handles will be populated by DB.
let
cfhandles
:
Vec
<
_
>
=
cfs_v
.iter
()
let
cfhandles
:
Vec
<
_
>
=
cfs_v
.iter
()
.map
(|
_
|
ptr
::
null_mut
())
.collect
();
.map
(|
_
|
ptr
::
null_mut
())
.collect
();
let
cfopts
:
Vec
<
_
>
=
cf_opts_v
.iter
()
let
cfopts
:
Vec
<
_
>
=
cf_opts_v
.iter
()
.map
(|
x
|
x
.inner
as
*
const
crocksdb_ffi
::
DBOptions
)
.map
(|
x
|
x
.inner
as
*
const
crocksdb_ffi
::
DBOptions
)
...
@@ -771,18 +769,10 @@ impl DB {
...
@@ -771,18 +769,10 @@ impl DB {
}
}
fn
get_approximate_sizes_cfopt
(
&
self
,
cf
:
Option
<&
CFHandle
>
,
ranges
:
&
[
Range
])
->
Vec
<
u64
>
{
fn
get_approximate_sizes_cfopt
(
&
self
,
cf
:
Option
<&
CFHandle
>
,
ranges
:
&
[
Range
])
->
Vec
<
u64
>
{
let
start_keys
:
Vec
<*
const
u8
>
=
ranges
.iter
()
let
start_keys
:
Vec
<*
const
u8
>
=
ranges
.iter
()
.map
(|
x
|
x
.start_key
.as_ptr
())
.collect
();
.map
(|
x
|
x
.start_key
.as_ptr
())
let
start_key_lens
:
Vec
<
_
>
=
ranges
.iter
()
.map
(|
x
|
x
.start_key
.len
())
.collect
();
.collect
();
let
end_keys
:
Vec
<*
const
u8
>
=
ranges
.iter
()
.map
(|
x
|
x
.end_key
.as_ptr
())
.collect
();
let
start_key_lens
:
Vec
<
_
>
=
ranges
.iter
()
let
end_key_lens
:
Vec
<
_
>
=
ranges
.iter
()
.map
(|
x
|
x
.end_key
.len
())
.collect
();
.map
(|
x
|
x
.start_key
.len
())
.collect
();
let
end_keys
:
Vec
<*
const
u8
>
=
ranges
.iter
()
.map
(|
x
|
x
.end_key
.as_ptr
())
.collect
();
let
end_key_lens
:
Vec
<
_
>
=
ranges
.iter
()
.map
(|
x
|
x
.end_key
.len
())
.collect
();
let
mut
sizes
:
Vec
<
u64
>
=
vec!
[
0
;
ranges
.len
()];
let
mut
sizes
:
Vec
<
u64
>
=
vec!
[
0
;
ranges
.len
()];
let
(
n
,
start_key_ptr
,
start_key_len_ptr
,
end_key_ptr
,
end_key_len_ptr
,
size_ptr
)
=
let
(
n
,
start_key_ptr
,
start_key_len_ptr
,
end_key_ptr
,
end_key_len_ptr
,
size_ptr
)
=
(
ranges
.len
()
as
i32
,
(
ranges
.len
()
as
i32
,
...
@@ -944,7 +934,8 @@ impl DB {
...
@@ -944,7 +934,8 @@ impl DB {
pub
fn
get_and_reset_statistics_ticker_count
(
&
self
,
pub
fn
get_and_reset_statistics_ticker_count
(
&
self
,
ticker_type
:
DBStatisticsTickerType
)
ticker_type
:
DBStatisticsTickerType
)
->
u64
{
->
u64
{
self
.opts
.get_and_reset_statistics_ticker_count
(
ticker_type
)
self
.opts
.get_and_reset_statistics_ticker_count
(
ticker_type
)
}
}
pub
fn
get_statistics_histogram_string
(
&
self
,
pub
fn
get_statistics_histogram_string
(
&
self
,
...
@@ -1624,7 +1615,8 @@ mod test {
...
@@ -1624,7 +1615,8 @@ mod test {
// Make a backup.
// Make a backup.
let
backup_dir
=
TempDir
::
new
(
"_rust_rocksdb_backuptest_backup"
)
.unwrap
();
let
backup_dir
=
TempDir
::
new
(
"_rust_rocksdb_backuptest_backup"
)
.unwrap
();
let
backup_engine
=
db
.backup_at
(
backup_dir
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
backup_engine
=
db
.backup_at
(
backup_dir
.path
()
.to_str
()
.unwrap
())
.unwrap
();
// Restore it.
// Restore it.
let
ropt1
=
RestoreOptions
::
new
();
let
ropt1
=
RestoreOptions
::
new
();
...
@@ -1773,9 +1765,11 @@ mod test {
...
@@ -1773,9 +1765,11 @@ mod test {
.unwrap
();
.unwrap
();
// Wait until all currently running background processes finish.
// Wait until all currently running background processes finish.
db
.pause_bg_work
();
db
.pause_bg_work
();
assert_eq!
(
db
.get_property_int
(
"rocksdb.num-running-compactions"
)
.unwrap
(),
assert_eq!
(
db
.get_property_int
(
"rocksdb.num-running-compactions"
)
.unwrap
(),
0
);
0
);
assert_eq!
(
db
.get_property_int
(
"rocksdb.num-running-flushes"
)
.unwrap
(),
assert_eq!
(
db
.get_property_int
(
"rocksdb.num-running-flushes"
)
.unwrap
(),
0
);
0
);
db
.continue_bg_work
();
db
.continue_bg_work
();
h
.join
()
.unwrap
();
h
.join
()
.unwrap
();
...
@@ -1835,7 +1829,8 @@ mod test {
...
@@ -1835,7 +1829,8 @@ mod test {
let
cf_handle
=
db
.cf_handle
(
"cf"
)
.unwrap
();
let
cf_handle
=
db
.cf_handle
(
"cf"
)
.unwrap
();
for
i
in
0
..
200
{
for
i
in
0
..
200
{
db
.put_cf
(
cf_handle
,
format!
(
"k_{}"
,
i
)
.as_bytes
(),
b
"v"
)
.unwrap
();
db
.put_cf
(
cf_handle
,
format!
(
"k_{}"
,
i
)
.as_bytes
(),
b
"v"
)
.unwrap
();
}
}
db
.flush_cf
(
cf_handle
,
true
)
.unwrap
();
db
.flush_cf
(
cf_handle
,
true
)
.unwrap
();
...
...
tests/test_column_family.rs
View file @
5e80fbd4
...
@@ -76,8 +76,11 @@ pub fn test_column_family() {
...
@@ -76,8 +76,11 @@ pub fn test_column_family() {
};
};
let
cf1
=
db
.cf_handle
(
"cf1"
)
.unwrap
();
let
cf1
=
db
.cf_handle
(
"cf1"
)
.unwrap
();
assert
!
(
db
.put_cf
(
cf1
,
b
"k1"
,
b
"v1"
)
.is_ok
());
assert
!
(
db
.put_cf
(
cf1
,
b
"k1"
,
b
"v1"
)
.is_ok
());
assert
!
(
db
.get_cf
(
cf1
,
b
"k1"
)
.unwrap
()
.unwrap
()
.to_utf8
()
.unwrap
()
==
assert
!
(
db
.get_cf
(
cf1
,
b
"k1"
)
"v1"
);
.unwrap
()
.unwrap
()
.to_utf8
()
.unwrap
()
==
"v1"
);
let
p
=
db
.put_cf
(
cf1
,
b
"k1"
,
b
"a"
);
let
p
=
db
.put_cf
(
cf1
,
b
"k1"
,
b
"a"
);
assert
!
(
p
.is_ok
());
assert
!
(
p
.is_ok
());
/*
/*
...
@@ -108,11 +111,9 @@ pub fn test_column_family() {
...
@@ -108,11 +111,9 @@ pub fn test_column_family() {
*/
*/
}
}
// TODO should be able to use writebatch ops with a cf
// TODO should be able to use writebatch ops with a cf
{
{}
}
// TODO should be able to iterate over a cf
// TODO should be able to iterate over a cf
{
{}
}
// should b able to drop a cf
// should b able to drop a cf
{
{
let
mut
db
=
DB
::
open_cf
(
Options
::
new
(),
path_str
,
&
[
"cf1"
],
&
[
&
Options
::
new
()])
.unwrap
();
let
mut
db
=
DB
::
open_cf
(
Options
::
new
(),
path_str
,
&
[
"cf1"
],
&
[
&
Options
::
new
()])
.unwrap
();
...
...
tests/test_compact_range.rs
View file @
5e80fbd4
...
@@ -21,13 +21,11 @@ fn test_compact_range() {
...
@@ -21,13 +21,11 @@ fn test_compact_range() {
let
mut
opts
=
Options
::
new
();
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
opts
.create_if_missing
(
true
);
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
samples
=
vec!
[
let
samples
=
vec!
[(
b
"k1"
.to_vec
(),
b
"value--------1"
.to_vec
()),
(
b
"k1"
.to_vec
(),
b
"value--------1"
.to_vec
()),
(
b
"k2"
.to_vec
(),
b
"value--------2"
.to_vec
()),
(
b
"k2"
.to_vec
(),
b
"value--------2"
.to_vec
()),
(
b
"k3"
.to_vec
(),
b
"value--------3"
.to_vec
()),
(
b
"k3"
.to_vec
(),
b
"value--------3"
.to_vec
()),
(
b
"k4"
.to_vec
(),
b
"value--------4"
.to_vec
()),
(
b
"k4"
.to_vec
(),
b
"value--------4"
.to_vec
()),
(
b
"k5"
.to_vec
(),
b
"value--------5"
.to_vec
())];
(
b
"k5"
.to_vec
(),
b
"value--------5"
.to_vec
()),
];
for
&
(
ref
k
,
ref
v
)
in
&
samples
{
for
&
(
ref
k
,
ref
v
)
in
&
samples
{
db
.put
(
k
,
v
)
.unwrap
();
db
.put
(
k
,
v
)
.unwrap
();
assert_eq!
(
v
.as_slice
(),
&*
db
.get
(
k
)
.unwrap
()
.unwrap
());
assert_eq!
(
v
.as_slice
(),
&*
db
.get
(
k
)
.unwrap
()
.unwrap
());
...
...
tests/test_compaction_filter.rs
View file @
5e80fbd4
...
@@ -23,7 +23,10 @@ struct Filter {
...
@@ -23,7 +23,10 @@ struct Filter {
impl
CompactionFilter
for
Filter
{
impl
CompactionFilter
for
Filter
{
fn
filter
(
&
mut
self
,
_
:
usize
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
bool
{
fn
filter
(
&
mut
self
,
_
:
usize
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
bool
{
self
.filtered_kvs
.write
()
.unwrap
()
.push
((
key
.to_vec
(),
value
.to_vec
()));
self
.filtered_kvs
.write
()
.unwrap
()
.push
((
key
.to_vec
(),
value
.to_vec
()));
true
true
}
}
}
}
...
@@ -44,16 +47,14 @@ fn test_compaction_filter() {
...
@@ -44,16 +47,14 @@ fn test_compaction_filter() {
opts
.set_compaction_filter
(
"test"
,
opts
.set_compaction_filter
(
"test"
,
false
,
false
,
Box
::
new
(
Filter
{
Box
::
new
(
Filter
{
drop_called
:
drop_called
.clone
(),
drop_called
:
drop_called
.clone
(),
filtered_kvs
:
filtered_kvs
.clone
(),
filtered_kvs
:
filtered_kvs
.clone
(),
}))
}))
.unwrap
();
.unwrap
();
opts
.create_if_missing
(
true
);
opts
.create_if_missing
(
true
);
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
samples
=
vec!
[
let
samples
=
vec!
[(
b
"key1"
.to_vec
(),
b
"value1"
.to_vec
()),
(
b
"key1"
.to_vec
(),
b
"value1"
.to_vec
()),
(
b
"key2"
.to_vec
(),
b
"value2"
.to_vec
())];
(
b
"key2"
.to_vec
(),
b
"value2"
.to_vec
()),
];
for
&
(
ref
k
,
ref
v
)
in
&
samples
{
for
&
(
ref
k
,
ref
v
)
in
&
samples
{
db
.put
(
k
,
v
)
.unwrap
();
db
.put
(
k
,
v
)
.unwrap
();
assert_eq!
(
v
.as_slice
(),
&*
db
.get
(
k
)
.unwrap
()
.unwrap
());
assert_eq!
(
v
.as_slice
(),
&*
db
.get
(
k
)
.unwrap
()
.unwrap
());
...
@@ -76,9 +77,9 @@ fn test_compaction_filter() {
...
@@ -76,9 +77,9 @@ fn test_compaction_filter() {
opts
.set_compaction_filter
(
"test"
,
opts
.set_compaction_filter
(
"test"
,
true
,
true
,
Box
::
new
(
Filter
{
Box
::
new
(
Filter
{
drop_called
:
drop_called
.clone
(),
drop_called
:
drop_called
.clone
(),
filtered_kvs
:
filtered_kvs
.clone
(),
filtered_kvs
:
filtered_kvs
.clone
(),
}))
}))
.unwrap
();
.unwrap
();
assert
!
(
drop_called
.load
(
Ordering
::
Relaxed
));
assert
!
(
drop_called
.load
(
Ordering
::
Relaxed
));
drop_called
.store
(
false
,
Ordering
::
Relaxed
);
drop_called
.store
(
false
,
Ordering
::
Relaxed
);
...
...
tests/test_ingest_external_file.rs
View file @
5e80fbd4
...
@@ -54,7 +54,8 @@ fn test_ingest_external_file() {
...
@@ -54,7 +54,8 @@ fn test_ingest_external_file() {
&
[(
b
"k1"
,
b
"v1"
),
(
b
"k2"
,
b
"v2"
)]);
&
[(
b
"k1"
,
b
"v1"
),
(
b
"k2"
,
b
"v2"
)]);
let
mut
ingest_opt
=
IngestExternalFileOptions
::
new
();
let
mut
ingest_opt
=
IngestExternalFileOptions
::
new
();
db
.ingest_external_file
(
&
ingest_opt
,
&
[
test_sstfile_str
])
.unwrap
();
db
.ingest_external_file
(
&
ingest_opt
,
&
[
test_sstfile_str
])
.unwrap
();
assert
!
(
test_sstfile
.exists
());
assert
!
(
test_sstfile
.exists
());
assert_eq!
(
db
.get
(
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v1"
);
assert_eq!
(
db
.get
(
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v1"
);
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v2"
);
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v2"
);
...
@@ -63,7 +64,8 @@ fn test_ingest_external_file() {
...
@@ -63,7 +64,8 @@ fn test_ingest_external_file() {
None
,
None
,
test_sstfile_str
,
test_sstfile_str
,
&
[(
b
"k1"
,
b
"v3"
),
(
b
"k2"
,
b
"v4"
)]);
&
[(
b
"k1"
,
b
"v3"
),
(
b
"k2"
,
b
"v4"
)]);
db
.ingest_external_file_cf
(
handle
,
&
ingest_opt
,
&
[
test_sstfile_str
])
.unwrap
();
db
.ingest_external_file_cf
(
handle
,
&
ingest_opt
,
&
[
test_sstfile_str
])
.unwrap
();
assert_eq!
(
db
.get_cf
(
handle
,
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v3"
);
assert_eq!
(
db
.get_cf
(
handle
,
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v3"
);
assert_eq!
(
db
.get_cf
(
handle
,
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v4"
);
assert_eq!
(
db
.get_cf
(
handle
,
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v4"
);
...
@@ -74,7 +76,8 @@ fn test_ingest_external_file() {
...
@@ -74,7 +76,8 @@ fn test_ingest_external_file() {
test_sstfile_str
,
test_sstfile_str
,
&
[(
b
"k2"
,
b
"v5"
),
(
b
"k3"
,
b
"v6"
)]);
&
[(
b
"k2"
,
b
"v5"
),
(
b
"k3"
,
b
"v6"
)]);
ingest_opt
=
ingest_opt
.move_files
(
true
);
ingest_opt
=
ingest_opt
.move_files
(
true
);
db
.ingest_external_file_cf
(
handle
,
&
ingest_opt
,
&
[
test_sstfile_str
])
.unwrap
();
db
.ingest_external_file_cf
(
handle
,
&
ingest_opt
,
&
[
test_sstfile_str
])
.unwrap
();
assert_eq!
(
db
.get_cf
(
handle
,
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v3"
);
assert_eq!
(
db
.get_cf
(
handle
,
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v3"
);
assert_eq!
(
db
.get_cf
(
handle
,
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v5"
);
assert_eq!
(
db
.get_cf
(
handle
,
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v5"
);
...
...
tests/test_iterator.rs
View file @
5e80fbd4
...
@@ -56,8 +56,9 @@ pub fn test_iterator() {
...
@@ -56,8 +56,9 @@ pub fn test_iterator() {
assert
!
(
p
.is_ok
());
assert
!
(
p
.is_ok
());
let
p
=
db
.put
(
k3
,
v3
);
let
p
=
db
.put
(
k3
,
v3
);
assert
!
(
p
.is_ok
());
assert
!
(
p
.is_ok
());
let
expected
=
let
expected
=
vec!
[(
k1
.to_vec
(),
v1
.to_vec
()),
vec!
[(
k1
.to_vec
(),
v1
.to_vec
()),
(
k2
.to_vec
(),
v2
.to_vec
()),
(
k3
.to_vec
(),
v3
.to_vec
())];
(
k2
.to_vec
(),
v2
.to_vec
()),
(
k3
.to_vec
(),
v3
.to_vec
())];
let
mut
iter
=
db
.iter
();
let
mut
iter
=
db
.iter
();
...
@@ -101,8 +102,9 @@ pub fn test_iterator() {
...
@@ -101,8 +102,9 @@ pub fn test_iterator() {
assert_eq!
(
iter
.collect
::
<
Vec
<
_
>>
(),
expected2
);
assert_eq!
(
iter
.collect
::
<
Vec
<
_
>>
(),
expected2
);
iter
.seek
(
SeekKey
::
Key
(
k2
));
iter
.seek
(
SeekKey
::
Key
(
k2
));
let
expected
=
let
expected
=
vec!
[(
k2
.to_vec
(),
v2
.to_vec
()),
vec!
[(
k2
.to_vec
(),
v2
.to_vec
()),
(
k3
.to_vec
(),
v3
.to_vec
()),
(
k4
.to_vec
(),
v4
.to_vec
())];
(
k3
.to_vec
(),
v3
.to_vec
()),
(
k4
.to_vec
(),
v4
.to_vec
())];
assert_eq!
(
iter
.collect
::
<
Vec
<
_
>>
(),
expected
);
assert_eq!
(
iter
.collect
::
<
Vec
<
_
>>
(),
expected
);
iter
.seek
(
SeekKey
::
Key
(
k2
));
iter
.seek
(
SeekKey
::
Key
(
k2
));
...
...
tests/test_multithreaded.rs
View file @
5e80fbd4
...
@@ -28,34 +28,28 @@ pub fn test_multithreaded() {
...
@@ -28,34 +28,28 @@ pub fn test_multithreaded() {
db
.put
(
b
"key"
,
b
"value1"
)
.unwrap
();
db
.put
(
b
"key"
,
b
"value1"
)
.unwrap
();
let
db1
=
db
.clone
();
let
db1
=
db
.clone
();
let
j1
=
thread
::
spawn
(
move
||
{
let
j1
=
thread
::
spawn
(
move
||
for
_
in
1
..
N
{
for
_
in
1
..
N
{
db1
.put
(
b
"key"
,
b
"value1"
)
.unwrap
();
db1
.put
(
b
"key"
,
b
"value1"
)
.unwrap
();
});
}
});
let
db2
=
db
.clone
();
let
db2
=
db
.clone
();
let
j2
=
thread
::
spawn
(
move
||
{
let
j2
=
thread
::
spawn
(
move
||
for
_
in
1
..
N
{
for
_
in
1
..
N
{
db2
.put
(
b
"key"
,
b
"value2"
)
.unwrap
();
db2
.put
(
b
"key"
,
b
"value2"
)
.unwrap
();
});
}
});
let
db3
=
db
.clone
();
let
db3
=
db
.clone
();
let
j3
=
thread
::
spawn
(
move
||
{
let
j3
=
thread
::
spawn
(
move
||
for
_
in
1
..
N
{
for
_
in
1
..
N
{
match
db3
.get
(
b
"key"
)
{
match
db3
.get
(
b
"key"
)
{
Ok
(
Some
(
v
))
=>
{
Ok
(
Some
(
v
))
=>
{
if
&
v
[
..
]
!=
b
"value1"
&&
&
v
[
..
]
!=
b
"value2"
{
if
&
v
[
..
]
!=
b
"value1"
&&
&
v
[
..
]
!=
b
"value2"
{
assert
!
(
false
);
assert
!
(
false
);
}
}
}
}
_
=>
{
_
=>
{
assert
!
(
false
);
assert
!
(
false
);
}
}
}
}
});
}
});
j1
.join
()
.unwrap
();
j1
.join
()
.unwrap
();
j2
.join
()
.unwrap
();
j2
.join
()
.unwrap
();
...
...
tests/test_rocksdb_options.rs
View file @
5e80fbd4
...
@@ -65,7 +65,8 @@ fn test_enable_statistics() {
...
@@ -65,7 +65,8 @@ fn test_enable_statistics() {
opts
.enable_statistics
();
opts
.enable_statistics
();
opts
.set_stats_dump_period_sec
(
60
);
opts
.set_stats_dump_period_sec
(
60
);
assert
!
(
opts
.get_statistics
()
.is_some
());
assert
!
(
opts
.get_statistics
()
.is_some
());
assert
!
(
opts
.get_statistics_histogram_string
(
HistogramType
::
DbSeekMicros
)
.is_some
());
assert
!
(
opts
.get_statistics_histogram_string
(
HistogramType
::
DbSeekMicros
)
.is_some
());
assert_eq!
(
opts
.get_statistics_ticker_count
(
TickerType
::
BlockCacheMiss
),
assert_eq!
(
opts
.get_statistics_ticker_count
(
TickerType
::
BlockCacheMiss
),
0
);
0
);
assert_eq!
(
opts
.get_and_reset_statistics_ticker_count
(
TickerType
::
BlockCacheMiss
),
assert_eq!
(
opts
.get_and_reset_statistics_ticker_count
(
TickerType
::
BlockCacheMiss
),
...
@@ -98,8 +99,8 @@ fn test_memtable_insert_hint_prefix_extractor() {
...
@@ -98,8 +99,8 @@ fn test_memtable_insert_hint_prefix_extractor() {
opts
.create_if_missing
(
true
);
opts
.create_if_missing
(
true
);
opts
.set_memtable_insert_hint_prefix_extractor
(
"FixedPrefixTransform"
,
opts
.set_memtable_insert_hint_prefix_extractor
(
"FixedPrefixTransform"
,
Box
::
new
(
FixedPrefixTransform
{
Box
::
new
(
FixedPrefixTransform
{
prefix_len
:
2
,
prefix_len
:
2
,
}))
}))
.unwrap
();
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
wopts
=
WriteOptions
::
new
();
let
wopts
=
WriteOptions
::
new
();
...
@@ -156,7 +157,8 @@ fn test_create_info_log() {
...
@@ -156,7 +157,8 @@ fn test_create_info_log() {
opts
.set_log_file_time_to_roll
(
1
);
opts
.set_log_file_time_to_roll
(
1
);
let
info_dir
=
TempDir
::
new
(
"_rust_rocksdb_test_info_log_dir"
)
.expect
(
""
);
let
info_dir
=
TempDir
::
new
(
"_rust_rocksdb_test_info_log_dir"
)
.expect
(
""
);
opts
.create_info_log
(
info_dir
.path
()
.to_str
()
.unwrap
())
.unwrap
();
opts
.create_info_log
(
info_dir
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
assert
!
(
Path
::
new
(
info_dir
.path
()
.join
(
"LOG"
)
.to_str
()
.unwrap
())
.is_file
());
assert
!
(
Path
::
new
(
info_dir
.path
()
.join
(
"LOG"
)
.to_str
()
.unwrap
())
.is_file
());
...
@@ -183,7 +185,8 @@ fn test_auto_roll_max_size_info_log() {
...
@@ -183,7 +185,8 @@ fn test_auto_roll_max_size_info_log() {
opts
.set_max_log_file_size
(
10
);
opts
.set_max_log_file_size
(
10
);
let
info_dir
=
TempDir
::
new
(
"_rust_rocksdb_max_size_info_log_dir"
)
.expect
(
""
);
let
info_dir
=
TempDir
::
new
(
"_rust_rocksdb_max_size_info_log_dir"
)
.expect
(
""
);
opts
.create_info_log
(
info_dir
.path
()
.to_str
()
.unwrap
())
.unwrap
();
opts
.create_info_log
(
info_dir
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
assert
!
(
Path
::
new
(
info_dir
.path
()
.join
(
"LOG"
)
.to_str
()
.unwrap
())
.is_file
());
assert
!
(
Path
::
new
(
info_dir
.path
()
.join
(
"LOG"
)
.to_str
()
.unwrap
())
.is_file
());
...
...
tests/test_slice_transform.rs
View file @
5e80fbd4
...
@@ -58,8 +58,10 @@ fn test_slice_transform() {
...
@@ -58,8 +58,10 @@ fn test_slice_transform() {
let
mut
it
=
db
.iter
();
let
mut
it
=
db
.iter
();
let
invalid_seeks
=
let
invalid_seeks
=
vec!
[
b
"key_"
.to_vec
(),
vec!
[
b
"key_"
.to_vec
(),
b
"key_0"
.to_vec
(),
b
"key_030"
.to_vec
(),
b
"key_03000"
.to_vec
()];
b
"key_0"
.to_vec
(),
b
"key_030"
.to_vec
(),
b
"key_03000"
.to_vec
()];
for
key
in
invalid_seeks
{
for
key
in
invalid_seeks
{
it
.seek
(
SeekKey
::
Key
(
&
key
));
it
.seek
(
SeekKey
::
Key
(
&
key
));
...
...
tests/test_statistics.rs
View file @
5e80fbd4
...
@@ -35,6 +35,8 @@ fn test_db_statistics() {
...
@@ -35,6 +35,8 @@ fn test_db_statistics() {
assert
!
(
db
.get_statistics_ticker_count
(
TickerType
::
BlockCacheHit
)
>
0
);
assert
!
(
db
.get_statistics_ticker_count
(
TickerType
::
BlockCacheHit
)
>
0
);
assert
!
(
db
.get_and_reset_statistics_ticker_count
(
TickerType
::
BlockCacheHit
)
>
0
);
assert
!
(
db
.get_and_reset_statistics_ticker_count
(
TickerType
::
BlockCacheHit
)
>
0
);
assert_eq!
(
db
.get_statistics_ticker_count
(
TickerType
::
BlockCacheHit
),
0
);
assert_eq!
(
db
.get_statistics_ticker_count
(
TickerType
::
BlockCacheHit
),
0
);
assert
!
(
db
.get_statistics_histogram_string
(
HistogramType
::
DbGetMicros
)
.is_some
());
assert
!
(
db
.get_statistics_histogram_string
(
HistogramType
::
DbGetMicros
)
assert
!
(
db
.get_statistics_histogram
(
HistogramType
::
DbGetMicros
)
.is_some
());
.is_some
());
assert
!
(
db
.get_statistics_histogram
(
HistogramType
::
DbGetMicros
)
.is_some
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment