| 133 | } |
| 134 | |
| 135 | Status GetResult(KernelContext* ctx, const DataType& type, ExecResult* out) { |
| 136 | // generator to emit next value:count pair |
| 137 | int index = 0; |
| 138 | auto gen = [&]() { |
| 139 | for (; index < static_cast<int>(counts.size()); ++index) { |
| 140 | if (counts[index] != 0) { |
| 141 | auto value_count = |
| 142 | std::make_pair(static_cast<CType>(index + this->min), counts[index]); |
| 143 | ++index; |
| 144 | return value_count; |
| 145 | } |
| 146 | } |
| 147 | return std::pair<CType, uint64_t>(0, kCountEOF); |
| 148 | }; |
| 149 | |
| 150 | return Finalize<T>(ctx, type, out, std::move(gen)); |
| 151 | } |
| 152 | |
| 153 | Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { |
| 154 | // count values in all chunks, ignore nulls |