From 093dcbd2537cb64383af4c2d969f180a2c2b9d64 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Sat, 21 Jan 2017 11:23:29 +0900 Subject: [PATCH] issue/43 Isolated SegmentMeta --- src/core/index_meta.rs | 22 +--------------------- src/core/mod.rs | 4 +++- src/core/segment_meta.rs | 19 +++++++++++++++++++ src/directory/directory.rs | 3 ++- 4 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 src/core/segment_meta.rs diff --git a/src/core/index_meta.rs b/src/core/index_meta.rs index d82f865f2..c6d7f4bc5 100644 --- a/src/core/index_meta.rs +++ b/src/core/index_meta.rs @@ -1,7 +1,5 @@ - use schema::Schema; -use core::SegmentId; - +use core::SegmentMeta; /// Meta information about the `Index`. /// @@ -29,21 +27,3 @@ impl IndexMeta { } } } - -#[derive(Clone, Debug, RustcDecodable,RustcEncodable)] -pub struct SegmentMeta { - pub segment_id: SegmentId, - pub num_docs: u32, - pub num_deleted_docs: u32, -} - -#[cfg(test)] -impl SegmentMeta { - pub fn new(segment_id: SegmentId, num_docs: u32) -> SegmentMeta { - SegmentMeta { - segment_id: segment_id, - num_docs: num_docs, - num_deleted_docs: 0, - } - } -} \ No newline at end of file diff --git a/src/core/mod.rs b/src/core/mod.rs index 2dfac69d1..3111cfadc 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -7,6 +7,7 @@ mod segment_component; mod segment; mod index_meta; mod pool; +mod segment_meta; mod term_iterator; use std::path::PathBuf; @@ -18,7 +19,8 @@ pub use self::segment::Segment; pub use self::segment::SegmentInfo; pub use self::segment::SerializableSegment; pub use self::index::Index; -pub use self::index_meta::{IndexMeta, SegmentMeta}; +pub use self::segment_meta::SegmentMeta; +pub use self::index_meta::IndexMeta; pub use self::term_iterator::TermIterator; lazy_static! { diff --git a/src/core/segment_meta.rs b/src/core/segment_meta.rs new file mode 100644 index 000000000..ef7521818 --- /dev/null +++ b/src/core/segment_meta.rs @@ -0,0 +1,19 @@ +use core::SegmentId; + +#[derive(Clone, Debug, RustcDecodable,RustcEncodable)] +pub struct SegmentMeta { + pub segment_id: SegmentId, + pub num_docs: u32, + pub num_deleted_docs: u32, +} + +#[cfg(test)] +impl SegmentMeta { + pub fn new(segment_id: SegmentId, num_docs: u32) -> SegmentMeta { + SegmentMeta { + segment_id: segment_id, + num_docs: num_docs, + num_deleted_docs: 0, + } + } +} \ No newline at end of file diff --git a/src/directory/directory.rs b/src/directory/directory.rs index 1b29592b3..40da74654 100644 --- a/src/directory/directory.rs +++ b/src/directory/directory.rs @@ -7,7 +7,8 @@ use std::result; use std::io; use std::marker::Sync; -/// Write-once read many (WORM) abstraction for where tantivy's index should be stored. +/// Write-once read many (WORM) abstraction for where +/// tantivy's data should be stored. /// /// There are currently two implementations of `Directory` ///