/** * Construct a new indexer. It maps each long key to its position in the list, and then be ready for more keys. * * @param keys The list of keys to store. */ public static HashKeyIndex create(LongList keys) { HashKeyIndex idx = create(); LongIterator iter = keys.iterator(); while (iter.hasNext()) { idx.internId(iter.nextLong()); } return idx; }
/** * Returns a {@link StreamDataFileIndexIterator} for iterating over all (timestamp, position) pairs. */ StreamDataFileIndexIterator indexIterator() { final LongListIterator timestampIter = timestamps.iterator(); final LongListIterator positionIter = positions.iterator(); return new StreamDataFileIndexIterator() { private long timestamp; private long position; @Override public boolean nextIndexEntry() { if (timestampIter.hasNext() && positionIter.hasNext()) { timestamp = timestampIter.nextLong(); position = positionIter.nextLong(); return true; } return false; } @Override public long currentTimestamp() { return timestamp; } @Override public long currentPosition() { return position; } }; }
@Override public LongBigListIterator iterator() { return LongBigListIterators.asBigListIterator(list.iterator()); } @Override
/** * Construct a new indexer. It maps each long key to its position in the list, and then be ready for more keys. * * @param keys The list of keys to store. */ public static HashKeyIndex create(LongList keys) { HashKeyIndex idx = create(); LongIterator iter = keys.iterator(); while (iter.hasNext()) { idx.internId(iter.nextLong()); } return idx; }
private boolean doTruncateInvalidTxBefore(long time) throws InvalidTruncateTimeException { LOG.info("Removing tx ids before {} from invalid list", time); long truncateWp = time * TxConstants.MAX_TX_PER_MS; // Check if there any in-progress transactions started earlier than truncate time if (inProgress.lowerKey(truncateWp) != null) { throw new InvalidTruncateTimeException("Transactions started earlier than " + time + " are in-progress"); } // Find all invalid transactions earlier than truncateWp LongSet toTruncate = new LongArraySet(); LongIterator it = invalidTxList.toRawList().iterator(); while (it.hasNext()) { long wp = it.nextLong(); if (wp < truncateWp) { toTruncate.add(wp); } } LOG.info("Removing tx ids {} from invalid list", toTruncate); return invalidTxList.removeAll(toTruncate); }