in c++/src/RLEv1.cc [234:300]
void RleDecoderV1::next(T* const data, const uint64_t numValues, const char* const notNull) {
SCOPED_STOPWATCH(metrics, DecodingLatencyUs, DecodingCall);
uint64_t position = 0;
// skipNulls()
if (notNull) {
// Skip over null values.
while (position < numValues && !notNull[position]) {
++position;
}
}
while (position < numValues) {
// If we are out of values, read more.
if (remainingValues_ == 0) {
readHeader();
}
// How many do we read out of this block?
uint64_t count = std::min(numValues - position, remainingValues_);
uint64_t consumed = 0;
if (repeating_) {
if (notNull) {
for (uint64_t i = 0; i < count; ++i) {
if (notNull[position + i]) {
data[position + i] = static_cast<T>(value_ + static_cast<int64_t>(consumed) * delta_);
consumed += 1;
}
}
} else {
for (uint64_t i = 0; i < count; ++i) {
data[position + i] = static_cast<T>(value_ + static_cast<int64_t>(i) * delta_);
}
consumed = count;
}
value_ += static_cast<int64_t>(consumed) * delta_;
} else {
if (notNull) {
for (uint64_t i = 0; i < count; ++i) {
if (notNull[position + i]) {
data[position + i] =
isSigned_ ? static_cast<T>(unZigZag(readLong())) : static_cast<T>(readLong());
++consumed;
}
}
} else {
if (isSigned_) {
for (uint64_t i = 0; i < count; ++i) {
data[position + i] = static_cast<T>(unZigZag(readLong()));
}
} else {
for (uint64_t i = 0; i < count; ++i) {
data[position + i] = static_cast<T>(readLong());
}
}
consumed = count;
}
}
remainingValues_ -= consumed;
position += count;
// skipNulls()
if (notNull) {
// Skip over null values.
while (position < numValues && !notNull[position]) {
++position;
}
}
}
}