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

Function DropNullRecordBatch

cpp/src/arrow/compute/kernels/vector_selection.cc:111–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111Result<Datum> DropNullRecordBatch(const std::shared_ptr<RecordBatch>& batch,
112 ExecContext* ctx) {
113 // Compute an upper bound of the final null count
114 int64_t null_count = 0;
115 for (const auto& column : batch->columns()) {
116 null_count += column->null_count();
117 }
118 if (null_count == 0) {
119 return batch;
120 }
121 ARROW_ASSIGN_OR_RAISE(auto dst,
122 AllocateEmptyBitmap(batch->num_rows(), ctx->memory_pool()));
123 bit_util::SetBitsTo(dst->mutable_data(), 0, batch->num_rows(), true);
124 for (const auto& column : batch->columns()) {
125 if (column->type()->id() == Type::type::NA) {
126 bit_util::SetBitsTo(dst->mutable_data(), 0, batch->num_rows(), false);
127 break;
128 }
129 if (column->null_bitmap_data()) {
130 ::arrow::internal::BitmapAnd(column->null_bitmap_data(), column->offset(),
131 dst->data(), 0, column->length(), 0,
132 dst->mutable_data());
133 }
134 }
135 auto drop_null_filter = std::make_shared<BooleanArray>(batch->num_rows(), dst);
136 if (drop_null_filter->true_count() == 0) {
137 return RecordBatch::MakeEmpty(batch->schema(), ctx->memory_pool());
138 }
139 return Filter(Datum(batch), Datum(drop_null_filter), FilterOptions::Defaults(), ctx);
140}
141
142Result<Datum> DropNullTable(const std::shared_ptr<Table>& table, ExecContext* ctx) {
143 if (table->num_rows() == 0) {

Callers 1

ExecuteImplMethod · 0.85

Calls 15

BitmapAndFunction · 0.85
FilterFunction · 0.85
columnsMethod · 0.80
true_countMethod · 0.80
SetBitsToFunction · 0.50
DatumClass · 0.50
DefaultsFunction · 0.50
null_countMethod · 0.45
mutable_dataMethod · 0.45
num_rowsMethod · 0.45
idMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected