public final int getDiffIndexById(final int snapshotId) { int diffIndex = diffs.binarySearch(snapshotId); diffIndex = diffIndex < 0 ? (-diffIndex - 1) : diffIndex; return diffIndex; }
@Override public int binarySearch(int i) { return diffs.binarySearch(i); }
public BlockInfo[] findEarlierSnapshotBlocks(int snapshotId) { assert snapshotId != Snapshot.NO_SNAPSHOT_ID : "Wrong snapshot id"; if (snapshotId == Snapshot.CURRENT_STATE_ID) { return null; } DiffList<FileDiff> diffs = this.asList(); int i = diffs.binarySearch(snapshotId); BlockInfo[] blocks = null; for(i = i >= 0 ? i : -i-2; i >= 0; i--) { blocks = diffs.get(i).getBlocks(); if(blocks != null) { break; } } return blocks; }
public final D getDiffById(final int snapshotId) { if (snapshotId == Snapshot.CURRENT_STATE_ID || diffs == null) { return null; } final int i = diffs.binarySearch(snapshotId); if (i >= 0) { // exact match return diffs.get(i); } else { // Exact match not found means that there were no changes between // given snapshot and the next state so that the diff for the given // snapshot was not recorded. Thus, return the next state. final int j = -i - 1; return j < diffs.size() ? diffs.get(j) : null; } }
public BlockInfo[] findLaterSnapshotBlocks(int snapshotId) { assert snapshotId != Snapshot.NO_SNAPSHOT_ID : "Wrong snapshot id"; if (snapshotId == Snapshot.CURRENT_STATE_ID) { return null; } DiffList<FileDiff> diffs = this.asList(); int i = diffs.binarySearch(snapshotId); BlockInfo[] blocks = null; for (i = i >= 0 ? i+1 : -i-1; i < diffs.size(); i++) { blocks = diffs.get(i).getBlocks(); if (blocks != null) { break; } } return blocks; }
final int i = diffs.binarySearch(anchorId); if (exclusive) { // must be the one before if (i == -1 || i == 0) {
return; int snapshotIndex = diffs.binarySearch(snapshot);