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
bd910578
Commit
bd910578
authored
Jan 07, 2015
by
Tyler Neely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
triggers ICE
parent
44efc60b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
rocksdb.rs
src/rocksdb.rs
+10
-14
No files found.
src/rocksdb.rs
View file @
bd910578
...
@@ -19,7 +19,6 @@ use std::io::{IoError};
...
@@ -19,7 +19,6 @@ use std::io::{IoError};
use
std
::
c_vec
::
CVec
;
use
std
::
c_vec
::
CVec
;
use
std
::
c_str
::
CString
;
use
std
::
c_str
::
CString
;
use
std
::
str
::
from_utf8
;
use
std
::
str
::
from_utf8
;
use
std
::
string
::
raw
::
from_buf_len
;
use
std
::
ptr
;
use
std
::
ptr
;
use
std
::
mem
;
use
std
::
mem
;
use
std
::
ptr
::
Unique
;
use
std
::
ptr
::
Unique
;
...
@@ -485,7 +484,7 @@ impl RocksDBVector {
...
@@ -485,7 +484,7 @@ impl RocksDBVector {
// RocksDBResult exists because of the inherent difference between
// RocksDBResult exists because of the inherent difference between
// an operational failure and the absence of a possible result.
// an operational failure and the absence of a possible result.
#[deriv
ing
(Clone,
PartialEq,
PartialOrd,
Eq,
Ord,
Show)]
#[deriv
e
(Clone,
PartialEq,
PartialOrd,
Eq,
Ord,
Show)]
pub
enum
RocksDBResult
<
'a
,
T
,
E
>
{
pub
enum
RocksDBResult
<
'a
,
T
,
E
>
{
Some
(
T
),
Some
(
T
),
None
,
None
,
...
@@ -493,8 +492,7 @@ pub enum RocksDBResult<'a,T,E> {
...
@@ -493,8 +492,7 @@ pub enum RocksDBResult<'a,T,E> {
}
}
impl
<
'a
,
T
,
E
>
RocksDBResult
<
'a
,
T
,
E
>
{
impl
<
'a
,
T
,
E
>
RocksDBResult
<
'a
,
T
,
E
>
{
#[unstable
=
"waiting for unboxed closures"
]
pub
fn
map
<
U
>
(
self
,
f
:
FnMut
(
T
)
->
U
)
->
RocksDBResult
<
'a
,
U
,
E
>
{
pub
fn
map
<
U
>
(
self
,
f
:
|
T
|
->
U
)
->
RocksDBResult
<
U
,
E
>
{
match
self
{
match
self
{
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
f
(
x
)),
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
f
(
x
)),
RocksDBResult
::
None
=>
RocksDBResult
::
None
,
RocksDBResult
::
None
=>
RocksDBResult
::
None
,
...
@@ -512,8 +510,7 @@ impl <'a,T,E> RocksDBResult<'a,T,E> {
...
@@ -512,8 +510,7 @@ impl <'a,T,E> RocksDBResult<'a,T,E> {
}
}
}
}
#[unstable
=
"waiting for unboxed closures"
]
pub
fn
on_error
<
U
>
(
self
,
f
:
FnMut
(
E
)
->
U
)
->
RocksDBResult
<
'a
,
T
,
U
>
{
pub
fn
on_error
<
U
>
(
self
,
f
:
|
E
|
->
U
)
->
RocksDBResult
<
T
,
U
>
{
match
self
{
match
self
{
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
x
),
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
x
),
RocksDBResult
::
None
=>
RocksDBResult
::
None
,
RocksDBResult
::
None
=>
RocksDBResult
::
None
,
...
@@ -521,8 +518,7 @@ impl <'a,T,E> RocksDBResult<'a,T,E> {
...
@@ -521,8 +518,7 @@ impl <'a,T,E> RocksDBResult<'a,T,E> {
}
}
}
}
#[unstable
=
"waiting for unboxed closures"
]
pub
fn
on_absent
(
self
,
f
:
FnMut
()
->
())
->
RocksDBResult
<
'a
,
T
,
E
>
{
pub
fn
on_absent
(
self
,
f
:
||
->
())
->
RocksDBResult
<
T
,
E
>
{
match
self
{
match
self
{
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
x
),
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
x
),
RocksDBResult
::
None
=>
{
RocksDBResult
::
None
=>
{
...
@@ -593,7 +589,7 @@ impl <'a> MergeOperands<'a> {
...
@@ -593,7 +589,7 @@ impl <'a> MergeOperands<'a> {
}
}
}
}
impl
<
'a
>
Iterator
<&
'a
[
u8
]
>
for
&
'a
mut
MergeOperands
<
'a
>
{
impl
<
'a
>
Iterator
for
&
'a
mut
MergeOperands
<
'a
>
{
fn
next
(
&
mut
self
)
->
Option
<&
'a
[
u8
]
>
{
fn
next
(
&
mut
self
)
->
Option
<&
'a
[
u8
]
>
{
use
std
::
raw
::
Slice
;
use
std
::
raw
::
Slice
;
match
self
.cursor
==
self
.num_operands
{
match
self
.cursor
==
self
.num_operands
{
...
@@ -608,8 +604,8 @@ impl <'a> Iterator<&'a [u8]> for &'a mut MergeOperands<'a> {
...
@@ -608,8 +604,8 @@ impl <'a> Iterator<&'a [u8]> for &'a mut MergeOperands<'a> {
as
*
const
size_t
;
as
*
const
size_t
;
let
len
=
*
len_ptr
as
uint
;
let
len
=
*
len_ptr
as
uint
;
let
ptr
=
base
+
(
spacing
*
self
.cursor
);
let
ptr
=
base
+
(
spacing
*
self
.cursor
);
let
op
=
from
_buf_len
(
*
(
ptr
as
*
const
*
const
u8
),
len
);
let
op
=
String
::
from_raw
_buf_len
(
*
(
ptr
as
*
const
*
const
u8
),
len
);
let
des
:
Option
<
uint
>
=
from_
str
(
op
.as_slice
());
let
des
:
Option
<
uint
>
=
from_
utf8
(
op
.as_slice
());
self
.cursor
+=
1
;
self
.cursor
+=
1
;
Some
(
mem
::
transmute
(
Slice
{
data
:
*
(
ptr
as
*
const
*
const
u8
)
Some
(
mem
::
transmute
(
Slice
{
data
:
*
(
ptr
as
*
const
*
const
u8
)
as
*
const
u8
,
len
:
len
}))
as
*
const
u8
,
len
:
len
}))
...
@@ -657,8 +653,8 @@ extern "C" fn full_merge_callback(
...
@@ -657,8 +653,8 @@ extern "C" fn full_merge_callback(
&
mut
MergeOperands
::
new
(
operands_list
,
&
mut
MergeOperands
::
new
(
operands_list
,
operands_list_len
,
operands_list_len
,
num_operands
);
num_operands
);
let
key
=
from
_buf_len
(
key
as
*
const
u8
,
key_len
as
uint
);
let
key
=
String
::
from_raw
_buf_len
(
key
as
*
const
u8
,
key_len
as
uint
);
let
oldval
=
from
_buf_len
(
existing_value
as
*
const
u8
,
let
oldval
=
String
::
from_raw
_buf_len
(
existing_value
as
*
const
u8
,
existing_value_len
as
uint
);
existing_value_len
as
uint
);
let
mut
result
=
let
mut
result
=
(
cb
.merge_fn
)(
key
.as_bytes
(),
Some
(
oldval
.as_bytes
()),
operands
);
(
cb
.merge_fn
)(
key
.as_bytes
(),
Some
(
oldval
.as_bytes
()),
operands
);
...
@@ -690,7 +686,7 @@ extern "C" fn partial_merge_callback(
...
@@ -690,7 +686,7 @@ extern "C" fn partial_merge_callback(
let
operands
=
&
mut
MergeOperands
::
new
(
operands_list
,
let
operands
=
&
mut
MergeOperands
::
new
(
operands_list
,
operands_list_len
,
operands_list_len
,
num_operands
);
num_operands
);
let
key
=
from
_buf_len
(
key
as
*
const
u8
,
key_len
as
uint
);
let
key
=
String
::
from_raw
_buf_len
(
key
as
*
const
u8
,
key_len
as
uint
);
let
mut
result
=
(
cb
.merge_fn
)(
key
.as_bytes
(),
None
,
operands
);
let
mut
result
=
(
cb
.merge_fn
)(
key
.as_bytes
(),
None
,
operands
);
result
.shrink_to_fit
();
result
.shrink_to_fit
();
//TODO(tan) investigate zero-copy techniques to improve performance
//TODO(tan) investigate zero-copy techniques to improve performance
...
...
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