Skip to content

Commit

Permalink
need to rework storage strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
slyphon committed Jun 27, 2018
1 parent 34cb2e9 commit 6ec0e55
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ lcov
cdb.rs
*.cdb
compile_commands.json

*.cmd
core
8 changes: 4 additions & 4 deletions deps/ccommon/src/cc_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ debug_setup(debug_options_st *options)
}

/* some adjustment on signal handling */
if (signal_override(SIGSEGV, "printing stacktrace when segfault", 0, 0,
_stacktrace) < 0) {
goto error;
}
// if (signal_override(SIGSEGV, "printing stacktrace when segfault", 0, 0,
// _stacktrace) < 0) {
// goto error;
// }

/* to allow logrotate with nocopytruncate, use SIGHUP to reopen log */
if (signal_override(SIGHUP, "reopen log file", 0, 0, _logrotate) < 0) {
Expand Down
8 changes: 7 additions & 1 deletion src/storage/cdb/cdb_rs/src/cdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub type Result<T> = result::Result<T, CDBError>;

// idea from https://raw.githubusercontent.com/jothan/cordoba/master/src/lib.rs
#[derive(Copy, Clone, Eq, PartialEq)]
#[repr(C)]
struct CDBHash(u32);

impl CDBHash {
Expand Down Expand Up @@ -70,6 +71,7 @@ impl<'a> From<&'a CDBHash> for u32 {
}

#[derive(Copy, Clone)]
#[repr(C)]
struct Bucket {
ptr: usize,
num_ents: usize,
Expand All @@ -95,6 +97,7 @@ impl Bucket {
}

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(C)]
struct IndexEntryPos(usize);

impl From<IndexEntryPos> for usize {
Expand All @@ -104,6 +107,7 @@ impl From<IndexEntryPos> for usize {
}

#[derive(Clone, Debug)]
#[repr(C)]
pub struct KV {
pub k: Bytes,
pub v: Bytes,
Expand All @@ -126,6 +130,7 @@ struct IndexEntry {
ptr: usize, // pointer to the absolute position of the data in the db
}

#[repr(C)]
pub struct KVIter {
cdb: Box<CDB>,
bkt_idx: usize,
Expand Down Expand Up @@ -168,7 +173,7 @@ impl Iterator for KVIter {
};

self.entry_n += 1;

if idx_ent.ptr == 0 {
continue
} else {
Expand All @@ -182,6 +187,7 @@ impl Iterator for KVIter {
}

#[derive(Debug)]
#[repr(C)]
pub struct CDB {
data: SliceFactory,
}
Expand Down
6 changes: 4 additions & 2 deletions src/storage/cdb/cdb_rs/src/cdb/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::sync::Arc;
use super::Result;

#[derive(Debug)]
#[repr(C)]
pub enum SliceFactory {
HeapStorage(Bytes),
MmapStorage(MMapWrap),
Expand Down Expand Up @@ -95,6 +96,7 @@ impl Clone for SliceFactory {
}

#[derive(Debug)]
#[repr(C)]
pub struct MMapWrap {
inner: Arc<Mmap>
}
Expand All @@ -120,6 +122,7 @@ impl Clone for MMapWrap {
}

#[derive(Debug)]
#[repr(C)]
pub struct FileWrap {
inner: RefCell<File>,
path: String,
Expand Down Expand Up @@ -164,6 +167,7 @@ impl Clone for FileWrap {
}
}

#[repr(C)]
struct BMString(BytesMut);

impl ToString for BMString {
Expand Down Expand Up @@ -225,5 +229,3 @@ mod tests {
})
}
}


0 comments on commit 6ec0e55

Please sign in to comment.