-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from nocduro/update_tantivy
update tantivy to 0.6.1
- Loading branch information
Showing
11 changed files
with
466 additions
and
329 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "tantivy-cli" | ||
version = "0.5.1" | ||
version = "0.6.1" | ||
authors = ["Paul Masurel <[email protected]>"] | ||
|
||
description = """Command line interface for Tantivy, a search engine library.""" | ||
|
@@ -30,7 +30,7 @@ byteorder = "0.5" | |
log = "0.3" | ||
futures = "0.1" | ||
env_logger = "0.3" | ||
tantivy = "0.5.1" | ||
tantivy = "0.6.1" | ||
|
||
[[bin]] | ||
name = "tantivy" | ||
|
@@ -42,8 +42,3 @@ opt-level = 3 | |
debug = false | ||
debug-assertions = false | ||
lto = true | ||
|
||
|
||
[features] | ||
default = ["tantivy/simdcompression"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
use time::PreciseTime; | ||
|
||
pub struct OpenTimer<'a> { | ||
name: &'static str, | ||
timer_tree: &'a mut TimerTree, | ||
start: PreciseTime, | ||
depth: u32, | ||
} | ||
|
||
impl<'a> OpenTimer<'a> { | ||
/// Starts timing a new named subtask | ||
/// | ||
/// The timer is stopped automatically | ||
/// when the `OpenTimer` is dropped. | ||
pub fn open(&mut self, name: &'static str) -> OpenTimer { | ||
OpenTimer { | ||
name, | ||
timer_tree: self.timer_tree, | ||
start: PreciseTime::now(), | ||
depth: self.depth + 1, | ||
} | ||
} | ||
} | ||
|
||
impl<'a> Drop for OpenTimer<'a> { | ||
fn drop(&mut self) { | ||
self.timer_tree.timings.push(Timing { | ||
name: self.name, | ||
duration: self.start | ||
.to(PreciseTime::now()) | ||
.num_microseconds() | ||
.unwrap(), | ||
depth: self.depth, | ||
}); | ||
} | ||
} | ||
|
||
/// Timing recording | ||
#[derive(Debug, Serialize)] | ||
pub struct Timing { | ||
name: &'static str, | ||
duration: i64, | ||
depth: u32, | ||
} | ||
|
||
/// Timer tree | ||
#[derive(Debug, Serialize)] | ||
pub struct TimerTree { | ||
timings: Vec<Timing>, | ||
} | ||
|
||
impl TimerTree { | ||
/// Returns the total time elapsed in microseconds | ||
pub fn total_time(&self) -> i64 { | ||
self.timings.last().unwrap().duration | ||
} | ||
|
||
/// Open a new named subtask | ||
pub fn open(&mut self, name: &'static str) -> OpenTimer { | ||
OpenTimer { | ||
name, | ||
timer_tree: self, | ||
start: PreciseTime::now(), | ||
depth: 0, | ||
} | ||
} | ||
} | ||
|
||
impl Default for TimerTree { | ||
fn default() -> TimerTree { | ||
TimerTree { | ||
timings: Vec::new(), | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn test_timer() { | ||
let mut timer_tree = TimerTree::default(); | ||
{ | ||
let mut a = timer_tree.open("a"); | ||
{ | ||
let mut ab = a.open("b"); | ||
{ | ||
let _abc = ab.open("c"); | ||
} | ||
{ | ||
let _abd = ab.open("d"); | ||
} | ||
} | ||
} | ||
assert_eq!(timer_tree.timings.len(), 4); | ||
} | ||
} |