Browse Source

NOBUG Updating to follow tantivy

develop
Paul Masurel 8 years ago
parent
commit
092f36cc39
3 changed files with 12 additions and 4 deletions
  1. +7
    -0
      Cargo.toml
  2. +4
    -3
      src/commands/index.rs
  3. +1
    -1
      src/commands/merge.rs

+ 7
- 0
Cargo.toml View File

@@ -38,3 +38,10 @@ env_logger = "0.3"
[[bin]] [[bin]]
name = "tantivy" name = "tantivy"
path = "src/main.rs" path = "src/main.rs"


[profile.release]
opt-level = 3
debug = false
lto = true
debug-assertions = false

+ 4
- 3
src/commands/index.rs View File

@@ -68,7 +68,6 @@ fn run_index(directory: PathBuf, document_source: DocumentSource, buffer_size_pe
} }
drop(doc_sender); drop(doc_sender);



let mut index_writer = try!( let mut index_writer = try!(
if num_threads > 0 { if num_threads > 0 {
index.writer_with_num_threads(num_threads, buffer_size_per_thread) index.writer_with_num_threads(num_threads, buffer_size_per_thread)
@@ -80,7 +79,7 @@ fn run_index(directory: PathBuf, document_source: DocumentSource, buffer_size_pe




let index_result = index_documents(&mut index_writer, doc_receiver); let index_result = index_documents(&mut index_writer, doc_receiver);
match index_result {
try!(match index_result {
Ok(docstamp) => { Ok(docstamp) => {
println!("Commit succeed, docstamp at {}", docstamp); println!("Commit succeed, docstamp at {}", docstamp);
Ok(()) Ok(())
@@ -91,7 +90,9 @@ fn run_index(directory: PathBuf, document_source: DocumentSource, buffer_size_pe
println!("Rollback succeeded"); println!("Rollback succeeded");
Err(e) Err(e)
} }
}
});
index_writer.wait_merging_threads()
} }


fn index_documents(index_writer: &mut IndexWriter, doc_receiver: chan::Receiver<Document>) -> tantivy::Result<u64> { fn index_documents(index_writer: &mut IndexWriter, doc_receiver: chan::Receiver<Document>) -> tantivy::Result<u64> {


+ 1
- 1
src/commands/merge.rs View File

@@ -14,7 +14,7 @@ pub fn run_merge_cli(argmatch: &ArgMatches) -> Result<(), String> {


fn run_merge(path: PathBuf) -> tantivy::Result<()> { fn run_merge(path: PathBuf) -> tantivy::Result<()> {
let index = try!(Index::open(&path)); let index = try!(Index::open(&path));
let segments = try!(index.segments());
let segments = index.searchable_segments();
let mut index_writer = try!(index.writer(HEAP_SIZE)); let mut index_writer = try!(index.writer(HEAP_SIZE));
index_writer.merge(&segments) index_writer.merge(&segments)
} }

Loading…
Cancel
Save