public void compact(long index) {
    Map.Entry<Long, JournalSegment<E>> segmentEntry = segments.floorEntry(index);
    if (segmentEntry != null) {
      SortedMap<Long, JournalSegment<E>> compactSegments = segments.headMap(segmentEntry.getValue().index());
      if (!compactSegments.isEmpty()) {
        log.debug("{} - Compacting {} segment(s)", name, compactSegments.size());
        for (JournalSegment segment : compactSegments.values()) {
          log.trace("Deleting segment: {}", segment);
          segment.close();
          segment.delete();
        }
        compactSegments.clear();
        resetHead(segmentEntry.getValue().index());
      }
    }
  }
public void compact ( long index ) { Map . Entry < Long , JournalSegment < E > > segmentEntry = segments . floorEntry ( index ) ; if ( segmentEntry != null ) { SortedMap < Long , JournalSegment < E > > compactSegments = segments . headMap ( segmentEntry . getValue ( ) . index ( ) ) ; if ( ! compactSegments . isEmpty ( ) ) { log . debug ( "{} - Compacting {} segment(s)" , name , compactSegments . size ( ) ) ; for ( JournalSegment segment : compactSegments . values ( ) ) { log . trace ( "Deleting segment: {}" , segment ) ; segment . close ( ) ; segment . delete ( ) ; } compactSegments . clear ( ) ; resetHead ( segmentEntry . getValue ( ) . index ( ) ) ; } } }
Compacts the journal up to the given index.
<p>
The semantics of compaction are not specified by this interface.

@param index The index up to which to compact the journal.