private long getTotalBytesRead(StoreFindToken token, List<MessageInfo> messageEntries, Offset logEndOffsetBeforeFind,
      ConcurrentSkipListMap<Offset, IndexSegment> indexSegments) {
    long bytesRead = 0;
    if (token.getType().equals(FindTokenType.IndexBased)) {
      try {
        if (token.getOffset().equals(validIndexSegments.lastKey())) {
          bytesRead = getAbsoluteReadBytesFromIndexBasedToken(token, indexSegments);
        } else {
          bytesRead = getAbsolutePositionInLogForOffset(token.getOffset(), indexSegments);
        }
      } catch (StoreException e) {
        //If get read bytes from storeKey fails, use the start offset in index based token.
        logger.error(
            "Store exception on getAbsoluteReadBytesFromIndexBasedToken request with error code {} in datadir {} ",
            e.getErrorCode(), dataDir);
        bytesRead = getAbsolutePositionInLogForOffset(token.getOffset(), indexSegments);
      }
    } else if (token.getType().equals(FindTokenType.JournalBased)) {
      if (messageEntries.size() > 0) {
        bytesRead = getAbsolutePositionInLogForOffset(token.getOffset(), indexSegments) + messageEntries.get(
            messageEntries.size() - 1).getSize();
      } else {
        bytesRead = getAbsolutePositionInLogForOffset(logEndOffsetBeforeFind, indexSegments);
      }
    }
    return bytesRead;
  }
Gets the total number of bytes from the beginning of the log to the position of {@code token}. This includes any
overhead due to headers and empty space.
@param token the point until which the log has been read.
@param messageEntries the list of {@link MessageInfo} that were read when producing {@code token}.
@param logEndOffsetBeforeFind the end offset of the log before a find was attempted.
@param indexSegments the list of index segments to use.
@return the total number of bytes read from the log at the position of {@code token}.
ambry-store/src/main/java/com/github/ambry/store/PersistentIndex.java