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

Method DecodeNulls

cpp/src/arrow/compute/row/row_encoder_internal.cc:34–64  ·  view source on GitHub ↗

extract the null bitmap from the leading nullity bytes of encoded keys

Source from the content-addressed store, hash-verified

32
33// extract the null bitmap from the leading nullity bytes of encoded keys
34Status 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
66void BooleanKeyEncoder::AddLength(const ExecValue&, int64_t batch_length,
67 int32_t* lengths) {

Callers 1

DecodeMethod · 0.45

Calls 8

AllocateBitmapFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.50
OKFunction · 0.50
mutable_dataMethod · 0.45
SetMethod · 0.45
ClearMethod · 0.45
NextMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected