extract the null bitmap from the leading nullity bytes of encoded keys
| 32 | |
| 33 | // extract the null bitmap from the leading nullity bytes of encoded keys |
| 34 | Status KeyEncoder::DecodeNulls(MemoryPool* pool, int32_t length, uint8_t** encoded_bytes, |
| 35 | std::shared_ptr<Buffer>* null_bitmap, |
| 36 | int32_t* null_count) { |
| 37 | // first count nulls to determine if a null bitmap is necessary |
| 38 | *null_count = 0; |
| 39 | for (int32_t i = 0; i < length; ++i) { |
| 40 | *null_count += (encoded_bytes[i][0] == kNullByte); |
| 41 | } |
| 42 | |
| 43 | if (*null_count > 0) { |
| 44 | ARROW_ASSIGN_OR_RAISE(*null_bitmap, AllocateBitmap(length, pool)); |
| 45 | uint8_t* validity = (*null_bitmap)->mutable_data(); |
| 46 | |
| 47 | FirstTimeBitmapWriter writer(validity, 0, length); |
| 48 | for (int32_t i = 0; i < length; ++i) { |
| 49 | if (encoded_bytes[i][0] == kValidByte) { |
| 50 | writer.Set(); |
| 51 | } else { |
| 52 | writer.Clear(); |
| 53 | } |
| 54 | writer.Next(); |
| 55 | encoded_bytes[i] += 1; |
| 56 | } |
| 57 | writer.Finish(); |
| 58 | } else { |
| 59 | for (int32_t i = 0; i < length; ++i) { |
| 60 | encoded_bytes[i] += 1; |
| 61 | } |
| 62 | } |
| 63 | return Status ::OK(); |
| 64 | } |
| 65 | |
| 66 | void BooleanKeyEncoder::AddLength(const ExecValue&, int64_t batch_length, |
| 67 | int32_t* lengths) { |
no test coverage detected