public synchronized List<T> get(int start, int end) {
    int lowerBound = Math.max(start, 0);
    int upperBound = Math.min(end, size - 1);
    List<T> rets = new ArrayList<>();
    for (int i = lowerBound; i <= upperBound; i++) {
      rets.add(buffer[(head + i) % capacity]);
    }
    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