Generate the DelAdd for is_null, is_empty, and exists

This commit is contained in:
Clément Renault 2023-10-17 18:15:14 +02:00
parent c829feb40b
commit 7d546b9c22
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -325,10 +325,14 @@ pub fn extract_fid_docid_facet_values<R: io::Read + io::Seek>(
indexer.chunk_compression_level, indexer.chunk_compression_level,
tempfile::tempfile()?, tempfile::tempfile()?,
); );
// TODO generate an Obkv<DelAdd, Bitmap> for (fid, (del_bitmap, add_bitmap)) in facet_exists_docids.into_iter() {
for (fid, bitmap) in facet_exists_docids.into_iter() { let mut obkv = KvWriterDelAdd::memory();
let bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&bitmap).unwrap(); let del_bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&del_bitmap).unwrap();
facet_exists_docids_writer.insert(fid.to_be_bytes(), &bitmap_bytes)?; let add_bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&add_bitmap).unwrap();
obkv.insert(DelAdd::Deletion, del_bitmap_bytes)?;
obkv.insert(DelAdd::Addition, add_bitmap_bytes)?;
let bytes = obkv.into_inner()?;
facet_exists_docids_writer.insert(fid.to_be_bytes(), &bytes)?;
} }
let facet_exists_docids_reader = writer_into_reader(facet_exists_docids_writer)?; let facet_exists_docids_reader = writer_into_reader(facet_exists_docids_writer)?;
@ -337,22 +341,30 @@ pub fn extract_fid_docid_facet_values<R: io::Read + io::Seek>(
indexer.chunk_compression_level, indexer.chunk_compression_level,
tempfile::tempfile()?, tempfile::tempfile()?,
); );
// TODO generate an Obkv<DelAdd, Bitmap> for (fid, (del_bitmap, add_bitmap)) in facet_is_null_docids.into_iter() {
for (fid, bitmap) in facet_is_null_docids.into_iter() { let mut obkv = KvWriterDelAdd::memory();
let bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&bitmap).unwrap(); let del_bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&del_bitmap).unwrap();
facet_is_null_docids_writer.insert(fid.to_be_bytes(), &bitmap_bytes)?; let add_bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&add_bitmap).unwrap();
obkv.insert(DelAdd::Deletion, del_bitmap_bytes)?;
obkv.insert(DelAdd::Addition, add_bitmap_bytes)?;
let bytes = obkv.into_inner()?;
facet_is_null_docids_writer.insert(fid.to_be_bytes(), &bytes)?;
} }
let facet_is_null_docids_reader = writer_into_reader(facet_is_null_docids_writer)?; let facet_is_null_docids_reader = writer_into_reader(facet_is_null_docids_writer)?;
// TODO generate an Obkv<DelAdd, Bitmap>
let mut facet_is_empty_docids_writer = create_writer( let mut facet_is_empty_docids_writer = create_writer(
indexer.chunk_compression_type, indexer.chunk_compression_type,
indexer.chunk_compression_level, indexer.chunk_compression_level,
tempfile::tempfile()?, tempfile::tempfile()?,
); );
for (fid, bitmap) in facet_is_empty_docids.into_iter() { for (fid, (del_bitmap, add_bitmap)) in facet_is_empty_docids.into_iter() {
let bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&bitmap).unwrap(); let mut obkv = KvWriterDelAdd::memory();
facet_is_empty_docids_writer.insert(fid.to_be_bytes(), &bitmap_bytes)?; let del_bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&del_bitmap).unwrap();
let add_bitmap_bytes = CboRoaringBitmapCodec::bytes_encode(&add_bitmap).unwrap();
obkv.insert(DelAdd::Deletion, del_bitmap_bytes)?;
obkv.insert(DelAdd::Addition, add_bitmap_bytes)?;
let bytes = obkv.into_inner()?;
facet_is_empty_docids_writer.insert(fid.to_be_bytes(), &bytes)?;
} }
let facet_is_empty_docids_reader = writer_into_reader(facet_is_empty_docids_writer)?; let facet_is_empty_docids_reader = writer_into_reader(facet_is_empty_docids_writer)?;