fix(fuzzer): fix the fuzzer after #430

This commit is contained in:
Tamo 2022-01-25 12:08:47 +01:00
parent fd177b63f8
commit fb51d511be
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69

View File

@ -8,7 +8,7 @@ use arbitrary_json::ArbitraryValue;
use heed::EnvOpenOptions; use heed::EnvOpenOptions;
use libfuzzer_sys::fuzz_target; use libfuzzer_sys::fuzz_target;
use milli::documents::{DocumentBatchBuilder, DocumentBatchReader}; use milli::documents::{DocumentBatchBuilder, DocumentBatchReader};
use milli::update::UpdateBuilder; use milli::update::{IndexDocuments, IndexDocumentsConfig, IndexerConfig, Settings};
use milli::Index; use milli::Index;
use serde_json::Value; use serde_json::Value;
@ -35,11 +35,14 @@ fn index_documents(
index: &mut milli::Index, index: &mut milli::Index,
documents: DocumentBatchReader<Cursor<Vec<u8>>>, documents: DocumentBatchReader<Cursor<Vec<u8>>>,
) -> Result<()> { ) -> Result<()> {
let update_builder = UpdateBuilder::new(); let config = IndexerConfig::default();
let mut wtxn = index.write_txn()?; let mut wtxn = index.write_txn()?;
let builder = update_builder.index_documents(&mut wtxn, &index);
builder.execute(documents, |_| ())?; let indexing_config = IndexDocumentsConfig::default();
let mut builder = IndexDocuments::new(&mut wtxn, &index, &config, indexing_config, |_| ());
builder.add_documents(documents)?;
builder.execute().unwrap();
wtxn.commit()?; wtxn.commit()?;
Ok(()) Ok(())
} }
@ -51,9 +54,10 @@ fn create_index() -> Result<milli::Index> {
options.max_readers(1); options.max_readers(1);
let index = Index::new(options, dir.path())?; let index = Index::new(options, dir.path())?;
let update_builder = UpdateBuilder::new(); let config = IndexerConfig::default();
let mut wtxn = index.write_txn().unwrap(); let mut wtxn = index.write_txn().unwrap();
let mut builder = update_builder.settings(&mut wtxn, &index);
let mut builder = Settings::new(&mut wtxn, &index, &config);
let displayed_fields = let displayed_fields =
["id", "title", "album", "artist", "genre", "country", "released", "duration"] ["id", "title", "album", "artist", "genre", "country", "released", "duration"]