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
dfbf55f8
Commit
dfbf55f8
authored
Jan 19, 2015
by
Tyler Neely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add db repair function
parent
3ab6a191
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
rocksdb.rs
src/rocksdb.rs
+22
-5
No files found.
src/rocksdb.rs
View file @
dfbf55f8
...
...
@@ -75,10 +75,7 @@ impl RocksDB {
let
ospath
=
Path
::
new
(
path
);
if
!
ospath
.exists
()
{
match
fs
::
mkdir_recursive
(
&
ospath
,
io
::
USER_DIR
)
{
Err
(
e
)
=>
return
Err
(
e
.desc
),
Ok
(
_
)
=>
(),
}
return
Err
(
"path does not exist"
);
}
let
err
=
0
as
*
mut
i8
;
...
...
@@ -92,6 +89,27 @@ impl RocksDB {
}
}
pub
fn
repair
(
opts
:
RocksDBOptions
,
path
:
&
str
)
->
Result
<
(),
&
str
>
{
unsafe
{
let
cpath
=
CString
::
from_slice
(
path
.as_bytes
());
let
cpath_ptr
=
cpath
.as_ptr
();
let
ospath
=
Path
::
new
(
path
);
if
!
ospath
.exists
()
{
return
Err
(
"path does not exist"
);
}
let
err
=
0
as
*
mut
i8
;
let
result
=
rocksdb_ffi
::
rocksdb_repair_db
(
opts
.inner
,
cpath_ptr
,
err
);
if
!
err
.is_null
()
{
let
cs
=
from_c_str
(
err
as
*
const
i8
);
return
Err
(
cs
);
}
Ok
(())
}
}
pub
fn
create_snapshot
(
self
)
->
RocksDBSnapshot
{
unsafe
{
rocksdb_ffi
::
rocksdb_create_snapshot
(
self
.inner
)
...
...
@@ -128,7 +146,6 @@ impl RocksDB {
}
}
pub
fn
get
<
'a
>
(
&
self
,
key
:
&
[
u8
])
->
RocksDBResult
<
'a
,
RocksDBVector
,
&
str
>
{
unsafe
{
...
...
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