2021-08-16 13:36:30 +02:00
|
|
|
mod extract_docid_word_positions;
|
|
|
|
mod extract_facet_number_docids;
|
|
|
|
mod extract_facet_string_docids;
|
|
|
|
mod extract_fid_docid_facet_values;
|
|
|
|
mod extract_fid_word_count_docids;
|
2021-08-23 18:41:48 +02:00
|
|
|
mod extract_geo_points;
|
2023-06-08 11:35:36 +02:00
|
|
|
mod extract_vector_points;
|
2021-08-16 13:36:30 +02:00
|
|
|
mod extract_word_docids;
|
|
|
|
mod extract_word_pair_proximity_docids;
|
2021-10-05 11:18:42 +02:00
|
|
|
mod extract_word_position_docids;
|
2021-08-16 13:36:30 +02:00
|
|
|
|
|
|
|
use std::fs::File;
|
2023-09-28 16:26:01 +02:00
|
|
|
use std::io::BufReader;
|
2024-04-17 10:54:48 +02:00
|
|
|
use std::sync::Arc;
|
2021-08-16 13:36:30 +02:00
|
|
|
|
|
|
|
use crossbeam_channel::Sender;
|
|
|
|
use rayon::prelude::*;
|
|
|
|
|
|
|
|
use self::extract_docid_word_positions::extract_docid_word_positions;
|
|
|
|
use self::extract_facet_number_docids::extract_facet_number_docids;
|
|
|
|
use self::extract_facet_string_docids::extract_facet_string_docids;
|
2023-03-09 13:21:21 +01:00
|
|
|
use self::extract_fid_docid_facet_values::{extract_fid_docid_facet_values, ExtractedFacetValues};
|
2021-08-16 13:36:30 +02:00
|
|
|
use self::extract_fid_word_count_docids::extract_fid_word_count_docids;
|
2021-08-23 18:41:48 +02:00
|
|
|
use self::extract_geo_points::extract_geo_points;
|
2023-11-15 15:46:37 +01:00
|
|
|
use self::extract_vector_points::{
|
|
|
|
extract_embeddings, extract_vector_points, ExtractedVectorPoints,
|
|
|
|
};
|
2021-08-16 13:36:30 +02:00
|
|
|
use self::extract_word_docids::extract_word_docids;
|
|
|
|
use self::extract_word_pair_proximity_docids::extract_word_pair_proximity_docids;
|
2023-04-05 14:55:02 +02:00
|
|
|
use self::extract_word_position_docids::extract_word_position_docids;
|
2024-01-22 16:23:12 +01:00
|
|
|
use super::helpers::{as_cloneable_grenad, CursorClonableMmap, GrenadParameters};
|
2021-08-16 13:36:30 +02:00
|
|
|
use super::{helpers, TypedChunk};
|
2024-03-26 13:27:43 +01:00
|
|
|
use crate::update::settings::InnerIndexSettingsDiff;
|
|
|
|
use crate::{FieldId, Result};
|
2021-08-16 13:36:30 +02:00
|
|
|
|
|
|
|
/// Extract data for each databases from obkv documents in parallel.
|
|
|
|
/// Send data in grenad file over provided Sender.
|
2022-10-14 16:44:10 +02:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
2024-01-23 09:42:48 +01:00
|
|
|
#[tracing::instrument(level = "trace", skip_all, target = "indexing::extract")]
|
2021-08-16 13:36:30 +02:00
|
|
|
pub(crate) fn data_from_obkv_documents(
|
2023-09-28 16:26:01 +02:00
|
|
|
original_obkv_chunks: impl Iterator<Item = Result<grenad::Reader<BufReader<File>>>> + Send,
|
|
|
|
flattened_obkv_chunks: impl Iterator<Item = Result<grenad::Reader<BufReader<File>>>> + Send,
|
2021-08-16 13:36:30 +02:00
|
|
|
indexer: GrenadParameters,
|
2021-08-24 13:01:31 +02:00
|
|
|
lmdb_writer_sx: Sender<Result<TypedChunk>>,
|
2021-09-02 15:57:40 +02:00
|
|
|
primary_key_id: FieldId,
|
2022-03-23 17:28:41 +01:00
|
|
|
geo_fields_ids: Option<(FieldId, FieldId)>,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff: Arc<InnerIndexSettingsDiff>,
|
2021-10-06 12:11:07 +02:00
|
|
|
max_positions_per_attributes: Option<u32>,
|
2021-08-16 13:36:30 +02:00
|
|
|
) -> Result<()> {
|
2023-07-10 18:41:54 +02:00
|
|
|
puffin::profile_function!();
|
|
|
|
|
2024-01-22 16:23:12 +01:00
|
|
|
let (original_pipeline_result, flattened_pipeline_result): (Result<_>, Result<_>) = rayon::join(
|
|
|
|
|| {
|
|
|
|
original_obkv_chunks
|
|
|
|
.par_bridge()
|
|
|
|
.map(|original_documents_chunk| {
|
|
|
|
send_original_documents_data(
|
|
|
|
original_documents_chunk,
|
|
|
|
indexer,
|
|
|
|
lmdb_writer_sx.clone(),
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-01-22 16:23:12 +01:00
|
|
|
)
|
|
|
|
})
|
|
|
|
.collect::<Result<()>>()
|
2022-03-24 15:22:57 +01:00
|
|
|
},
|
2024-01-22 16:23:12 +01:00
|
|
|
|| {
|
|
|
|
flattened_obkv_chunks
|
|
|
|
.par_bridge()
|
|
|
|
.map(|flattened_obkv_chunks| {
|
|
|
|
send_and_extract_flattened_documents_data(
|
|
|
|
flattened_obkv_chunks,
|
|
|
|
indexer,
|
|
|
|
lmdb_writer_sx.clone(),
|
|
|
|
primary_key_id,
|
|
|
|
geo_fields_ids,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-01-22 16:23:12 +01:00
|
|
|
max_positions_per_attributes,
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.map(|result| {
|
|
|
|
if let Ok((
|
|
|
|
ref docid_word_positions_chunk,
|
|
|
|
(ref fid_docid_facet_numbers_chunk, ref fid_docid_facet_strings_chunk),
|
|
|
|
)) = result
|
|
|
|
{
|
|
|
|
run_extraction_task::<_, _, grenad::Reader<BufReader<File>>>(
|
|
|
|
docid_word_positions_chunk.clone(),
|
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-01-22 16:23:12 +01:00
|
|
|
lmdb_writer_sx.clone(),
|
|
|
|
extract_fid_word_count_docids,
|
|
|
|
TypedChunk::FieldIdWordCountDocids,
|
|
|
|
"field-id-wordcount-docids",
|
|
|
|
);
|
|
|
|
run_extraction_task::<
|
|
|
|
_,
|
|
|
|
_,
|
|
|
|
(
|
|
|
|
grenad::Reader<BufReader<File>>,
|
|
|
|
grenad::Reader<BufReader<File>>,
|
|
|
|
grenad::Reader<BufReader<File>>,
|
|
|
|
),
|
|
|
|
>(
|
|
|
|
docid_word_positions_chunk.clone(),
|
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-01-22 16:23:12 +01:00
|
|
|
lmdb_writer_sx.clone(),
|
2024-03-26 13:27:43 +01:00
|
|
|
extract_word_docids,
|
2024-01-22 16:23:12 +01:00
|
|
|
|(
|
|
|
|
word_docids_reader,
|
|
|
|
exact_word_docids_reader,
|
|
|
|
word_fid_docids_reader,
|
|
|
|
)| {
|
|
|
|
TypedChunk::WordDocids {
|
|
|
|
word_docids_reader,
|
|
|
|
exact_word_docids_reader,
|
|
|
|
word_fid_docids_reader,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"word-docids",
|
|
|
|
);
|
|
|
|
|
|
|
|
run_extraction_task::<_, _, grenad::Reader<BufReader<File>>>(
|
|
|
|
docid_word_positions_chunk.clone(),
|
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-01-22 16:23:12 +01:00
|
|
|
lmdb_writer_sx.clone(),
|
|
|
|
extract_word_position_docids,
|
|
|
|
TypedChunk::WordPositionDocids,
|
|
|
|
"word-position-docids",
|
|
|
|
);
|
|
|
|
|
|
|
|
run_extraction_task::<
|
|
|
|
_,
|
|
|
|
_,
|
|
|
|
(grenad::Reader<BufReader<File>>, grenad::Reader<BufReader<File>>),
|
|
|
|
>(
|
|
|
|
fid_docid_facet_strings_chunk.clone(),
|
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-01-22 16:23:12 +01:00
|
|
|
lmdb_writer_sx.clone(),
|
|
|
|
extract_facet_string_docids,
|
|
|
|
TypedChunk::FieldIdFacetStringDocids,
|
|
|
|
"field-id-facet-string-docids",
|
|
|
|
);
|
|
|
|
|
|
|
|
run_extraction_task::<_, _, grenad::Reader<BufReader<File>>>(
|
|
|
|
fid_docid_facet_numbers_chunk.clone(),
|
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-01-22 16:23:12 +01:00
|
|
|
lmdb_writer_sx.clone(),
|
|
|
|
extract_facet_number_docids,
|
|
|
|
TypedChunk::FieldIdFacetNumberDocids,
|
|
|
|
"field-id-facet-number-docids",
|
|
|
|
);
|
|
|
|
|
2024-03-26 13:27:43 +01:00
|
|
|
run_extraction_task::<_, _, grenad::Reader<BufReader<File>>>(
|
|
|
|
docid_word_positions_chunk.clone(),
|
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff.clone(),
|
2024-03-26 13:27:43 +01:00
|
|
|
lmdb_writer_sx.clone(),
|
|
|
|
extract_word_pair_proximity_docids,
|
|
|
|
TypedChunk::WordPairProximityDocids,
|
|
|
|
"word-pair-proximity-docids",
|
|
|
|
);
|
2024-01-22 16:23:12 +01:00
|
|
|
}
|
2021-08-16 13:36:30 +02:00
|
|
|
|
2024-01-22 16:23:12 +01:00
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.collect::<Result<()>>()
|
|
|
|
},
|
2021-08-16 13:36:30 +02:00
|
|
|
);
|
2022-06-16 08:24:16 +02:00
|
|
|
|
2024-01-22 16:23:12 +01:00
|
|
|
original_pipeline_result.and(flattened_pipeline_result)
|
2021-08-16 13:36:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Spawn a new task to extract data for a specific DB using extract_fn.
|
|
|
|
/// Generated grenad chunks are merged using the merge_fn.
|
|
|
|
/// The result of merged chunks is serialized as TypedChunk using the serialize_fn
|
|
|
|
/// and sent into lmdb_writer_sx.
|
2024-01-22 16:23:12 +01:00
|
|
|
fn run_extraction_task<FE, FS, M>(
|
|
|
|
chunk: grenad::Reader<CursorClonableMmap>,
|
2021-08-16 13:36:30 +02:00
|
|
|
indexer: GrenadParameters,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff: Arc<InnerIndexSettingsDiff>,
|
2021-08-24 13:01:31 +02:00
|
|
|
lmdb_writer_sx: Sender<Result<TypedChunk>>,
|
2021-08-16 13:36:30 +02:00
|
|
|
extract_fn: FE,
|
|
|
|
serialize_fn: FS,
|
|
|
|
name: &'static str,
|
|
|
|
) where
|
2024-03-26 13:27:43 +01:00
|
|
|
FE: Fn(
|
|
|
|
grenad::Reader<CursorClonableMmap>,
|
|
|
|
GrenadParameters,
|
|
|
|
&InnerIndexSettingsDiff,
|
|
|
|
) -> Result<M>
|
2021-08-16 13:36:30 +02:00
|
|
|
+ Sync
|
|
|
|
+ Send
|
|
|
|
+ 'static,
|
2024-01-22 16:23:12 +01:00
|
|
|
FS: Fn(M) -> TypedChunk + Sync + Send + 'static,
|
|
|
|
M: Send,
|
2021-08-16 13:36:30 +02:00
|
|
|
{
|
2024-01-23 09:42:48 +01:00
|
|
|
let current_span = tracing::Span::current();
|
|
|
|
|
2021-08-16 13:36:30 +02:00
|
|
|
rayon::spawn(move || {
|
2024-02-26 16:38:17 +01:00
|
|
|
let child_span = tracing::trace_span!(target: "indexing::extract::details", parent: ¤t_span, "extract_multiple_chunks");
|
2024-01-23 09:42:48 +01:00
|
|
|
let _entered = child_span.enter();
|
2024-01-22 16:23:12 +01:00
|
|
|
puffin::profile_scope!("extract_multiple_chunks", name);
|
2024-04-03 11:19:45 +02:00
|
|
|
match extract_fn(chunk, indexer, &settings_diff) {
|
2024-01-22 16:23:12 +01:00
|
|
|
Ok(chunk) => {
|
|
|
|
let _ = lmdb_writer_sx.send(Ok(serialize_fn(chunk)));
|
2021-08-26 11:01:30 +02:00
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
let _ = lmdb_writer_sx.send(Err(e));
|
2021-08-24 13:01:31 +02:00
|
|
|
}
|
2024-01-22 16:23:12 +01:00
|
|
|
}
|
|
|
|
})
|
2021-08-16 13:36:30 +02:00
|
|
|
}
|
2021-08-24 13:01:31 +02:00
|
|
|
|
2022-03-23 17:28:41 +01:00
|
|
|
/// Extract chunked data and send it into lmdb_writer_sx sender:
|
2021-08-24 13:01:31 +02:00
|
|
|
/// - documents
|
2022-03-23 17:28:41 +01:00
|
|
|
fn send_original_documents_data(
|
2023-09-28 16:26:01 +02:00
|
|
|
original_documents_chunk: Result<grenad::Reader<BufReader<File>>>,
|
2023-09-06 12:20:25 +02:00
|
|
|
indexer: GrenadParameters,
|
2022-03-23 17:28:41 +01:00
|
|
|
lmdb_writer_sx: Sender<Result<TypedChunk>>,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff: Arc<InnerIndexSettingsDiff>,
|
2022-03-23 17:28:41 +01:00
|
|
|
) -> Result<()> {
|
|
|
|
let original_documents_chunk =
|
|
|
|
original_documents_chunk.and_then(|c| unsafe { as_cloneable_grenad(&c) })?;
|
|
|
|
|
2023-11-15 15:46:37 +01:00
|
|
|
let documents_chunk_cloned = original_documents_chunk.clone();
|
|
|
|
let lmdb_writer_sx_cloned = lmdb_writer_sx.clone();
|
2024-03-19 15:41:37 +01:00
|
|
|
|
|
|
|
let request_threads = rayon::ThreadPoolBuilder::new()
|
|
|
|
.num_threads(crate::vector::REQUEST_PARALLELISM)
|
|
|
|
.thread_name(|index| format!("embedding-request-{index}"))
|
2024-03-20 13:25:10 +01:00
|
|
|
.build()?;
|
2024-03-19 15:41:37 +01:00
|
|
|
|
2024-04-03 11:19:45 +02:00
|
|
|
if settings_diff.reindex_vectors() || !settings_diff.settings_update_only() {
|
|
|
|
let settings_diff = settings_diff.clone();
|
|
|
|
rayon::spawn(move || {
|
|
|
|
for (name, (embedder, prompt)) in settings_diff.new.embedding_configs.clone() {
|
|
|
|
let result = extract_vector_points(
|
|
|
|
documents_chunk_cloned.clone(),
|
|
|
|
indexer,
|
|
|
|
&settings_diff,
|
|
|
|
&prompt,
|
|
|
|
&name,
|
|
|
|
);
|
|
|
|
match result {
|
|
|
|
Ok(ExtractedVectorPoints { manual_vectors, remove_vectors, prompts }) => {
|
|
|
|
let embeddings = match extract_embeddings(
|
2024-04-03 19:10:19 +02:00
|
|
|
prompts,
|
|
|
|
indexer,
|
|
|
|
embedder.clone(),
|
|
|
|
&request_threads,
|
|
|
|
) {
|
|
|
|
Ok(results) => Some(results),
|
|
|
|
Err(error) => {
|
|
|
|
let _ = lmdb_writer_sx_cloned.send(Err(error));
|
|
|
|
None
|
|
|
|
}
|
|
|
|
};
|
2023-12-12 21:19:48 +01:00
|
|
|
|
2024-04-03 11:19:45 +02:00
|
|
|
if !(remove_vectors.is_empty()
|
|
|
|
&& manual_vectors.is_empty()
|
|
|
|
&& embeddings.as_ref().map_or(true, |e| e.is_empty()))
|
|
|
|
{
|
|
|
|
let _ = lmdb_writer_sx_cloned.send(Ok(TypedChunk::VectorPoints {
|
|
|
|
remove_vectors,
|
|
|
|
embeddings,
|
|
|
|
expected_dimension: embedder.dimensions(),
|
|
|
|
manual_vectors,
|
|
|
|
embedder_name: name,
|
|
|
|
}));
|
|
|
|
}
|
2023-12-07 17:35:45 +01:00
|
|
|
}
|
2023-12-12 21:19:48 +01:00
|
|
|
|
2024-04-03 11:19:45 +02:00
|
|
|
Err(error) => {
|
|
|
|
let _ = lmdb_writer_sx_cloned.send(Err(error));
|
|
|
|
}
|
2023-12-12 21:19:48 +01:00
|
|
|
}
|
2023-12-07 17:35:45 +01:00
|
|
|
}
|
2024-04-03 11:19:45 +02:00
|
|
|
});
|
|
|
|
}
|
2023-09-06 12:20:25 +02:00
|
|
|
|
2022-03-23 17:28:41 +01:00
|
|
|
// TODO: create a custom internal error
|
2024-02-13 14:22:21 +01:00
|
|
|
let _ = lmdb_writer_sx.send(Ok(TypedChunk::Documents(original_documents_chunk)));
|
2022-03-23 17:28:41 +01:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Extract chunked data and send it into lmdb_writer_sx sender:
|
2021-08-24 13:01:31 +02:00
|
|
|
/// - documents_ids
|
|
|
|
/// - docid_word_positions
|
|
|
|
/// - docid_fid_facet_numbers
|
|
|
|
/// - docid_fid_facet_strings
|
2022-07-19 09:30:19 +02:00
|
|
|
/// - docid_fid_facet_exists
|
2022-10-14 16:44:10 +02:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
#[allow(clippy::type_complexity)]
|
2022-03-23 17:28:41 +01:00
|
|
|
fn send_and_extract_flattened_documents_data(
|
2023-09-28 16:26:01 +02:00
|
|
|
flattened_documents_chunk: Result<grenad::Reader<BufReader<File>>>,
|
2021-08-24 13:01:31 +02:00
|
|
|
indexer: GrenadParameters,
|
|
|
|
lmdb_writer_sx: Sender<Result<TypedChunk>>,
|
2021-09-02 15:57:40 +02:00
|
|
|
primary_key_id: FieldId,
|
2022-03-23 17:28:41 +01:00
|
|
|
geo_fields_ids: Option<(FieldId, FieldId)>,
|
2024-04-17 12:33:25 +02:00
|
|
|
settings_diff: Arc<InnerIndexSettingsDiff>,
|
2021-10-06 12:11:07 +02:00
|
|
|
max_positions_per_attributes: Option<u32>,
|
2021-08-24 13:01:31 +02:00
|
|
|
) -> Result<(
|
|
|
|
grenad::Reader<CursorClonableMmap>,
|
2024-01-22 16:23:12 +01:00
|
|
|
(grenad::Reader<CursorClonableMmap>, grenad::Reader<CursorClonableMmap>),
|
2021-08-24 13:01:31 +02:00
|
|
|
)> {
|
2022-03-23 17:28:41 +01:00
|
|
|
let flattened_documents_chunk =
|
|
|
|
flattened_documents_chunk.and_then(|c| unsafe { as_cloneable_grenad(&c) })?;
|
2021-08-24 13:01:31 +02:00
|
|
|
|
2022-03-23 17:28:41 +01:00
|
|
|
if let Some(geo_fields_ids) = geo_fields_ids {
|
|
|
|
let documents_chunk_cloned = flattened_documents_chunk.clone();
|
2021-08-30 15:47:11 +02:00
|
|
|
let lmdb_writer_sx_cloned = lmdb_writer_sx.clone();
|
|
|
|
rayon::spawn(move || {
|
2021-09-09 12:20:08 +02:00
|
|
|
let result =
|
2022-03-23 17:28:41 +01:00
|
|
|
extract_geo_points(documents_chunk_cloned, indexer, primary_key_id, geo_fields_ids);
|
2021-09-09 12:20:08 +02:00
|
|
|
let _ = match result {
|
2021-08-30 15:47:11 +02:00
|
|
|
Ok(geo_points) => lmdb_writer_sx_cloned.send(Ok(TypedChunk::GeoPoints(geo_points))),
|
|
|
|
Err(error) => lmdb_writer_sx_cloned.send(Err(error)),
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
2021-08-25 16:59:38 +02:00
|
|
|
|
2023-10-18 13:53:58 +02:00
|
|
|
let (docid_word_positions_chunk, fid_docid_facet_values_chunks): (Result<_>, Result<_>) =
|
2021-08-24 13:01:31 +02:00
|
|
|
rayon::join(
|
|
|
|
|| {
|
2023-11-06 10:31:14 +01:00
|
|
|
let (docid_word_positions_chunk, script_language_pair) =
|
2022-10-17 13:51:04 +02:00
|
|
|
extract_docid_word_positions(
|
|
|
|
flattened_documents_chunk.clone(),
|
2023-02-21 10:18:44 +01:00
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
&settings_diff,
|
2022-10-17 13:51:04 +02:00
|
|
|
max_positions_per_attributes,
|
|
|
|
)?;
|
2021-08-24 13:01:31 +02:00
|
|
|
|
|
|
|
// send docid_word_positions_chunk to DB writer
|
|
|
|
let docid_word_positions_chunk =
|
2022-02-16 15:40:08 +01:00
|
|
|
unsafe { as_cloneable_grenad(&docid_word_positions_chunk)? };
|
2021-08-26 11:01:30 +02:00
|
|
|
|
2022-10-17 13:51:04 +02:00
|
|
|
let _ =
|
|
|
|
lmdb_writer_sx.send(Ok(TypedChunk::ScriptLanguageDocids(script_language_pair)));
|
2022-10-12 13:24:56 +02:00
|
|
|
|
2021-08-24 13:01:31 +02:00
|
|
|
Ok(docid_word_positions_chunk)
|
|
|
|
},
|
|
|
|
|| {
|
2023-03-09 13:21:21 +01:00
|
|
|
let ExtractedFacetValues {
|
2023-10-18 13:53:58 +02:00
|
|
|
fid_docid_facet_numbers_chunk,
|
|
|
|
fid_docid_facet_strings_chunk,
|
2023-03-08 16:46:42 +01:00
|
|
|
fid_facet_is_null_docids_chunk,
|
2023-03-14 18:08:12 +01:00
|
|
|
fid_facet_is_empty_docids_chunk,
|
2022-07-19 14:42:35 +02:00
|
|
|
fid_facet_exists_docids_chunk,
|
2023-03-09 13:21:21 +01:00
|
|
|
} = extract_fid_docid_facet_values(
|
2022-07-19 09:30:19 +02:00
|
|
|
flattened_documents_chunk.clone(),
|
2022-10-13 22:02:54 +02:00
|
|
|
indexer,
|
2024-04-17 12:33:25 +02:00
|
|
|
&settings_diff,
|
2023-08-08 16:28:07 +02:00
|
|
|
geo_fields_ids,
|
2022-07-19 09:30:19 +02:00
|
|
|
)?;
|
2021-08-24 13:01:31 +02:00
|
|
|
|
2023-10-18 13:53:58 +02:00
|
|
|
// send fid_docid_facet_numbers_chunk to DB writer
|
|
|
|
let fid_docid_facet_numbers_chunk =
|
|
|
|
unsafe { as_cloneable_grenad(&fid_docid_facet_numbers_chunk)? };
|
2021-08-26 11:01:30 +02:00
|
|
|
|
|
|
|
let _ = lmdb_writer_sx.send(Ok(TypedChunk::FieldIdDocidFacetNumbers(
|
2023-10-18 13:53:58 +02:00
|
|
|
fid_docid_facet_numbers_chunk.clone(),
|
2021-08-26 11:01:30 +02:00
|
|
|
)));
|
2021-08-24 13:01:31 +02:00
|
|
|
|
2023-10-18 13:53:58 +02:00
|
|
|
// send fid_docid_facet_strings_chunk to DB writer
|
|
|
|
let fid_docid_facet_strings_chunk =
|
|
|
|
unsafe { as_cloneable_grenad(&fid_docid_facet_strings_chunk)? };
|
2021-08-26 11:01:30 +02:00
|
|
|
|
|
|
|
let _ = lmdb_writer_sx.send(Ok(TypedChunk::FieldIdDocidFacetStrings(
|
2023-10-18 13:53:58 +02:00
|
|
|
fid_docid_facet_strings_chunk.clone(),
|
2021-08-26 11:01:30 +02:00
|
|
|
)));
|
2021-08-24 13:01:31 +02:00
|
|
|
|
2024-01-22 16:23:12 +01:00
|
|
|
let _ = lmdb_writer_sx
|
|
|
|
.send(Ok(TypedChunk::FieldIdFacetIsNullDocids(fid_facet_is_null_docids_chunk)));
|
|
|
|
|
|
|
|
let _ = lmdb_writer_sx.send(Ok(TypedChunk::FieldIdFacetIsEmptyDocids(
|
|
|
|
fid_facet_is_empty_docids_chunk,
|
|
|
|
)));
|
|
|
|
|
|
|
|
let _ = lmdb_writer_sx
|
|
|
|
.send(Ok(TypedChunk::FieldIdFacetExistsDocids(fid_facet_exists_docids_chunk)));
|
|
|
|
|
|
|
|
Ok((fid_docid_facet_numbers_chunk, fid_docid_facet_strings_chunk))
|
2021-08-24 13:01:31 +02:00
|
|
|
},
|
|
|
|
);
|
2021-09-02 15:17:52 +02:00
|
|
|
|
2023-10-18 13:53:58 +02:00
|
|
|
Ok((docid_word_positions_chunk?, fid_docid_facet_values_chunks?))
|
2021-08-24 13:01:31 +02:00
|
|
|
}
|