Example #1
0
 int decRef() {
   int newRefCount = refCount.decrementAndGet();
   if (DebugUtils.isTraceLockingEnabled()) {
     LlapIoImpl.LOG.info("Unlocked " + this + "; refcount " + newRefCount);
   }
   if (newRefCount < 0) {
     throw new AssertionError("Unexpected refCount " + newRefCount + ": " + this);
   }
   return newRefCount;
 }
Example #2
0
 /** @return Whether the we can invalidate; false if locked or already evicted. */
 @Override
 public boolean invalidate() {
   while (true) {
     int value = refCount.get();
     if (value != 0) return false;
     if (refCount.compareAndSet(value, EVICTED_REFCOUNT)) break;
   }
   if (DebugUtils.isTraceLockingEnabled()) {
     LlapIoImpl.LOG.info("Invalidated " + this + " due to eviction");
   }
   return true;
 }
Example #3
0
 int incRef() {
   int newRefCount = -1;
   while (true) {
     int oldRefCount = refCount.get();
     if (oldRefCount == EVICTED_REFCOUNT) return -1;
     assert oldRefCount >= 0 : "oldRefCount is " + oldRefCount + " " + this;
     newRefCount = oldRefCount + 1;
     if (refCount.compareAndSet(oldRefCount, newRefCount)) break;
   }
   if (DebugUtils.isTraceLockingEnabled()) {
     LlapIoImpl.LOG.info("Locked " + this + "; new ref count " + newRefCount);
   }
   return newRefCount;
 }
Example #4
0
 @Override
 public void returnData(OrcEncodedColumnBatch ecb) {
   for (ColumnStreamData[] datas : ecb.getColumnData()) {
     if (datas == null) continue;
     for (ColumnStreamData data : datas) {
       if (data == null || data.decRef() != 0) continue;
       if (DebugUtils.isTraceLockingEnabled()) {
         for (MemoryBuffer buf : data.getCacheBuffers()) {
           LlapIoImpl.LOG.info("Unlocking " + buf + " at the end of processing");
         }
       }
       lowLevelCache.releaseBuffers(data.getCacheBuffers());
       CSD_POOL.offer(data);
     }
   }
   // We can offer ECB even with some streams not discarded; reset() will clear the arrays.
   ECB_POOL.offer(ecb);
 }