| 109 | } |
| 110 | |
| 111 | Result<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 | |
| 142 | Result<Datum> DropNullTable(const std::shared_ptr<Table>& table, ExecContext* ctx) { |
| 143 | if (table->num_rows() == 0) { |
no test coverage detected