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

Method Evaluate

cpp/src/gandiva/filter.cc:91–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91Status 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
122const std::string& Filter::DumpIR() { return llvm_generator_->ir(); }
123

Callers 4

ggandiva_filter_evaluateFunction · 0.45
ExampleFunction · 0.45

Calls 10

GetMaxSlotsMethod · 0.80
GetLocalBitMapSizeMethod · 0.80
PopulateFromBitMapMethod · 0.80
MakeFunction · 0.70
InvalidFunction · 0.50
num_rowsMethod · 0.45
EqualsMethod · 0.45
schemaMethod · 0.45
GetLocalBitMapMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected