public long seek(long newNextIndex) {
      lock.writeLock().lock();
      try {
        if (isClosed) {
          return -1;
        }

        newNextIndex = Math.max(firstIndex, Math.min(tailIndex, newNextIndex));
        final long oldNextIndex = nextIndex;

        if (newNextIndex < oldNextIndex) {
          currentNode = pilotNode;
          nextIndex = firstIndex;

          final long step = newNextIndex - firstIndex;
          for (long i = 0; i < step; ++i) {
            next();
          }
        } else {
          final long step = newNextIndex - oldNextIndex;
          for (long i = 0; i < step; ++i) {
            next();
          }
        }

        return nextIndex;
      } finally {
        lock.writeLock().unlock();
      }
    }
Seek to the given index, which represents the index of the next element to be returned. If
the given index is smaller than {@link ConcurrentIterableLinkedQueue#firstIndex}, the
iterator will be reset to the earliest element. If the given index is larger than {@link
ConcurrentIterableLinkedQueue#tailIndex}, the iterator will be reset to the latest element.
Otherwise, the iterator will be reset to the element whose index is the given index.

@param newNextIndex the given index
@return the actual index of the next element to be returned
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/queue/ConcurrentIterableLinkedQueue.java