private MessageWriteSetStateInStore checkWriteSetStateInStore(MessageWriteSet messageSetToWrite, FileSpan fileSpan)
      throws StoreException {
    int existingIdenticalEntries = 0;
    for (MessageInfo info : messageSetToWrite.getMessageSetInfo()) {
      if (index.findKey(info.getStoreKey(), fileSpan,
          EnumSet.of(PersistentIndex.IndexEntryType.PUT, PersistentIndex.IndexEntryType.DELETE)) != null) {
        if (index.wasRecentlySeenOrCrcIsNull(info)) {
          existingIdenticalEntries++;
          metrics.identicalPutAttemptCount.inc();
        } else {
          logger.error("COLLISION: For key {} in WriteSet with crc {}, index already has the key with journal crc {}",
              info.getStoreKey(), info.getCrc(), index.journal.getCrcOfKey(info.getStoreKey()));
          return MessageWriteSetStateInStore.COLLIDING;
        }
      }
    }
    if (existingIdenticalEntries == messageSetToWrite.getMessageSetInfo().size()) {
      return MessageWriteSetStateInStore.ALL_DUPLICATE;
    } else if (existingIdenticalEntries > 0) {
      return MessageWriteSetStateInStore.SOME_NOT_ALL_DUPLICATE;
    } else {
      return MessageWriteSetStateInStore.ALL_ABSENT;
    }
  }
Checks the state of the messages in the given {@link MessageWriteSet} in the given {@link FileSpan}.
@param messageSetToWrite Non-empty set of messages to write to the store.
@param fileSpan The fileSpan on which the check for existence of the messages have to be made.
@return {@link MessageWriteSetStateInStore} representing the outcome of the state check.
@throws StoreException relays those encountered from {@link PersistentIndex#findKey(StoreKey, FileSpan, EnumSet)}.
ambry-store/src/main/java/com/github/ambry/store/BlobStore.java