Store throws an io::Error

This commit is contained in:
Paul Masurel
2016-08-20 16:38:53 +09:00
parent 2e1ad4bbce
commit 07997e67c9
2 changed files with 3 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
use Result;
use DocId;
use std::io;
use schema::Schema;
use schema::Document;
use schema::Term;
@@ -99,7 +100,7 @@ impl SegmentWriter {
self.segment_serializer)
}
pub fn add_document(&mut self, doc: &Document, schema: &Schema) -> Result<()> {
pub fn add_document(&mut self, doc: &Document, schema: &Schema) -> io::Result<()> {
let doc_id = self.max_doc;
for (field, field_values) in doc.get_sorted_fields() {
// TODO pos collision if the field is redundant

View File

@@ -83,9 +83,7 @@ impl StoreWriter {
fn write_and_compress_block(&mut self,) -> io::Result<()> {
self.intermediary_buffer.clear();
{
let mut encoder = lz4::EncoderBuilder::new()
.build(&mut self.intermediary_buffer)
.unwrap();
let mut encoder = try!(lz4::EncoderBuilder::new().build(&mut self.intermediary_buffer));
try!(encoder.write_all(&self.current_block));
let (_, encoder_result) = encoder.finish();
try!(encoder_result);