pvary commented on a change in pull request #1675:
URL: https://github.com/apache/hive/pull/1675#discussion_r524122923



##########
File path: 
llap-server/src/java/org/apache/hadoop/hive/llap/cache/LowLevelLrfuCachePolicy.java
##########
@@ -240,18 +247,38 @@ public void setEvictionListener(EvictionListener 
listener) {
     this.evictionListener = listener;
   }
 
-  @Override
-  public long purge() {
+  private long evictOrPurge(boolean isPurge) {
     long evicted = 0;
     LlapCacheableBuffer oldTail;
     listLock.lock();
     try {
       LlapCacheableBuffer current = listTail;
+      LlapCacheableBuffer lockedHead = null;
+      LlapCacheableBuffer lockedTail = null;
       oldTail = listTail;
       while (current != null) {
-        boolean canEvict = LlapCacheableBuffer.INVALIDATE_OK == 
current.invalidate();
+        // Case for when there is proactive eviction, but current buffer is 
not marked -> thus need to be kept
+        if (!isPurge && !current.isMarkedForEviction()) {
+          LlapCacheableBuffer newCurrent = current.prev;
+          oldTail = removeFromLocalList(oldTail, current);
+
+          current.indexInHeap = LlapCacheableBuffer.IN_LIST;
+          if (lockedHead != null) {
+            current.next = lockedHead;
+            lockedHead.prev = current;
+            lockedHead = current;
+          } else {
+            lockedHead = current;
+            lockedTail = current;
+            current.next = null;
+          }
+
+          current = newCurrent;
+          continue;

Review comment:
       Have I told you that I hate `continue`?
   This is basically an `if/else` in disguise :(
   




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to