@@ -303,8 +303,26 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
303
303
return Status::OK ();
304
304
}
305
305
306
- Status add_array_nulls (uint32_t row_id) override {
307
- _null_bitmap.add (row_id);
306
+ Status add_array_nulls (const uint8_t * null_map, size_t num_rows) override {
307
+ DCHECK (_rid >= num_rows);
308
+ if (num_rows == 0 || null_map == nullptr ) {
309
+ return Status::OK ();
310
+ }
311
+ std::vector<uint32_t > null_indices;
312
+ null_indices.reserve (num_rows / 8 );
313
+
314
+ // because _rid is the row id in block, not segment, and we add data before we add nulls,
315
+ // so we need to subtract num_rows to get the row id in segment
316
+ for (size_t i = 0 ; i < num_rows; i++) {
317
+ if (null_map[i] == 1 ) {
318
+ null_indices.push_back (_rid - num_rows + static_cast <uint32_t >(i));
319
+ }
320
+ }
321
+
322
+ if (!null_indices.empty ()) {
323
+ _null_bitmap.addMany (null_indices.size (), null_indices.data ());
324
+ }
325
+
308
326
return Status::OK ();
309
327
}
310
328
@@ -378,8 +396,9 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
378
396
return Status::OK ();
379
397
}
380
398
381
- Status add_array_values (size_t field_size, const void * value_ptr, const uint8_t * null_map,
382
- const uint8_t * offsets_ptr, size_t count) override {
399
+ Status add_array_values (size_t field_size, const void * value_ptr,
400
+ const uint8_t * nested_null_map, const uint8_t * offsets_ptr,
401
+ size_t count) override {
383
402
DBUG_EXECUTE_IF (" InvertedIndexColumnWriterImpl::add_array_values_count_is_zero" ,
384
403
{ count = 0 ; })
385
404
if (count == 0 ) {
@@ -404,7 +423,7 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
404
423
lucene::document::Field* new_field = nullptr ;
405
424
CL_NS (analysis)::TokenStream* ts = nullptr ;
406
425
for (auto j = start_off; j < start_off + array_elem_size; ++j) {
407
- if (null_map [j] == 1 ) {
426
+ if (nested_null_map && nested_null_map [j] == 1 ) {
408
427
continue ;
409
428
}
410
429
auto * v = (Slice*)((const uint8_t *)value_ptr + j * field_size);
@@ -500,7 +519,7 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
500
519
for (int i = 0 ; i < count; ++i) {
501
520
auto array_elem_size = offsets[i + 1 ] - offsets[i];
502
521
for (size_t j = start_off; j < start_off + array_elem_size; ++j) {
503
- if (null_map [j] == 1 ) {
522
+ if (nested_null_map && nested_null_map [j] == 1 ) {
504
523
continue ;
505
524
}
506
525
const CppType* p = &reinterpret_cast <const CppType*>(value_ptr)[j];
@@ -520,7 +539,8 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
520
539
DBUG_EXECUTE_IF (" InvertedIndexColumnWriterImpl::add_array_values_field_is_nullptr" ,
521
540
{ _field = nullptr ; })
522
541
DBUG_EXECUTE_IF (
523
- " InvertedIndexColumnWriterImpl::add_array_values_index_writer_is_nullptr" ,
542
+ " InvertedIndexColumnWriterImpl::add_array_values_index_writer_is_"
543
+ " nullptr" ,
524
544
{ _index_writer = nullptr ; })
525
545
if (_field == nullptr || _index_writer == nullptr ) {
526
546
LOG (ERROR) << " field or index writer is null in inverted index writer." ;
@@ -582,9 +602,10 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
582
602
std::string new_value;
583
603
size_t value_length = sizeof (CppType);
584
604
585
- DBUG_EXECUTE_IF (" InvertedIndexColumnWriterImpl::add_value_bkd_writer_add_throw_error" , {
586
- _CLTHROWA (CL_ERR_IllegalArgument, (" packedValue should be length=xxx" ));
587
- });
605
+ DBUG_EXECUTE_IF (
606
+ " InvertedIndexColumnWriterImpl::add_value_bkd_writer_add_throw_"
607
+ " error" ,
608
+ { _CLTHROWA (CL_ERR_IllegalArgument, (" packedValue should be length=xxx" )); });
588
609
589
610
_value_key_coder->full_encode_ascending (&value, &new_value);
590
611
_bkd_writer->add ((const uint8_t *)new_value.c_str (), value_length, _rid);
@@ -643,8 +664,8 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
643
664
_bkd_writer->finish (data_out.get (), index_out.get ()),
644
665
int (field_type));
645
666
} else {
646
- LOG (WARNING)
647
- << " Inverted index writer create output error occurred: nullptr" ;
667
+ LOG (WARNING) << " Inverted index writer create output error "
668
+ " occurred: nullptr" ;
648
669
_CLTHROWA (CL_ERR_IO, " Create output error with nullptr" );
649
670
}
650
671
} else if constexpr (field_is_slice_type (field_type)) {
@@ -653,9 +674,12 @@ class InvertedIndexColumnWriterImpl : public InvertedIndexColumnWriter {
653
674
InvertedIndexDescriptor::get_temporary_null_bitmap_file_name ()));
654
675
write_null_bitmap (null_bitmap_out.get ());
655
676
DBUG_EXECUTE_IF (
656
- " InvertedIndexWriter._throw_clucene_error_in_fulltext_writer_close" , {
677
+ " InvertedIndexWriter._throw_clucene_error_in_fulltext_"
678
+ " writer_close" ,
679
+ {
657
680
_CLTHROWA (CL_ERR_IO,
658
- " debug point: test throw error in fulltext index writer" );
681
+ " debug point: test throw error in fulltext "
682
+ " index writer" );
659
683
});
660
684
}
661
685
} catch (CLuceneError& e) {
0 commit comments