coderex2522 commented on code in PR #1114:
URL: https://github.com/apache/orc/pull/1114#discussion_r875511335


##########
c++/src/Reader.hh:
##########
@@ -187,6 +188,16 @@ namespace orc {
     friend class TestRowReader_advanceToNextRowGroup_Test;
     friend class TestRowReader_computeBatchSize_Test;
 
+    inline uint64_t lastRowOfCurrentStripe() const {

Review Comment:
   The function has remove.



##########
c++/src/Reader.cc:
##########
@@ -391,27 +392,39 @@ namespace orc {
       return;
     }
 
-    currentStripe = seekToStripe;
-    currentRowInStripe = rowNumber - firstRowOfStripe[currentStripe];
     previousRow = rowNumber;
-    startNextStripe();
+    auto rowIndexStride = footer->rowindexstride();
+    if (!isCurrentStripeInited()
+        || currentStripe != seekToStripe
+        || rowIndexStride == 0
+        || currentStripeInfo.indexlength() == 0) {
+      // current stripe is not initialized or
+      // target stripe is not current stripe or
+      // current stripe doesn't have row indexes
+      currentStripe = seekToStripe;
+      currentRowInStripe = rowNumber - firstRowOfStripe[currentStripe];
+      startNextStripe();
+      if (currentStripe >= lastStripe) {
+        return;
+      }
+    } else {
+      currentRowInStripe = rowNumber - firstRowOfStripe[currentStripe];
+      if (sargsApplier) {
+        // advance to selected row group if predicate pushdown is enabled
+        currentRowInStripe = advanceToNextRowGroup(currentRowInStripe,
+                                                   rowsInCurrentStripe,
+                                                   footer->rowindexstride(),
+                                                   
sargsApplier->getNextSkippedRows());
+      }
+    }
 
     uint64_t rowsToSkip = currentRowInStripe;
-    auto rowIndexStride = footer->rowindexstride();
     // seek to the target row group if row indexes exists
     if (rowIndexStride > 0 && currentStripeInfo.indexlength() > 0) {
-      // when predicate push down is enabled, above call to startNextStripe()
-      // will move current row to 1st matching row group; here we only need
-      // to deal with the case when PPD is not enabled.
-      if (!sargsApplier) {
-        if (rowIndexes.empty()) {
-          loadStripeIndex();
-        }
-        auto rowGroupId = static_cast<uint32_t>(rowsToSkip / rowIndexStride);
-        if (rowGroupId != 0) {
-          seekToRowGroup(rowGroupId);
-        }
+      if (rowIndexes.empty()) {
+        loadStripeIndex();
       }
+      seekToRowGroup(static_cast<uint32_t>(rowsToSkip / rowIndexStride));

Review Comment:
   Done



##########
c++/src/Reader.hh:
##########
@@ -146,6 +146,7 @@ namespace orc {
     uint64_t firstStripe;
     uint64_t currentStripe;
     uint64_t lastStripe; // the stripe AFTER the last one
+    uint64_t currentInitedStripe;

Review Comment:
   Done.



-- 
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