Browse Source

Bumped version of tantivy to 0.3.1

develop
Paul Masurel 7 years ago
parent
commit
424cf0eaf6
3 changed files with 18 additions and 11 deletions
  1. +3
    -3
      Cargo.lock
  2. +1
    -1
      Cargo.toml
  3. +14
    -7
      src/commands/merge.rs

+ 3
- 3
Cargo.lock View File

@@ -15,7 +15,7 @@ dependencies = [
"persistent 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"staticfile 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tantivy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tantivy 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"urlencoded 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"version 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -713,7 +713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "tantivy"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atomicwrites 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1042,7 +1042,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "172382bac9424588d7840732b250faeeef88942e37b6e35317dce98cafdd75b2"
"checksum staticfile 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b28e731e7fcc67ce6aa4b53359d6922e193979175fbe85d5558fc71e692e4523"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
"checksum tantivy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b298586b33dd0997944c6f2a86a3c734baa30ddec5bdce271bc3d624bf6cf12"
"checksum tantivy 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "389ee9371eed5bec929bd1384ece956cb1e61764237d94bcab5cf4660faa8be5"
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
"checksum tempfile 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3213fd2b7ed87e39306737ccfac04b1233b57a33ca64cfbf52f2ffaa2b765e2f"
"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209"


+ 1
- 1
Cargo.toml View File

@@ -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"


+ 14
- 7
src/commands/merge.rs View File

@@ -1,6 +1,6 @@
extern crate tantivy;

use tantivy::{Index, SegmentMeta};
use tantivy::Index;
use std::path::PathBuf;
use clap::ArgMatches;
use futures::Future;
@@ -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(())
}

Loading…
Cancel
Save