mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-23 11:40:40 +00:00
Prettifying json
This commit is contained in:
@@ -184,11 +184,13 @@ impl Index {
|
||||
}
|
||||
|
||||
pub fn save_metas(&mut self,) -> io::Result<()> {
|
||||
let encoded = {
|
||||
let metas_lock = self.metas.read().unwrap();
|
||||
json::encode(&*metas_lock).unwrap()
|
||||
let mut w = Vec::new();
|
||||
{
|
||||
let metas_lock = self.metas.read().unwrap() ;
|
||||
let data = write!(&mut w, "{}\n", json::as_pretty_json(&*metas_lock));
|
||||
};
|
||||
try!(self.rw_directory()).atomic_write(&META_FILEPATH, encoded.as_bytes())
|
||||
try!(self.rw_directory())
|
||||
.atomic_write(&META_FILEPATH, &w[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ impl IndexWriter {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn add(&mut self, doc: &Document) -> io::Result<()> {
|
||||
Rc::get_mut(&mut self.segment_writer).unwrap().add(&doc, &self.schema)
|
||||
pub fn add_document(&mut self, doc: &Document) -> io::Result<()> {
|
||||
Rc::get_mut(&mut self.segment_writer).unwrap().add_document(&doc, &self.schema)
|
||||
}
|
||||
|
||||
pub fn commit(&mut self,) -> io::Result<Segment> {
|
||||
@@ -96,7 +96,7 @@ impl SegmentWriter {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn add(&mut self, doc: &Document, schema: &Schema) -> io::Result<()> {
|
||||
pub fn add_document(&mut self, doc: &Document, schema: &Schema) -> io::Result<()> {
|
||||
let doc_id = self.max_doc;
|
||||
for field_value in doc.text_fields() {
|
||||
let field_options = schema.text_field_options(&field_value.field);
|
||||
|
||||
Reference in New Issue
Block a user