public synchronized List<T> consume(int start, int end) {
    List<T> rets = get(start, end);
    int upperBound = Math.min(end, size - 1);
    head = (end + 1) % capacity;
    size -= upperBound + 1;
    return rets;
  }
A queue that supports random access and consumption.
@param <T> Element type
samza-sql-shell/src/main/java/org/apache/samza/sql/client/util/RandomAccessQueue.java