fix: Change the way the iterator upper bound is computed

This commit is contained in:
Clément Renault 2018-12-07 15:31:58 +01:00
parent 4626c77eac
commit 7c98771068
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
3 changed files with 10 additions and 2 deletions

View File

@ -43,7 +43,7 @@ impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
{ {
let mut options = ReadOptions::new(); let mut options = ReadOptions::new();
let lower = DocumentKey::new(self.document_id); let lower = DocumentKey::new(self.document_id);
let upper = DocumentKey::new(self.document_id + 1); let upper = lower.with_attribute_max();
options.set_iterate_lower_bound(lower.as_ref()); options.set_iterate_lower_bound(lower.as_ref());
options.set_iterate_upper_bound(upper.as_ref()); options.set_iterate_upper_bound(upper.as_ref());

View File

@ -38,6 +38,10 @@ impl DocumentKey {
DocumentKeyAttr::new(self.document_id(), attr) DocumentKeyAttr::new(self.document_id(), attr)
} }
pub fn with_attribute_max(&self) -> DocumentKeyAttr {
DocumentKeyAttr::new(self.document_id(), SchemaAttr::max())
}
pub fn document_id(&self) -> DocumentId { pub fn document_id(&self) -> DocumentId {
(&self.0[4..]).read_u64::<NativeEndian>().unwrap() (&self.0[4..]).read_u64::<NativeEndian>().unwrap()
} }

View File

@ -1,9 +1,9 @@
use std::collections::{HashMap, BTreeMap}; use std::collections::{HashMap, BTreeMap};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::{fmt, u32};
use std::path::Path; use std::path::Path;
use std::ops::BitOr; use std::ops::BitOr;
use std::fs::File; use std::fs::File;
use std::fmt;
use serde_derive::{Serialize, Deserialize}; use serde_derive::{Serialize, Deserialize};
use linked_hash_map::LinkedHashMap; use linked_hash_map::LinkedHashMap;
@ -127,6 +127,10 @@ impl SchemaAttr {
SchemaAttr(value) SchemaAttr(value)
} }
pub fn max() -> SchemaAttr {
SchemaAttr(u32::MAX)
}
pub fn as_u32(&self) -> u32 { pub fn as_u32(&self) -> u32 {
self.0 self.0
} }