-
-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for a same-thread doc compressor. #1510
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 | ||||
---|---|---|---|---|---|---|
|
@@ -235,6 +235,14 @@ impl InnerSegmentMeta { | |||||
} | ||||||
} | ||||||
|
||||||
fn return_true() -> bool { | ||||||
true | ||||||
} | ||||||
|
||||||
fn is_true(val: &bool) -> bool { | ||||||
*val | ||||||
} | ||||||
|
||||||
/// Search Index Settings. | ||||||
/// | ||||||
/// Contains settings which are applied on the whole | ||||||
|
@@ -248,6 +256,12 @@ pub struct IndexSettings { | |||||
/// The `Compressor` used to compress the doc store. | ||||||
#[serde(default)] | ||||||
pub docstore_compression: Compressor, | ||||||
/// If set to true, docstore compression will happen on a dedicated thread. | ||||||
/// (defaults: true) | ||||||
#[doc(hidden)] | ||||||
#[serde(default = "return_true")] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
#[serde(skip_serializing_if = "is_true")] | ||||||
pub docstore_compress_dedicated_thread: bool, | ||||||
#[serde(default = "default_docstore_blocksize")] | ||||||
/// The size of each block that will be compressed and written to disk | ||||||
pub docstore_blocksize: usize, | ||||||
|
@@ -264,6 +278,7 @@ impl Default for IndexSettings { | |||||
sort_by_field: None, | ||||||
docstore_compression: Compressor::default(), | ||||||
docstore_blocksize: default_docstore_blocksize(), | ||||||
docstore_compress_dedicated_thread: true, | ||||||
} | ||||||
} | ||||||
} | ||||||
|
@@ -395,7 +410,7 @@ mod tests { | |||||
use super::IndexMeta; | ||||||
use crate::core::index_meta::UntrackedIndexMeta; | ||||||
use crate::schema::{Schema, TEXT}; | ||||||
use crate::store::ZstdCompressor; | ||||||
use crate::store::{Compressor, ZstdCompressor}; | ||||||
use crate::{IndexSettings, IndexSortByField, Order}; | ||||||
|
||||||
#[test] | ||||||
|
@@ -447,6 +462,7 @@ mod tests { | |||||
compression_level: Some(4), | ||||||
}), | ||||||
docstore_blocksize: 1_000_000, | ||||||
docstore_compress_dedicated_thread: true, | ||||||
}, | ||||||
segments: Vec::new(), | ||||||
schema, | ||||||
|
@@ -485,4 +501,47 @@ mod tests { | |||||
"unknown zstd option \"bla\" at line 1 column 103".to_string() | ||||||
); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
#[cfg(feature = "lz4-compression")] | ||||||
fn test_index_settings_default() { | ||||||
let mut index_settings = IndexSettings::default(); | ||||||
assert_eq!( | ||||||
index_settings, | ||||||
IndexSettings { | ||||||
sort_by_field: None, | ||||||
docstore_compression: Compressor::default(), | ||||||
docstore_compress_dedicated_thread: true, | ||||||
docstore_blocksize: 16_384 | ||||||
} | ||||||
); | ||||||
{ | ||||||
let index_settings_json = serde_json::to_value(&index_settings).unwrap(); | ||||||
assert_eq!( | ||||||
index_settings_json, | ||||||
serde_json::json!({ | ||||||
"docstore_compression": "lz4", | ||||||
"docstore_blocksize": 16384 | ||||||
}) | ||||||
); | ||||||
let index_settings_deser: IndexSettings = | ||||||
serde_json::from_value(index_settings_json).unwrap(); | ||||||
assert_eq!(index_settings_deser, index_settings); | ||||||
} | ||||||
{ | ||||||
index_settings.docstore_compress_dedicated_thread = false; | ||||||
let index_settings_json = serde_json::to_value(&index_settings).unwrap(); | ||||||
assert_eq!( | ||||||
index_settings_json, | ||||||
serde_json::json!({ | ||||||
"docstore_compression": "lz4", | ||||||
"docstore_blocksize": 16384, | ||||||
"docstore_compress_dedicated_thread": false, | ||||||
}) | ||||||
); | ||||||
let index_settings_deser: IndexSettings = | ||||||
serde_json::from_value(index_settings_json).unwrap(); | ||||||
assert_eq!(index_settings_deser, index_settings); | ||||||
} | ||||||
} | ||||||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.