Github user wgtmac commented on a diff in the pull request:
https://github.com/apache/orc/pull/273#discussion_r190800936
--- Diff: c++/src/RLE.cc ---
@@ -64,4 +66,55 @@ namespace orc {
}
}
+ void RleEncoder::add(const int64_t* data, uint64_t numValues,
+ const char* notNull) {
+ for (uint64_t i = 0; i < numValues; ++i) {
+ if (!notNull || notNull[i]) {
+ write(data[i]);
+ }
+ }
+ }
+
+ void RleEncoder::writeVslong(int64_t val) {
+ writeVulong((val << 1) ^ (val >> 63));
+ }
+
+ void RleEncoder::writeVulong(int64_t val) {
+ while (true) {
+ if ((val & ~0x7f) == 0) {
+ writeByte(static_cast<char>(val));
+ return;
+ } else {
+ writeByte(static_cast<char>(0x80 | (val & 0x7f)));
+ // cast val to unsigned so as to force 0-fill right shift
+ val = (static_cast<uint64_t>(val) >> 7);
+ }
+ }
+ }
+
+ void RleEncoder::writeByte(char c) {
+ if (bufferPosition == bufferLength) {
+ int addedSize = 0;
+ if (!outputStream->Next(reinterpret_cast<void **>(&buffer),
&addedSize)) {
+ throw std::bad_alloc();
+ }
+ bufferPosition = 0;
+ bufferLength = static_cast<size_t>(addedSize);
+ }
+ buffer[bufferPosition++] = c;
+ }
+
+ void RleEncoder::recordPosition(PositionRecorder* recorder) const {
--- End diff --
We haven't added support for writing index stream so far. Remove this
function for now and that should be in a separate change.
---