mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-25 06:00:08 +01:00
only call the extractor if needed
This commit is contained in:
parent
4fd0116a0d
commit
f73273d71c
@ -14,18 +14,12 @@ use crate::{FieldId, InternalError, Result};
|
|||||||
pub fn extract_geo_points<R: io::Read>(
|
pub fn extract_geo_points<R: io::Read>(
|
||||||
mut obkv_documents: grenad::Reader<R>,
|
mut obkv_documents: grenad::Reader<R>,
|
||||||
indexer: GrenadParameters,
|
indexer: GrenadParameters,
|
||||||
geo_field_id: Option<FieldId>, // faire un grenad vide
|
geo_field_id: FieldId,
|
||||||
) -> Result<grenad::Reader<File>> {
|
) -> Result<grenad::Reader<File>> {
|
||||||
let mut writer = tempfile::tempfile().and_then(|file| {
|
let mut writer = tempfile::tempfile().and_then(|file| {
|
||||||
create_writer(indexer.chunk_compression_type, indexer.chunk_compression_level, file)
|
create_writer(indexer.chunk_compression_type, indexer.chunk_compression_level, file)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// we never encountered any documents with a `_geo` field. We can skip entirely this step
|
|
||||||
let geo_field_id = match geo_field_id {
|
|
||||||
Some(geo) => geo,
|
|
||||||
None => return Ok(writer_into_reader(writer)?),
|
|
||||||
};
|
|
||||||
|
|
||||||
while let Some((docid_bytes, value)) = obkv_documents.next()? {
|
while let Some((docid_bytes, value)) = obkv_documents.next()? {
|
||||||
let obkv = obkv::KvReader::new(value);
|
let obkv = obkv::KvReader::new(value);
|
||||||
let point = match obkv.get(geo_field_id) {
|
let point = match obkv.get(geo_field_id) {
|
||||||
|
@ -182,6 +182,7 @@ fn extract_documents_data(
|
|||||||
|
|
||||||
let _ = lmdb_writer_sx.send(Ok(TypedChunk::Documents(documents_chunk.clone())));
|
let _ = lmdb_writer_sx.send(Ok(TypedChunk::Documents(documents_chunk.clone())));
|
||||||
|
|
||||||
|
if let Some(geo_field_id) = geo_field_id {
|
||||||
let documents_chunk_cloned = documents_chunk.clone();
|
let documents_chunk_cloned = documents_chunk.clone();
|
||||||
let lmdb_writer_sx_cloned = lmdb_writer_sx.clone();
|
let lmdb_writer_sx_cloned = lmdb_writer_sx.clone();
|
||||||
rayon::spawn(move || {
|
rayon::spawn(move || {
|
||||||
@ -190,6 +191,7 @@ fn extract_documents_data(
|
|||||||
Err(error) => lmdb_writer_sx_cloned.send(Err(error)),
|
Err(error) => lmdb_writer_sx_cloned.send(Err(error)),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let (docid_word_positions_chunk, docid_fid_facet_values_chunks): (Result<_>, Result<_>) =
|
let (docid_word_positions_chunk, docid_fid_facet_values_chunks): (Result<_>, Result<_>) =
|
||||||
rayon::join(
|
rayon::join(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user