-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalize LMDB usage and add support for multiple backing stores
Signed-off-by: Victor Porof <[email protected]>
- Loading branch information
1 parent
8b51df1
commit a4d76eb
Showing
33 changed files
with
1,583 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2018-2019 Mozilla | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
mod common; | ||
mod impl_lmdb; | ||
mod traits; | ||
|
||
pub use common::*; | ||
pub use traits::*; | ||
|
||
pub use impl_lmdb::DatabaseImpl as LmdbDatabase; | ||
pub use impl_lmdb::EnvironmentBuilderImpl as Lmdb; | ||
pub use impl_lmdb::EnvironmentImpl as LmdbEnvironment; | ||
pub use impl_lmdb::ErrorImpl as LmdbError; | ||
pub use impl_lmdb::RoCursorImpl as LmdbRoCursor; | ||
pub use impl_lmdb::RoTransactionImpl as LmdbRoTransaction; | ||
pub use impl_lmdb::RwTransactionImpl as LmdbRwTransaction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2018-2019 Mozilla | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
#![allow(non_camel_case_types)] | ||
|
||
pub enum EnvironmentFlags { | ||
FIXED_MAP, | ||
NO_SUB_DIR, | ||
WRITE_MAP, | ||
READ_ONLY, | ||
NO_META_SYNC, | ||
NO_SYNC, | ||
MAP_ASYNC, | ||
NO_TLS, | ||
NO_LOCK, | ||
NO_READAHEAD, | ||
NO_MEM_INIT, | ||
} | ||
|
||
pub enum DatabaseFlags { | ||
REVERSE_KEY, | ||
DUP_SORT, | ||
INTEGER_KEY, | ||
DUP_FIXED, | ||
INTEGER_DUP, | ||
REVERSE_DUP, | ||
} | ||
|
||
pub enum WriteFlags { | ||
NO_OVERWRITE, | ||
NO_DUP_DATA, | ||
CURRENT, | ||
APPEND, | ||
APPEND_DUP, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2018-2019 Mozilla | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
mod cursor; | ||
mod database; | ||
mod environment; | ||
mod error; | ||
mod flags; | ||
mod info; | ||
mod iter; | ||
mod stat; | ||
mod transaction; | ||
|
||
pub use cursor::{ | ||
RoCursorImpl, | ||
RwCursorImpl, | ||
}; | ||
pub use database::DatabaseImpl; | ||
pub use environment::{ | ||
EnvironmentBuilderImpl, | ||
EnvironmentImpl, | ||
}; | ||
pub use error::ErrorImpl; | ||
pub use flags::{ | ||
DatabaseFlagsImpl, | ||
EnvironmentFlagsImpl, | ||
WriteFlagsImpl, | ||
}; | ||
pub use info::InfoImpl; | ||
pub use iter::IterImpl; | ||
pub use stat::StatImpl; | ||
pub use transaction::{ | ||
RoTransactionImpl, | ||
RwTransactionImpl, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2018-2019 Mozilla | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
use lmdb::Cursor; | ||
|
||
use super::IterImpl; | ||
use crate::backend::traits::BackendRoCursor; | ||
|
||
#[derive(Debug)] | ||
pub struct RoCursorImpl<'env>(pub(crate) lmdb::RoCursor<'env>); | ||
|
||
impl<'env> BackendRoCursor<'env> for RoCursorImpl<'env> { | ||
type Iter = IterImpl<'env>; | ||
|
||
fn iter(&mut self) -> Self::Iter { | ||
IterImpl(self.0.iter()) | ||
} | ||
|
||
fn iter_from<K>(&mut self, key: K) -> Self::Iter | ||
where | ||
K: AsRef<[u8]>, | ||
{ | ||
IterImpl(self.0.iter_from(key)) | ||
} | ||
|
||
fn iter_dup_of<K>(&mut self, key: K) -> Self::Iter | ||
where | ||
K: AsRef<[u8]>, | ||
{ | ||
IterImpl(self.0.iter_dup_of(key)) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct RwCursorImpl<'env>(pub(crate) lmdb::RwCursor<'env>); | ||
|
||
impl<'env> BackendRoCursor<'env> for RwCursorImpl<'env> { | ||
type Iter = IterImpl<'env>; | ||
|
||
fn iter(&mut self) -> Self::Iter { | ||
IterImpl(self.0.iter()) | ||
} | ||
|
||
fn iter_from<K>(&mut self, key: K) -> Self::Iter | ||
where | ||
K: AsRef<[u8]>, | ||
{ | ||
IterImpl(self.0.iter_from(key)) | ||
} | ||
|
||
fn iter_dup_of<K>(&mut self, key: K) -> Self::Iter | ||
where | ||
K: AsRef<[u8]>, | ||
{ | ||
IterImpl(self.0.iter_dup_of(key)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2018-2019 Mozilla | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
use crate::backend::traits::BackendDatabase; | ||
|
||
#[derive(Debug, Eq, PartialEq, Copy, Clone)] | ||
pub struct DatabaseImpl(pub(crate) lmdb::Database); | ||
|
||
impl BackendDatabase for DatabaseImpl {} |
Oops, something went wrong.