public synchronized void add(T t) {
    if (size >= capacity) {
      buffer[head] = t;
      head = (head + 1) % capacity;
    } else {
      int pos = (head + size) % capacity;
      buffer[pos] = t;
      size++;
    }
  }
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