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
9c41fa6b
Commit
9c41fa6b
authored
Jul 04, 2017
by
Cholerae Hu
Committed by
zhangjinpeng1987
Jul 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SstFileWriter: get the ownership of Options (#82)
parent
425a023c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
rocksdb.rs
src/rocksdb.rs
+8
-3
test_ingest_external_file.rs
tests/test_ingest_external_file.rs
+7
-6
No files found.
src/rocksdb.rs
View file @
9c41fa6b
...
...
@@ -1346,25 +1346,31 @@ impl Drop for BackupEngine {
/// All keys in files generated by SstFileWriter will have sequence number = 0
pub
struct
SstFileWriter
{
inner
:
*
mut
crocksdb_ffi
::
SstFileWriter
,
_env_opt
:
EnvOptions
,
_opt
:
Options
,
}
unsafe
impl
Send
for
SstFileWriter
{}
impl
SstFileWriter
{
pub
fn
new
(
env_opt
:
&
EnvOptions
,
opt
:
&
Options
)
->
SstFileWriter
{
pub
fn
new
(
env_opt
:
EnvOptions
,
opt
:
Options
)
->
SstFileWriter
{
unsafe
{
SstFileWriter
{
inner
:
crocksdb_ffi
::
crocksdb_sstfilewriter_create
(
env_opt
.inner
,
opt
.inner
),
_env_opt
:
env_opt
,
_opt
:
opt
,
}
}
}
pub
fn
new_cf
(
env_opt
:
&
EnvOptions
,
opt
:
&
Options
,
cf
:
&
CFHandle
)
->
SstFileWriter
{
pub
fn
new_cf
(
env_opt
:
EnvOptions
,
opt
:
Options
,
cf
:
&
CFHandle
)
->
SstFileWriter
{
unsafe
{
SstFileWriter
{
inner
:
crocksdb_ffi
::
crocksdb_sstfilewriter_create_cf
(
env_opt
.inner
,
opt
.inner
,
cf
.inner
),
_env_opt
:
env_opt
,
_opt
:
opt
,
}
}
}
...
...
@@ -1408,7 +1414,6 @@ impl Drop for SstFileWriter {
#[cfg(test)]
mod
test
{
use
rocksdb_options
::
*
;
use
std
::
fs
;
use
std
::
path
::
Path
;
use
std
::
str
;
...
...
tests/test_ingest_external_file.rs
View file @
9c41fa6b
...
...
@@ -16,13 +16,13 @@ use rocksdb::*;
use
std
::
fs
;
use
tempdir
::
TempDir
;
fn
gen_sst
(
opt
:
&
Options
,
cf
:
Option
<&
CFHandle
>
,
path
:
&
str
,
data
:
&
[(
&
[
u8
],
&
[
u8
])])
{
fn
gen_sst
(
opt
:
Options
,
cf
:
Option
<&
CFHandle
>
,
path
:
&
str
,
data
:
&
[(
&
[
u8
],
&
[
u8
])])
{
let
_
=
fs
::
remove_file
(
path
);
let
env_opt
=
EnvOptions
::
new
();
let
mut
writer
=
if
cf
.is_some
()
{
SstFileWriter
::
new_cf
(
&
env_opt
,
opt
,
cf
.unwrap
())
SstFileWriter
::
new_cf
(
env_opt
,
opt
,
cf
.unwrap
())
}
else
{
SstFileWriter
::
new
(
&
env_opt
,
opt
)
SstFileWriter
::
new
(
env_opt
,
opt
)
};
writer
.open
(
path
)
.unwrap
();
for
&
(
k
,
v
)
in
data
{
...
...
@@ -48,7 +48,7 @@ fn test_ingest_external_file() {
let
test_sstfile_str
=
test_sstfile
.to_str
()
.unwrap
();
let
default_options
=
db
.get_options
();
gen_sst
(
&
default_options
,
gen_sst
(
default_options
,
Some
(
db
.cf_handle
(
"default"
)
.unwrap
()),
test_sstfile_str
,
&
[(
b
"k1"
,
b
"v1"
),
(
b
"k2"
,
b
"v2"
)]);
...
...
@@ -60,7 +60,7 @@ fn test_ingest_external_file() {
assert_eq!
(
db
.get
(
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v1"
);
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v2"
);
gen_sst
(
&
cf_opts
,
gen_sst
(
cf_opts
,
None
,
test_sstfile_str
,
&
[(
b
"k1"
,
b
"v3"
),
(
b
"k2"
,
b
"v4"
)]);
...
...
@@ -71,7 +71,8 @@ fn test_ingest_external_file() {
let
snap
=
db
.snapshot
();
gen_sst
(
&
default_options
,
let
opt
=
Options
::
new
();
gen_sst
(
opt
,
None
,
test_sstfile_str
,
&
[(
b
"k2"
,
b
"v5"
),
(
b
"k3"
,
b
"v6"
)]);
...
...
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