diff --git a/Cargo.toml b/Cargo.toml index cd3e6b722..bf59afcc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,24 +13,24 @@ readme = "README.md" keywords = ["search", "information", "retrieval"] [dependencies] -byteorder = "0.4" -memmap = "0.2" -lazy_static = "0.1" -regex = "0.1" -fst = "0.1.34" -atomicwrites = "0.0.14" +byteorder = "1.0" +memmap = "0.5" +lazy_static = "0.2.1" +regex = "0.2" +fst = "0.1.35" +atomicwrites = "0.1.3" tempfile = "2.1" rustc-serialize = "0.3" -log = "0.3" -combine = "2.0.*" +log = "0.3.6" +combine = "2.2" tempdir = "0.3" -bincode = "0.4" -libc = {version = "0.2.6", optional=true} -num_cpus = "0.2" -itertools = "0.4" -lz4 = "1.13" +bincode = "0.5" +libc = {version = "0.2.20", optional=true} +num_cpus = "1.2" +itertools = "0.5.9" +lz4 = "1.20" time = "0.1" -uuid = "0.1" +uuid = { version = "0.4", features = ["v4", "rustc-serialize"] } chan = "0.1" version = "2" crossbeam = "0.2" diff --git a/src/common/serialize.rs b/src/common/serialize.rs index 29c7b2986..b1ffab6cd 100644 --- a/src/common/serialize.rs +++ b/src/common/serialize.rs @@ -1,4 +1,3 @@ - use byteorder::{ReadBytesExt, WriteBytesExt}; use byteorder::LittleEndian as Endianness; use std::fmt; @@ -6,20 +5,12 @@ use std::io::Write; use std::io::Read; use std::io; use common::VInt; -use byteorder; pub trait BinarySerializable : fmt::Debug + Sized { fn serialize(&self, writer: &mut Write) -> io::Result; fn deserialize(reader: &mut Read) -> io::Result; } -fn convert_byte_order_error(byteorder_error: byteorder::Error) -> io::Error { - match byteorder_error { - byteorder::Error::UnexpectedEOF => io::Error::new(io::ErrorKind::InvalidData, "Reached EOF unexpectedly"), - byteorder::Error::Io(e) => e, - } -} - impl BinarySerializable for () { fn serialize(&self, _: &mut Write) -> io::Result { Ok(0) @@ -62,12 +53,10 @@ impl BinarySerializable for u32 { fn serialize(&self, writer: &mut Write) -> io::Result { writer.write_u32::(*self) .map(|_| 4) - .map_err(convert_byte_order_error) } fn deserialize(reader: &mut Read) -> io::Result { reader.read_u32::() - .map_err(convert_byte_order_error) } } @@ -76,11 +65,9 @@ impl BinarySerializable for u64 { fn serialize(&self, writer: &mut Write) -> io::Result { writer.write_u64::(*self) .map(|_| 8) - .map_err(convert_byte_order_error) } fn deserialize(reader: &mut Read) -> io::Result { reader.read_u64::() - .map_err(convert_byte_order_error) } } @@ -88,12 +75,11 @@ impl BinarySerializable for u64 { impl BinarySerializable for u8 { fn serialize(&self, writer: &mut Write) -> io::Result { // TODO error - try!(writer.write_u8(*self).map_err(convert_byte_order_error)); + try!(writer.write_u8(*self)); Ok(1) } fn deserialize(reader: &mut Read) -> io::Result { reader.read_u8() - .map_err(convert_byte_order_error) } } @@ -123,7 +109,7 @@ mod test { fn serialize_test(v: T, num_bytes: usize) { let mut buffer: Vec = Vec::new(); - + if num_bytes != 0 { assert_eq!(v.serialize(&mut buffer).unwrap(), num_bytes); assert_eq!(buffer.len(), num_bytes); diff --git a/src/core/segment_id.rs b/src/core/segment_id.rs index 81490166a..3d77668b3 100644 --- a/src/core/segment_id.rs +++ b/src/core/segment_id.rs @@ -23,12 +23,12 @@ lazy_static! { // During tests, we generate the segment id in a autoincrement manner // for consistency of segment id between run. // -// The order of the test execution is not guaranteed, but the order +// The order of the test execution is not guaranteed, but the order // of segments within a single test is guaranteed. #[cfg(test)] fn create_uuid() -> Uuid { let new_auto_inc_id = (*AUTO_INC_COUNTER).fetch_add(1, atomic::Ordering::SeqCst); - Uuid::from_fields(new_auto_inc_id as u32, 0, 0, &*EMPTY_ARR) + Uuid::from_fields(new_auto_inc_id as u32, 0, 0, &*EMPTY_ARR).unwrap() } #[cfg(not(test))] @@ -40,15 +40,15 @@ impl SegmentId { pub fn generate_random() -> SegmentId { SegmentId(create_uuid()) } - + pub fn short_uuid_string(&self,) -> String { - (&self.0.to_simple_string()[..8]).to_string() + (&self.0.simple().to_string()[..8]).to_string() } - + pub fn uuid_string(&self,) -> String { - self.0.to_simple_string() + self.0.simple().to_string() } - + pub fn relative_path(&self, component: SegmentComponent) -> PathBuf { let filename = self.uuid_string() + component.path_suffix(); PathBuf::from(filename)