orc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yuruiz <...@git.apache.org>
Subject [GitHub] orc pull request #273: ORC-343 Enable C++ writer to support RleV2
Date Mon, 28 May 2018 03:06:34 GMT
Github user yuruiz commented on a diff in the pull request:

    https://github.com/apache/orc/pull/273#discussion_r191102909
  
    --- 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 --
    
    This method has been exits for a while, removing it requires a wide range refactoring,
which is not the purpose of this PR.


---

Mime
View raw message