public int releaseInvalidated() {
    long oldValue, newValue;
    do {
      oldValue = state.get();
      if (!State.hasFlags(oldValue, State.FLAG_EVICTED)) {
        throw new AssertionError("Not invalidated");
      }
      if (State.hasFlags(oldValue, State.FLAG_MOVING | State.FLAG_REMOVED)) return -1;
      // No move pending and no intervening discard, the allocator can release.
      newValue = State.setFlag(oldValue, State.FLAG_REMOVED);
    } while (!state.compareAndSet(oldValue, newValue));
    if (LlapIoImpl.LOCKING_LOGGER.isTraceEnabled()) {
      LlapIoImpl.LOCKING_LOGGER.trace("Removed {}", this);
    }
    // Arena cannot change after we have marked it as released.
    return State.getArena(oldValue);
  }
Marks previously invalidated buffer as released.
@return Whether the buffer memory can be released.
llap-server/src/java/org/apache/hadoop/hive/llap/cache/LlapAllocatorBuffer.java