@Override public boolean hasNext() { if (currentIndex >= items.size()) return false; if (currentCursor == null) return false; if (currentCursor.hasNext()) return true; while (true) { try { boolean ret = loadNext(); if (!ret) return false; if (currentCursor.hasNext()) return true; } catch (IOException e) { logger.warn("kraken logstorage: cannot fetch next index from merged cursor, skipping", e); } } }
private boolean loadNext() throws IOException { if (currentCursor != null) { currentCursor.close(); currentCursor = null; } if (currentIndex >= items.size() - 1) return false; load(++currentIndex); return true; }
@Override public void close() { if (currentCursor != null) currentCursor.close(); }
@Override public LogIndexItem next() { if (!hasNext()) throw new NoSuchElementException(); return currentCursor.next(); }