diff --git a/src/db/db_format.rs b/src/db/db_format.rs index d76deff60e31536f67446f5a2e59fec578630a11..d69d6265687a47973c3f9114a4e64aa87d637e0a 100644 --- a/src/db/db_format.rs +++ b/src/db/db_format.rs @@ -102,36 +102,36 @@ impl Default for ParsedInternalKey { } impl ParsedInternalKey { - fn new(u: Slice, /* seq: SequenceNumber, */ t: ValueType) -> ParsedInternalKey { - ParsedInternalKey { + fn new(u: Slice, seq: u64, t: ValueType) -> Self { + Self { user_key: u, - sequence: 0, + sequence: seq, value_type: t, } } - fn debug_string() -> Slice { + fn debug_string(&self) -> Slice { Slice::default() } /// Return the length of the encoding of "key". - fn internal_key_encoding_length(key: ParsedInternalKey) -> usize { + fn internal_key_encoding_length(&self, key: ParsedInternalKey) -> usize { key.user_key.size() + 8 } - fn append_internal_key(key : ParsedInternalKey) -> Slice { + fn append_internal_key(&self, key : ParsedInternalKey) -> Slice { todo!() } /// Attempt to parse an internal key from "internal_key". On success, /// stores the parsed data in "*result", and returns true. /// On error, returns false, leaves "*result" in an undefined state. - fn parse_internal_key(internal_key : Slice, target: ParsedInternalKey) -> bool { + fn parse_internal_key(&self, internal_key : Slice, target: ParsedInternalKey) -> bool { todo!() } /// Returns the user key portion of an internal key. - fn extract_user_key(internal_key : Slice) -> Slice { + fn extract_user_key(&self, internal_key : Slice) -> Slice { todo!() } } diff --git a/src/db/log_writer.rs b/src/db/log_writer.rs index 48e567cda808384f73fa3c57b73a2ebeb7eb0338..42406db3f609f86e330a8e039f8f53ee9541a3c3 100644 --- a/src/db/log_writer.rs +++ b/src/db/log_writer.rs @@ -79,7 +79,7 @@ impl LogWriter { header[6] = record_type; let mut crc = CRC::extend(self.type_crc[record_type as usize], data); crc = CRC::mask(crc); - Coding::encode_fixed32(&mut crc, header.as_mut(), 0); + Coding::encode_fixed32(crc, header.as_mut(), 0); self.file_writer.write(header.as_ref())?; self.block_offset += K_HEADER_SIZE; if !data.is_empty() { diff --git a/src/db/mem_table.rs b/src/db/mem_table.rs index 56566ce53a72225323ef3cf32f48773c25891143..b9720c2f7413f530415843a9ef2d283e3420a169 100644 --- a/src/db/mem_table.rs +++ b/src/db/mem_table.rs @@ -17,7 +17,7 @@ pub struct MemTable { } /// 临时, 查找键 -struct LookupKey {} +pub struct LookupKey {} impl MemTable { diff --git a/src/table/format.rs b/src/table/format.rs index d956954d18cf4af447d688db36883eadf46400a4..01c9610c998bfc3f3532bf7df37e4868de6d1577 100644 --- a/src/table/format.rs +++ b/src/table/format.rs @@ -168,7 +168,7 @@ impl BlockTrait for BlockHandle { self.size_ = size; } - fn encode_to(&self) -> Slice { + fn encode_to(&self) -> Result { todo!() // // Sanity check that all fields have been set @@ -181,7 +181,7 @@ impl BlockTrait for BlockHandle { // Slice::default() } - fn decode_from(&self, input: Slice) -> Result { + fn decode_from(&mut self, input: Slice) -> Result<()> { todo!() } } @@ -201,7 +201,7 @@ impl FootTrait for Footer { todo!() } - fn set_metaindex_handle(&self, h: BlockHandle) { + fn set_metaindex_handle(&mut self, h: BlockHandle) { todo!() } @@ -209,15 +209,15 @@ impl FootTrait for Footer { todo!() } - fn set_index_handle(&self, h: BlockHandle) { + fn set_index_handle(&mut self, h: BlockHandle) { todo!() } - fn encode_to(&self) -> Slice { + fn encode_to(&self) -> Result { todo!() } - fn decode_from(&self, input: Slice) -> Result { + fn decode_from(&mut self, input: Slice) -> Result<()> { todo!() } } diff --git a/src/util/cache.rs b/src/util/cache.rs index 274d715332aca3de2c61d51120c2fd53d2b1f492..8d69c2d2621a2775d5f270a6f922127093127ca1 100644 --- a/src/util/cache.rs +++ b/src/util/cache.rs @@ -4,7 +4,7 @@ use crate::util::slice::Slice; use crate::util::Result; -struct Handle {} +pub struct Handle {} pub struct LRUHandle { key: Slice,