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

Method PutVlqInt

cpp/src/arrow/util/bit_stream_utils_internal.h:353–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351
352template <typename Int>
353inline bool BitWriter::PutVlqInt(Int v) {
354 static_assert(std::is_integral_v<Int>);
355
356 constexpr auto kBufferSize = kMaxLEB128ByteLenFor<Int>;
357
358 uint8_t buffer[kBufferSize] = {};
359 const auto bytes_written = WriteLEB128(v, buffer, kBufferSize);
360 ARROW_DCHECK_LE(bytes_written, kBufferSize);
361 if constexpr (std::is_signed_v<Int>) {
362 // Can fail if negative
363 if (ARROW_PREDICT_FALSE(!bytes_written == 0)) {
364 return false;
365 }
366 } else {
367 // Cannot fail since we gave max space
368 ARROW_DCHECK_GT(bytes_written, 0);
369 }
370
371 for (int i = 0; i < bytes_written; ++i) {
372 const bool success = PutAligned(buffer[i], 1);
373 if (ARROW_PREDICT_FALSE(!success)) {
374 return false;
375 }
376 }
377
378 return true;
379}
380
381template <typename Int>
382inline bool BitReader::GetVlqInt(Int* v) {

Callers 2

FlushRepeatedRunMethod · 0.80
FlushValuesMethod · 0.80

Calls 1

WriteLEB128Function · 0.85

Tested by

no test coverage detected