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
c5c0b09e
Commit
c5c0b09e
authored
Nov 12, 2017
by
Huachao Huang
Committed by
goroutine
Nov 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SstFileWriter::file_size() (#157)
* Add SstFileWriter::file_size()
parent
ec72a896
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
7 deletions
+18
-7
c.cc
librocksdb_sys/crocksdb/c.cc
+4
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+2
-0
lib.rs
librocksdb_sys/src/lib.rs
+3
-0
rocksdb.rs
src/rocksdb.rs
+4
-0
rocksdb_options.rs
src/rocksdb_options.rs
+2
-2
test_rate_limiter.rs
tests/test_rate_limiter.rs
+3
-5
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
c5c0b09e
...
...
@@ -2909,6 +2909,10 @@ void crocksdb_sstfilewriter_finish(crocksdb_sstfilewriter_t* writer,
SaveError
(
errptr
,
writer
->
rep
->
Finish
(
NULL
));
}
uint64_t
crocksdb_sstfilewriter_file_size
(
crocksdb_sstfilewriter_t
*
writer
)
{
return
writer
->
rep
->
FileSize
();
}
void
crocksdb_sstfilewriter_destroy
(
crocksdb_sstfilewriter_t
*
writer
)
{
delete
writer
->
rep
;
delete
writer
;
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
c5c0b09e
...
...
@@ -1220,6 +1220,8 @@ crocksdb_sstfilewriter_delete(crocksdb_sstfilewriter_t *writer, const char *key,
size_t
keylen
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_sstfilewriter_finish
(
crocksdb_sstfilewriter_t
*
writer
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
uint64_t
crocksdb_sstfilewriter_file_size
(
crocksdb_sstfilewriter_t
*
writer
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_sstfilewriter_destroy
(
crocksdb_sstfilewriter_t
*
writer
);
...
...
librocksdb_sys/src/lib.rs
View file @
c5c0b09e
...
...
@@ -1119,6 +1119,7 @@ extern "C" {
err
:
*
mut
*
mut
c_char
,
);
pub
fn
crocksdb_sstfilewriter_finish
(
writer
:
*
mut
SstFileWriter
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_sstfilewriter_file_size
(
writer
:
*
mut
SstFileWriter
)
->
uint64_t
;
pub
fn
crocksdb_sstfilewriter_destroy
(
writer
:
*
mut
SstFileWriter
);
pub
fn
crocksdb_ingest_external_file
(
...
...
@@ -1583,6 +1584,7 @@ mod test {
assert
!
(
err
.is_null
(),
error_message
(
err
));
crocksdb_sstfilewriter_finish
(
writer
,
&
mut
err
);
assert
!
(
err
.is_null
(),
error_message
(
err
));
assert
!
(
crocksdb_sstfilewriter_file_size
(
writer
)
>
0
);
let
ing_opt
=
crocksdb_ingestexternalfileoptions_create
();
let
file_list
=
&
[
c_sst_path_ptr
];
...
...
@@ -1606,6 +1608,7 @@ mod test {
assert
!
(
err
.is_null
(),
error_message
(
err
));
crocksdb_sstfilewriter_finish
(
writer
,
&
mut
err
);
assert
!
(
err
.is_null
(),
error_message
(
err
));
assert
!
(
crocksdb_sstfilewriter_file_size
(
writer
)
>
0
);
crocksdb_ingest_external_file
(
db
,
file_list
.as_ptr
(),
1
,
ing_opt
,
&
mut
err
);
assert
!
(
err
.is_null
(),
error_message
(
err
));
...
...
src/rocksdb.rs
View file @
c5c0b09e
...
...
@@ -1767,6 +1767,10 @@ impl SstFileWriter {
Ok
(())
}
}
pub
fn
file_size
(
&
mut
self
)
->
u64
{
unsafe
{
crocksdb_ffi
::
crocksdb_sstfilewriter_file_size
(
self
.inner
)
as
u64
}
}
}
impl
Drop
for
SstFileWriter
{
...
...
src/rocksdb_options.rs
View file @
c5c0b09e
...
...
@@ -153,8 +153,8 @@ pub struct RateLimiter {
inner
:
*
mut
DBRateLimiter
,
}
unsafe
impl
Send
for
RateLimiter
{
}
unsafe
impl
Sync
for
RateLimiter
{
}
unsafe
impl
Send
for
RateLimiter
{}
unsafe
impl
Sync
for
RateLimiter
{}
impl
RateLimiter
{
pub
fn
new
(
rate_bytes_per_sec
:
i64
,
refill_period_us
:
i64
,
fairness
:
i32
)
->
RateLimiter
{
...
...
tests/test_rate_limiter.rs
View file @
c5c0b09e
...
...
@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use
std
::
thread
;
use
rocksdb
::
RateLimiter
;
use
std
::
thread
;
#[test]
fn
test_rate_limiter
()
{
...
...
@@ -43,9 +43,7 @@ fn test_rate_limiter() {
fn
test_rate_limiter_sendable
()
{
let
rate_limiter
=
RateLimiter
::
new
(
10
*
1024
*
1024
,
100
*
1000
,
10
);
let
handle
=
thread
::
spawn
(
move
||
{
rate_limiter
.request
(
1024
,
0
);
});
let
handle
=
thread
::
spawn
(
move
||
{
rate_limiter
.request
(
1024
,
0
);
});
handle
.join
();
handle
.join
()
.unwrap
()
;
}
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