| 89 | } |
| 90 | |
| 91 | Status Filter::Evaluate(const arrow::RecordBatch& batch, |
| 92 | std::shared_ptr<SelectionVector> out_selection) { |
| 93 | const auto num_rows = batch.num_rows(); |
| 94 | ARROW_RETURN_IF(!batch.schema()->Equals(*schema_), |
| 95 | Status::Invalid("RecordBatch schema must expected filter schema")); |
| 96 | ARROW_RETURN_IF(num_rows == 0, Status::Invalid("RecordBatch must be non-empty.")); |
| 97 | ARROW_RETURN_IF(out_selection == nullptr, |
| 98 | Status::Invalid("out_selection must be non-null.")); |
| 99 | ARROW_RETURN_IF(out_selection->GetMaxSlots() < num_rows, |
| 100 | Status::Invalid("Output selection vector capacity too small")); |
| 101 | |
| 102 | // Allocate three local_bitmaps (one for output, one for validity, one to compute the |
| 103 | // intersection). |
| 104 | LocalBitMapsHolder bitmaps(num_rows, 3 /*local_bitmaps*/); |
| 105 | int64_t bitmap_size = bitmaps.GetLocalBitMapSize(); |
| 106 | |
| 107 | auto validity = std::make_shared<arrow::Buffer>(bitmaps.GetLocalBitMap(0), bitmap_size); |
| 108 | auto value = std::make_shared<arrow::Buffer>(bitmaps.GetLocalBitMap(1), bitmap_size); |
| 109 | auto array_data = arrow::ArrayData::Make(arrow::boolean(), num_rows, {validity, value}); |
| 110 | |
| 111 | // Execute the expression(s). |
| 112 | ARROW_RETURN_NOT_OK(llvm_generator_->Execute(batch, {array_data})); |
| 113 | |
| 114 | // Compute the intersection of the value and validity. |
| 115 | auto result = bitmaps.GetLocalBitMap(2); |
| 116 | BitMapAccumulator::IntersectBitMaps( |
| 117 | result, {bitmaps.GetLocalBitMap(0), bitmaps.GetLocalBitMap((1))}, {0, 0}, num_rows); |
| 118 | |
| 119 | return out_selection->PopulateFromBitMap(result, bitmap_size, num_rows - 1); |
| 120 | } |
| 121 | |
| 122 | const std::string& Filter::DumpIR() { return llvm_generator_->ir(); } |
| 123 |
no test coverage detected