MCPcopy Create free account
hub / github.com/apache/arrow / ComputeBitMapsForExpr

Method ComputeBitMapsForExpr

cpp/src/gandiva/llvm_generator.cc:494–530  ·  view source on GitHub ↗

Extract the bitmap addresses, and do an intersection.

Source from the content-addressed store, hash-verified

492
493/// Extract the bitmap addresses, and do an intersection.
494void LLVMGenerator::ComputeBitMapsForExpr(const CompiledExpr& compiled_expr,
495 const SelectionVector* selection_vector,
496 EvalBatch* eval_batch) const {
497 auto validities = compiled_expr.value_validity()->validity_exprs();
498
499 // Extract all the source bitmap addresses.
500 BitMapAccumulator accumulator(*eval_batch);
501 for (auto& validity_dex : validities) {
502 validity_dex->Accept(accumulator);
503 }
504
505 // Extract the destination bitmap address.
506 int out_idx = compiled_expr.output()->validity_idx();
507 uint8_t* dst_bitmap = eval_batch->GetBuffer(out_idx);
508 // Compute the destination bitmap.
509 if (selection_vector == nullptr) {
510 accumulator.ComputeResult(dst_bitmap);
511 } else {
512 /// The output bitmap is an intersection of some input/local bitmaps. However, with a
513 /// selection vector, only the bits corresponding to the indices in the selection
514 /// vector need to set in the output bitmap. This is done in two steps :
515 ///
516 /// 1. Do the intersection of input/local bitmaps to generate a temporary bitmap.
517 /// 2. copy just the relevant bits from the temporary bitmap to the output bitmap.
518 LocalBitMapsHolder bit_map_holder(eval_batch->num_records(), 1);
519 uint8_t* temp_bitmap = bit_map_holder.GetLocalBitMap(0);
520 accumulator.ComputeResult(temp_bitmap);
521
522 auto num_out_records = selection_vector->GetNumSlots();
523 // the memset isn't required, doing it just for valgrind.
524 memset(dst_bitmap, 0, arrow::bit_util::BytesForBits(num_out_records));
525 for (auto i = 0; i < num_out_records; ++i) {
526 auto bit = arrow::bit_util::GetBit(temp_bitmap, selection_vector->GetIndex(i));
527 arrow::bit_util::SetBitTo(dst_bitmap, i, bit);
528 }
529 }
530}
531
532llvm::Value* LLVMGenerator::AddFunctionCall(const std::string& full_name,
533 llvm::Type* ret_type,

Callers

nothing calls this directly

Calls 13

BytesForBitsFunction · 0.85
value_validityMethod · 0.80
validity_idxMethod · 0.80
outputMethod · 0.80
ComputeResultMethod · 0.80
num_recordsMethod · 0.80
GetNumSlotsMethod · 0.80
GetIndexMethod · 0.80
GetBitFunction · 0.50
SetBitToFunction · 0.50
AcceptMethod · 0.45
GetBufferMethod · 0.45

Tested by

no test coverage detected