/** Adds the obsolete offsets as well as the totals of the given object. */ void addTrackedSummary(TrackedFileSummary other) { /* Add the totals. */ add(other); /* * Add the offsets and the memory used [#15505] by the other tracker. * The memory budget has already been updated for the offsets to be * added, so we only need to account for a possible difference of one * segment when we merge them. */ memSize += other.memSize; if (other.obsoleteOffsets != null) { if (obsoleteOffsets != null) { /* Merge the other offsets into our list. */ if (obsoleteOffsets.merge(other.obsoleteOffsets)) { /* There is one segment less as a result of the merge. */ updateMemoryBudget(-MemoryBudget.TFS_LIST_SEGMENT_OVERHEAD); } } else { /* Adopt the other's offsets as our own. */ obsoleteOffsets = other.obsoleteOffsets; } } }
/** * Returns whether the given offset is present in the tracked offsets. This does not indicate * whether the offset is obsolete in general, but only if it is known to be obsolete in this * version of the tracked information. */ boolean containsObsoleteOffset(long offset) { if (obsoleteOffsets != null) { return obsoleteOffsets.contains(offset); } else { return false; } }
/** Returns obsolete offsets as an array of longs, or null if none. */ public long[] getObsoleteOffsets() { if (obsoleteOffsets != null) { return obsoleteOffsets.toArray(); } else { return null; } }
/** * Tracks the given offset as obsolete or non-obsolete. * * <p>Must be called under the log write latch. */ void trackObsolete(long offset) { if (!trackDetail) { return; } int adjustMem = 0; if (obsoleteOffsets == null) { obsoleteOffsets = new OffsetList(); adjustMem += MemoryBudget.TFS_LIST_INITIAL_OVERHEAD; } if (obsoleteOffsets.add(offset, tracker.getEnvironment().isOpen())) { adjustMem += MemoryBudget.TFS_LIST_SEGMENT_OVERHEAD; } if (adjustMem != 0) { updateMemoryBudget(adjustMem); } }