IntTimestampGetter (@NotNull TimestampGetter delegateGetter, int blockSize) { if (delegateGetter.size() < 0) throw new NegativeArraySizeException("delegateGetter.size() < 0: " + delegateGetter.size()); if (delegateGetter.size() == 0) throw new IllegalArgumentException("Empty TimestampGetter not supported"); long[] saveTimestamps = new long[(delegateGetter.size() - 1) / blockSize + 1]; for (int i = 0; i < saveTimestamps.length; i++) { saveTimestamps[i] = delegateGetter.getTimestamp(blockSize * i); } Int2LongOpenHashMap brokenDeltas = new Int2LongOpenHashMap(); int[] deltas = new int[delegateGetter.size()]; for (int i = 0; i < delegateGetter.size(); i++) { int blockIndex = i - (i % blockSize); long delta = delegateGetter.getTimestamp(i) - delegateGetter.getTimestamp(blockIndex); int intDelta = deltaToInt(delta); deltas[i] = intDelta; if (intDelta == BROKEN_DELTA) brokenDeltas.put(i, delta); } brokenDeltas.trim(); return new IntTimestampGetter(deltas, blockSize, saveTimestamps, brokenDeltas); }