stiga-huang commented on code in PR #1375:
URL: https://github.com/apache/orc/pull/1375#discussion_r1172453769


##########
c++/src/RLEv2.hh:
##########
@@ -166,6 +166,50 @@ namespace orc {
 
     void next(int16_t* data, uint64_t numValues, const char* notNull) override;
 
+    unsigned char readByte();
+
+    void setBufStart(char* start) {

Review Comment:
   The parameter type can be `const char*`. Same for the parameter of 
`setBufEnd()`



##########
c++/src/RLEv2.hh:
##########
@@ -220,17 +251,40 @@ namespace orc {
 
     const std::unique_ptr<SeekableInputStream> inputStream;
     const bool isSigned;
-
     unsigned char firstByte;
-    uint64_t runLength;  // Length of the current run
-    uint64_t runRead;    // Number of returned values of the current run
-    const char* bufferStart;
-    const char* bufferEnd;
-    uint32_t bitsLeft;                  // Used by readLongs when bitSize < 8
-    uint32_t curByte;                   // Used by anything that uses readLongs
+    char* bufferStart;
+    char* bufferEnd;
+    uint64_t runLength;                 // Length of the current run
+    uint64_t runRead;                   // Number of returned values of the 
current run
+    uint32_t bitsLeft;                 // Used by readLongs when bitSize < 8
+    uint32_t curByte;                  // Used by anything that uses readLongs
     DataBuffer<int64_t> unpackedPatch;  // Used by PATCHED_BASE
     DataBuffer<int64_t> literals;       // Values of the current run
   };
+
+  inline void RleDecoderV2::resetBufferStart(uint64_t len, bool resetBuf, 
uint32_t backupByteLen) {
+    char* bufStart = getBufStart();
+    uint64_t remainingLen = bufLength();
+    int bufferLength = 0;
+    const void* bufferPointer = nullptr;
+
+    if (backupByteLen != 0) {
+      inputStream->BackUp(backupByteLen);
+    }
+
+    if (len >= remainingLen && resetBuf) {
+      if (!inputStream->Next(&bufferPointer, &bufferLength)) {
+        throw ParseError("bad read in RleDecoderV2::resetBufferStart");
+      }
+    }
+
+    if (bufferPointer == nullptr) {
+      setBufStart(bufStart + len);
+    } else {
+      setBufStart(const_cast<char*>(static_cast<const char*>(bufferPointer)));

Review Comment:
   If the parameter type of `setBufStart()` is `const char*`, we don't need 
these casts. Actually, accessing fields of the class itself in its methods 
don't need these get/set wrappers. Only external callers need them. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to