Java Code Examples for java.util.concurrent.ConcurrentSkipListMap#size()

The following examples show how to use java.util.concurrent.ConcurrentSkipListMap#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentIndex.java    From ambry with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the start {@link Offset} of the given instance of  {@code indexSegments}.
 * @param indexSegments the map of index segment start {@link Offset} to {@link IndexSegment} instances
 */
private Offset getStartOffset(ConcurrentSkipListMap<Offset, IndexSegment> indexSegments) {
  Offset startOffset;
  if (indexSegments.size() == 0) {
    LogSegment firstLogSegment = log.getFirstSegment();
    startOffset = new Offset(firstLogSegment.getName(), firstLogSegment.getStartOffset());
  } else {
    startOffset = indexSegments.firstKey();
  }
  return startOffset;
}
 
Example 2
Source File: PersistentIndex.java    From ambry with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the end {@link Offset} of the given instance of {@code indexSegments}.
 * @param indexSegments the map of index segment start {@link Offset} to {@link IndexSegment} instances
 */
private Offset getCurrentEndOffset(ConcurrentSkipListMap<Offset, IndexSegment> indexSegments) {
  // If no indexSegments exist, return start offset of first log segment
  return indexSegments.size() == 0 ? getStartOffset(indexSegments)
      : indexSegments.lastEntry().getValue().getEndOffset();
}