From c05fab783a017596f50f50f8edac12a2fee39c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 2 Jan 2019 17:52:18 +0100 Subject: [PATCH] fix: Write and Read DocumentKeyAttr in big endian --- src/database/document_key.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/database/document_key.rs b/src/database/document_key.rs index f56bda1dd..cfcb34ad6 100644 --- a/src/database/document_key.rs +++ b/src/database/document_key.rs @@ -2,7 +2,7 @@ use std::io::{Cursor, Read, Write}; use std::mem::size_of; use std::fmt; -use byteorder::{NativeEndian, WriteBytesExt, ReadBytesExt}; +use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; use crate::database::schema::SchemaAttr; use crate::DocumentId; @@ -19,7 +19,7 @@ impl DocumentKey { let mut wtr = Cursor::new(&mut buffer[..]); wtr.write_all(b"doc-").unwrap(); - wtr.write_u64::(id.0).unwrap(); + wtr.write_u64::(id.0).unwrap(); DocumentKey(buffer) } @@ -43,7 +43,7 @@ impl DocumentKey { } pub fn document_id(&self) -> DocumentId { - let id = (&self.0[4..]).read_u64::().unwrap(); + let id = (&self.0[4..]).read_u64::().unwrap(); DocumentId(id) } } @@ -73,7 +73,7 @@ impl DocumentKeyAttr { let mut wtr = Cursor::new(&mut buffer[..]); wtr.write_all(&raw_key).unwrap(); wtr.write_all(b"-").unwrap(); - wtr.write_u16::(attr.0).unwrap(); + wtr.write_u16::(attr.0).unwrap(); DocumentKeyAttr(buffer) } @@ -97,13 +97,13 @@ impl DocumentKeyAttr { } pub fn document_id(&self) -> DocumentId { - let id = (&self.0[4..]).read_u64::().unwrap(); + let id = (&self.0[4..]).read_u64::().unwrap(); DocumentId(id) } pub fn attribute(&self) -> SchemaAttr { let offset = 4 + size_of::() + 1; - let value = (&self.0[offset..]).read_u16::().unwrap(); + let value = (&self.0[offset..]).read_u16::().unwrap(); SchemaAttr::new(value) }