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
ee4c6ebb
Commit
ee4c6ebb
authored
Apr 28, 2017
by
Dylan Wen
Committed by
siddontang
Apr 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add constructor for sst file writer (#43)
parent
c92d8f39
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
12 deletions
+39
-12
c.cc
librocksdb_sys/crocksdb/c.cc
+8
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+3
-0
lib.rs
librocksdb_sys/src/lib.rs
+5
-2
rocksdb.rs
src/rocksdb.rs
+14
-5
test_ingest_external_file.rs
tests/test_ingest_external_file.rs
+9
-5
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
ee4c6ebb
...
@@ -2482,6 +2482,14 @@ crocksdb_envoptions_t* crocksdb_envoptions_create() {
...
@@ -2482,6 +2482,14 @@ crocksdb_envoptions_t* crocksdb_envoptions_create() {
void
crocksdb_envoptions_destroy
(
crocksdb_envoptions_t
*
opt
)
{
delete
opt
;
}
void
crocksdb_envoptions_destroy
(
crocksdb_envoptions_t
*
opt
)
{
delete
opt
;
}
crocksdb_sstfilewriter_t
*
crocksdb_sstfilewriter_create
(
crocksdb_sstfilewriter_t
*
crocksdb_sstfilewriter_create
(
const
crocksdb_envoptions_t
*
env
,
const
crocksdb_options_t
*
io_options
)
{
crocksdb_sstfilewriter_t
*
writer
=
new
crocksdb_sstfilewriter_t
;
writer
->
rep
=
new
SstFileWriter
(
env
->
rep
,
io_options
->
rep
,
io_options
->
rep
.
comparator
);
return
writer
;
}
crocksdb_sstfilewriter_t
*
crocksdb_sstfilewriter_create_cf
(
const
crocksdb_envoptions_t
*
env
,
const
crocksdb_options_t
*
io_options
,
const
crocksdb_envoptions_t
*
env
,
const
crocksdb_options_t
*
io_options
,
crocksdb_column_family_handle_t
*
column_family
)
{
crocksdb_column_family_handle_t
*
column_family
)
{
crocksdb_sstfilewriter_t
*
writer
=
new
crocksdb_sstfilewriter_t
;
crocksdb_sstfilewriter_t
*
writer
=
new
crocksdb_sstfilewriter_t
;
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
ee4c6ebb
...
@@ -994,6 +994,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_envoptions_destroy(
...
@@ -994,6 +994,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_envoptions_destroy(
extern
C_ROCKSDB_LIBRARY_API
crocksdb_sstfilewriter_t
*
extern
C_ROCKSDB_LIBRARY_API
crocksdb_sstfilewriter_t
*
crocksdb_sstfilewriter_create
(
const
crocksdb_envoptions_t
*
env
,
crocksdb_sstfilewriter_create
(
const
crocksdb_envoptions_t
*
env
,
const
crocksdb_options_t
*
io_options
);
extern
C_ROCKSDB_LIBRARY_API
crocksdb_sstfilewriter_t
*
crocksdb_sstfilewriter_create_cf
(
const
crocksdb_envoptions_t
*
env
,
const
crocksdb_options_t
*
io_options
,
const
crocksdb_options_t
*
io_options
,
crocksdb_column_family_handle_t
*
column_family
);
crocksdb_column_family_handle_t
*
column_family
);
extern
C_ROCKSDB_LIBRARY_API
crocksdb_sstfilewriter_t
*
extern
C_ROCKSDB_LIBRARY_API
crocksdb_sstfilewriter_t
*
...
...
librocksdb_sys/src/lib.rs
View file @
ee4c6ebb
...
@@ -663,9 +663,12 @@ extern "C" {
...
@@ -663,9 +663,12 @@ extern "C" {
// SstFileWriter
// SstFileWriter
pub
fn
crocksdb_sstfilewriter_create
(
env
:
*
mut
EnvOptions
,
pub
fn
crocksdb_sstfilewriter_create
(
env
:
*
mut
EnvOptions
,
io_options
:
*
const
DBOptions
,
io_options
:
*
const
DBOptions
)
cf
:
*
mut
DBCFHandle
)
->
*
mut
SstFileWriter
;
->
*
mut
SstFileWriter
;
pub
fn
crocksdb_sstfilewriter_create_cf
(
env
:
*
mut
EnvOptions
,
io_options
:
*
const
DBOptions
,
cf
:
*
mut
DBCFHandle
)
->
*
mut
SstFileWriter
;
pub
fn
crocksdb_sstfilewriter_create_with_comparator
(
env
:
*
mut
EnvOptions
,
pub
fn
crocksdb_sstfilewriter_create_with_comparator
(
env
:
*
mut
EnvOptions
,
io_options
:
*
const
DBOptions
,
io_options
:
*
const
DBOptions
,
comparator
:
*
const
DBComparator
,
comparator
:
*
const
DBComparator
,
...
...
src/rocksdb.rs
View file @
ee4c6ebb
...
@@ -1343,12 +1343,20 @@ pub struct SstFileWriter {
...
@@ -1343,12 +1343,20 @@ pub struct SstFileWriter {
unsafe
impl
Send
for
SstFileWriter
{}
unsafe
impl
Send
for
SstFileWriter
{}
impl
SstFileWriter
{
impl
SstFileWriter
{
pub
fn
new
(
env_opt
:
&
EnvOptions
,
opt
:
&
Options
,
cf
:
&
CFHandle
)
->
SstFileWriter
{
pub
fn
new
(
env_opt
:
&
EnvOptions
,
opt
:
&
Options
)
->
SstFileWriter
{
unsafe
{
unsafe
{
SstFileWriter
{
SstFileWriter
{
inner
:
crocksdb_ffi
::
crocksdb_sstfilewriter_create
(
env_opt
.inner
,
inner
:
crocksdb_ffi
::
crocksdb_sstfilewriter_create
(
env_opt
.inner
,
opt
.inner
),
opt
.inner
,
}
cf
.inner
),
}
}
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
),
}
}
}
}
}
}
...
@@ -1802,7 +1810,8 @@ mod test {
...
@@ -1802,7 +1810,8 @@ mod test {
}
}
db
.flush_cf
(
cf_handle
,
true
)
.unwrap
();
db
.flush_cf
(
cf_handle
,
true
)
.unwrap
();
let
total_sst_files_size
=
db
.get_property_int_cf
(
cf_handle
,
"rocksdb.total-sst-files-size"
)
.unwrap
();
let
total_sst_files_size
=
db
.get_property_int_cf
(
cf_handle
,
"rocksdb.total-sst-files-size"
)
.unwrap
();
assert
!
(
total_sst_files_size
>
0
);
assert
!
(
total_sst_files_size
>
0
);
}
}
}
}
tests/test_ingest_external_file.rs
View file @
ee4c6ebb
...
@@ -16,10 +16,14 @@ use rocksdb::*;
...
@@ -16,10 +16,14 @@ use rocksdb::*;
use
std
::
fs
;
use
std
::
fs
;
use
tempdir
::
TempDir
;
use
tempdir
::
TempDir
;
fn
gen_sst
(
opt
:
&
Options
,
cf
:
&
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
_
=
fs
::
remove_file
(
path
);
let
env_opt
=
EnvOptions
::
new
();
let
env_opt
=
EnvOptions
::
new
();
let
mut
writer
=
SstFileWriter
::
new
(
&
env_opt
,
opt
,
cf
);
let
mut
writer
=
if
cf
.is_some
()
{
SstFileWriter
::
new_cf
(
&
env_opt
,
opt
,
cf
.unwrap
())
}
else
{
SstFileWriter
::
new
(
&
env_opt
,
opt
)
};
writer
.open
(
path
)
.unwrap
();
writer
.open
(
path
)
.unwrap
();
for
&
(
k
,
v
)
in
data
{
for
&
(
k
,
v
)
in
data
{
writer
.add
(
k
,
v
)
.unwrap
();
writer
.add
(
k
,
v
)
.unwrap
();
...
@@ -45,7 +49,7 @@ fn test_ingest_external_file() {
...
@@ -45,7 +49,7 @@ fn test_ingest_external_file() {
let
default_options
=
db
.get_options
();
let
default_options
=
db
.get_options
();
gen_sst
(
&
default_options
,
gen_sst
(
&
default_options
,
db
.cf_handle
(
"default"
)
.unwrap
(
),
Some
(
db
.cf_handle
(
"default"
)
.unwrap
()
),
test_sstfile_str
,
test_sstfile_str
,
&
[(
b
"k1"
,
b
"v1"
),
(
b
"k2"
,
b
"v2"
)]);
&
[(
b
"k1"
,
b
"v1"
),
(
b
"k2"
,
b
"v2"
)]);
...
@@ -56,7 +60,7 @@ fn test_ingest_external_file() {
...
@@ -56,7 +60,7 @@ fn test_ingest_external_file() {
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v2"
);
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v2"
);
gen_sst
(
&
cf_opts
,
gen_sst
(
&
cf_opts
,
handl
e
,
Non
e
,
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
();
...
@@ -66,7 +70,7 @@ fn test_ingest_external_file() {
...
@@ -66,7 +70,7 @@ fn test_ingest_external_file() {
let
snap
=
db
.snapshot
();
let
snap
=
db
.snapshot
();
gen_sst
(
&
default_options
,
gen_sst
(
&
default_options
,
handl
e
,
Non
e
,
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
);
...
...
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