Skip to content

Commit

Permalink
Bumped version of tantivy to 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Apr 23, 2017
1 parent f341800 commit 424cf0e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ log = "0.3"
futures = "0.1"
env_logger = "0.3"
version = "2"
tantivy = "0.3.0"
tantivy = "0.3.1"

[[bin]]
name = "tantivy"
Expand Down
21 changes: 14 additions & 7 deletions src/commands/merge.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate tantivy;

use tantivy::{Index, SegmentMeta};
use tantivy::Index;
use std::path::PathBuf;
use clap::ArgMatches;
use futures::Future;
Expand All @@ -14,18 +14,25 @@ fn error_msg(err: tantivy::Error) -> String {

pub fn run_merge_cli(argmatch: &ArgMatches) -> Result<(), String> {
let index_directory = PathBuf::from(argmatch.value_of("index").unwrap());
let segment_meta = run_merge(index_directory).map_err(error_msg)?;
println!("Merge finished with segment meta {:?}", segment_meta);
Ok(())
run_merge(index_directory).map_err(error_msg)

// we rollback to force a gc.

}


fn run_merge(path: PathBuf) -> tantivy::Result<SegmentMeta> {
fn run_merge(path: PathBuf) -> tantivy::Result<()> {
let index = Index::open(&path)?;
let segments = index.searchable_segment_ids()?;
index
let segment_meta = index
.writer(HEAP_SIZE)?
.merge(&segments)
.wait()
.map_err(|_| tantivy::Error::ErrorInThread(String::from("Merge got cancelled")))
.map_err(|_| tantivy::Error::ErrorInThread(String::from("Merge got cancelled")));
println!("Merge finished with segment meta {:?}", segment_meta);
println!("Garbage collect irrelevant segments.");
Index::open(&path)?
.writer_with_num_threads(1, 40_000_000)?
.garbage_collect_files()?;
Ok(())
}

0 comments on commit 424cf0e

Please sign in to comment.