mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-06-03 09:00:42 +00:00
Compare commits
35 Commits
postings-w
...
postings-w
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5221215b3 | ||
|
|
7d9427e9d6 | ||
|
|
62b50bb254 | ||
|
|
2dcd550b74 | ||
|
|
4840886a87 | ||
|
|
1de872ba71 | ||
|
|
93915ce1bf | ||
|
|
bf87c54f0e | ||
|
|
4f27b503ed | ||
|
|
0346942174 | ||
|
|
6ec38276a6 | ||
|
|
476960e89b | ||
|
|
955ce6477c | ||
|
|
daaecf2afb | ||
|
|
d64178906f | ||
|
|
f1377018b0 | ||
|
|
9fe96d06af | ||
|
|
d9c4270acb | ||
|
|
16d1611f4d | ||
|
|
b296948bcd | ||
|
|
6b7380eda8 | ||
|
|
947459a0a9 | ||
|
|
eb18182901 | ||
|
|
01d670f60c | ||
|
|
b77338b590 | ||
|
|
c75fa94d25 | ||
|
|
cf632673ac | ||
|
|
6f00d96127 | ||
|
|
a5ccb62c99 | ||
|
|
c42505a043 | ||
|
|
3e57eb9add | ||
|
|
0955b44ce1 | ||
|
|
783a2a6bef | ||
|
|
1e3c353e21 | ||
|
|
799e88adbd |
@@ -3,7 +3,7 @@ use std::io;
|
||||
use crate::codec::postings::block_wand::{block_wand, block_wand_single_scorer};
|
||||
use crate::codec::postings::PostingsCodec;
|
||||
use crate::codec::standard::postings::block_segment_postings::BlockSegmentPostings;
|
||||
use crate::codec::standard::postings::segment_postings::SegmentPostings;
|
||||
pub use crate::codec::standard::postings::segment_postings::SegmentPostings;
|
||||
use crate::fieldnorm::FieldNormReader;
|
||||
use crate::positions::PositionReader;
|
||||
use crate::query::term_query::TermScorer;
|
||||
|
||||
@@ -12,7 +12,6 @@ use crate::query::Bm25Weight;
|
||||
use crate::schema::IndexRecordOption;
|
||||
use crate::{DocId, Score};
|
||||
|
||||
/// Default tantivy postings codec serializer.
|
||||
pub struct StandardPostingsSerializer {
|
||||
last_doc_id_encoded: u32,
|
||||
|
||||
@@ -32,7 +31,6 @@ pub struct StandardPostingsSerializer {
|
||||
}
|
||||
|
||||
impl StandardPostingsSerializer {
|
||||
/// Creates a new instance of `StandardPostingsSerializer`.
|
||||
pub fn new(
|
||||
avg_fieldnorm: Score,
|
||||
mode: IndexRecordOption,
|
||||
|
||||
@@ -4,8 +4,6 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::codec::{Codec, StandardCodec};
|
||||
|
||||
/// A small struct representing a codec configuration.
|
||||
/// It is meant to be serialized in the index metadata file.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct CodecConfiguration {
|
||||
name: Cow<'static, str>,
|
||||
@@ -14,10 +12,13 @@ pub struct CodecConfiguration {
|
||||
}
|
||||
|
||||
impl CodecConfiguration {
|
||||
/// Builds the codec given a codec_configuration.
|
||||
///
|
||||
/// If the configuration codec name does not match the type C,
|
||||
/// a tantivy error is returned.
|
||||
pub fn from_codec<C: Codec>(codec: &C) -> Self {
|
||||
CodecConfiguration {
|
||||
name: Cow::Borrowed(C::NAME),
|
||||
props: codec.to_json_props(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_codec<C: Codec>(&self) -> crate::Result<C> {
|
||||
if self.name != C::NAME {
|
||||
return Err(crate::TantivyError::InvalidArgument(format!(
|
||||
@@ -30,17 +31,8 @@ impl CodecConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, C: Codec> From<&'a C> for CodecConfiguration {
|
||||
fn from(codec: &'a C) -> Self {
|
||||
CodecConfiguration {
|
||||
name: Cow::Borrowed(C::NAME),
|
||||
props: codec.to_json_props(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CodecConfiguration {
|
||||
fn default() -> Self {
|
||||
CodecConfiguration::from(&StandardCodec)
|
||||
CodecConfiguration::from_codec(&StandardCodec)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ impl<Codec: crate::codec::Codec> IndexBuilder<Codec> {
|
||||
fn create_avoid_monomorphization(self, dir: Box<dyn Directory>) -> crate::Result<Index<Codec>> {
|
||||
self.validate()?;
|
||||
let directory = ManagedDirectory::wrap(dir)?;
|
||||
let codec: CodecConfiguration = CodecConfiguration::from(&self.codec);
|
||||
let codec: CodecConfiguration = CodecConfiguration::from_codec(&self.codec);
|
||||
save_new_metas(
|
||||
self.get_expect_schema()?,
|
||||
self.index_settings.clone(),
|
||||
|
||||
@@ -368,7 +368,7 @@ impl IndexMeta {
|
||||
schema,
|
||||
opstamp: 0u64,
|
||||
payload: None,
|
||||
codec: CodecConfiguration::from(codec),
|
||||
codec: CodecConfiguration::from_codec(codec),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ pub fn merge_filtered_segments<C: crate::codec::Codec, T: Into<Box<dyn Directory
|
||||
))
|
||||
.trim_end()
|
||||
);
|
||||
let codec_configuration = CodecConfiguration::from(segments[0].index().codec());
|
||||
let codec_configuration = CodecConfiguration::from_codec(segments[0].index().codec());
|
||||
|
||||
let index_meta = IndexMeta {
|
||||
index_settings: target_settings, // index_settings of all segments should be the same
|
||||
@@ -410,7 +410,7 @@ impl<Codec: crate::codec::Codec> SegmentUpdater<Codec> {
|
||||
//
|
||||
// Segment 1 from disk 1, Segment 1 from disk 2, etc.
|
||||
committed_segment_metas.sort_by_key(|segment_meta| -(segment_meta.max_doc() as i32));
|
||||
let codec = CodecConfiguration::from(index.codec());
|
||||
let codec = CodecConfiguration::from_codec(index.codec());
|
||||
let index_meta = IndexMeta {
|
||||
index_settings: index.settings().clone(),
|
||||
segments: committed_segment_metas,
|
||||
|
||||
@@ -53,7 +53,7 @@ impl<Codec: crate::codec::Codec, D: Document> SingleSegmentIndexWriter<Codec, D>
|
||||
schema: index.schema(),
|
||||
opstamp: 0,
|
||||
payload: None,
|
||||
codec: CodecConfiguration::from(index.codec()),
|
||||
codec: CodecConfiguration::from_codec(index.codec()),
|
||||
};
|
||||
save_metas(&index_meta, index.directory())?;
|
||||
index.directory().sync_directory()?;
|
||||
|
||||
Reference in New Issue
Block a user