summaryrefslogtreecommitdiffstats
path: root/src/fastfield/reader.rs
diff options
context:
space:
mode:
authorPaul Masurel <paul.masurel@gmail.com>2017-08-28 17:42:26 +0900
committerPaul Masurel <paul.masurel@gmail.com>2017-08-28 18:22:41 +0900
commitf8710bd4b0b914d37be2671d92d67a4e5fbd941b (patch)
tree48adfbbbd984a7011ff3e9990a24052d0bb4d1da /src/fastfield/reader.rs
parent8d05b8f7b217e877622524e9507bc7f00c82a476 (diff)
Format
Diffstat (limited to 'src/fastfield/reader.rs')
-rw-r--r--src/fastfield/reader.rs30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/fastfield/reader.rs b/src/fastfield/reader.rs
index 0c59cba..8e37688 100644
--- a/src/fastfield/reader.rs
+++ b/src/fastfield/reader.rs
@@ -2,7 +2,7 @@ use directory::ReadOnlySource;
use common::{self, BinarySerializable};
use common::bitpacker::{compute_num_bits, BitUnpacker};
use DocId;
-use schema::{SchemaBuilder};
+use schema::SchemaBuilder;
use std::path::Path;
use schema::FAST;
use directory::{WritePtr, RAMDirectory, Directory};
@@ -106,10 +106,10 @@ impl FastFieldReader for U64FastFieldReader {
let amplitude: u64;
{
let mut cursor = data.as_slice();
- min_value = u64::deserialize(&mut cursor)
- .expect("Failed to read the min_value of fast field.");
- amplitude = u64::deserialize(&mut cursor)
- .expect("Failed to read the amplitude of fast field.");
+ min_value =
+ u64::deserialize(&mut cursor).expect("Failed to read the min_value of fast field.");
+ amplitude =
+ u64::deserialize(&mut cursor).expect("Failed to read the amplitude of fast field.");
}
let max_value = min_value + amplitude;
@@ -130,15 +130,14 @@ impl From<Vec<u64>> for U64FastFieldReader {
let mut schema_builder = SchemaBuilder::default();
let field = schema_builder.add_u64_field("field", FAST);
let schema = schema_builder.build();
- let path = Path::new("test");
+ let path = Path::new("__dummy__");
let mut directory: RAMDirectory = RAMDirectory::create();
{
- let write: WritePtr = directory.open_write(Path::new("test")).unwrap();
- let mut serializer = FastFieldSerializer::from_write(write).unwrap();
+ let write: WritePtr = directory.open_write(path).expect("With a RAMDirectory, this should never fail.");
+ let mut serializer = FastFieldSerializer::from_write(write).expect("With a RAMDirectory, this should never fail.");
let mut fast_field_writers = FastFieldsWriter::from_schema(&schema);
- // TODO Error not unwrap
{
- let fast_field_writer = fast_field_writers.get_field_writer(field).unwrap();
+ let fast_field_writer = fast_field_writers.get_field_writer(field).expect("With a RAMDirectory, this should never fail.");
for val in vals {
fast_field_writer.add_val(val);
}
@@ -147,13 +146,12 @@ impl From<Vec<u64>> for U64FastFieldReader {
serializer.close().unwrap();
}
- let source = directory
- .open_read(path)
- .expect("Failed to open the file");
- let composite_file = CompositeFile::open(source)
- .expect("Failed to read the composite file");
+ let source = directory.open_read(path).expect("Failed to open the file");
+ let composite_file =
+ CompositeFile::open(source).expect("Failed to read the composite file");
- let field_source = composite_file.open_read(field)
+ let field_source = composite_file
+ .open_read(field)
.expect("File component not found");
U64FastFieldReader::open(field_source)
}