private int incRefInternal(boolean doWait) {
    long newValue = -1;
    while (true) {
      long oldValue = state.get();
      if (State.hasFlags(oldValue, State.FLAG_EVICTED)) return INCREF_EVICTED;
      if (State.hasFlags(oldValue, State.FLAG_MOVING)) {
        if (!doWait || !waitForState()) return INCREF_FAILED; // Thread is being interrupted.
        continue;
      }
      int oldRefCount = State.getRefCount(oldValue);
      assert oldRefCount >= 0 : "oldValue is " + oldValue + " " + this;
      if (oldRefCount == State.MAX_REFCOUNT) throw new AssertionError(this);
      newValue = State.incRefCount(oldValue);
      if (State.hasFlags(oldValue, State.FLAG_NEW_ALLOC)) {
        // Remove new-alloc flag on first use. Full unlock after that would imply force-discarding
        // this buffer is acceptable. This is kind of an ugly compact between the cache and us.
        newValue = State.switchFlag(newValue, State.FLAG_NEW_ALLOC);
      }
      if (state.compareAndSet(oldValue, newValue)) break;
    }
    int newRefCount = State.getRefCount(newValue);
    if (LlapIoImpl.LOCKING_LOGGER.isTraceEnabled()) {
      LlapIoImpl.LOCKING_LOGGER.trace("Locked {}; new ref count {}", this, newRefCount);
    }
    return newRefCount;
  }
Allocator uses this to remember the allocation size. Somewhat redundant with header.
llap-server/src/java/org/apache/hadoop/hive/llap/cache/LlapAllocatorBuffer.java