private IndexCheckResult checkStartIndexValid(final File file, final long startIndex) {
    // get local index from memory map
    long localIndex = getCurrentFileStartIndex(file.getAbsolutePath());
    // get local index from file
    if (localIndex < 0 && file.exists()) {
      localIndex = file.length();
      recordStartIndex(file, localIndex);
    }
    // compare and check
    if (localIndex < 0 && startIndex != 0) {
      LOGGER.error(
          "The start index {} of data sync is not valid. "
              + "The file is not exist and start index should equal to 0).",
          startIndex);
      return new IndexCheckResult(false, "0");
    } else if (localIndex >= 0 && localIndex != startIndex) {
      LOGGER.error(
          "The start index {} of data sync is not valid. "
              + "The start index of the file should equal to {}.",
          startIndex,
          localIndex);
      return new IndexCheckResult(false, String.valueOf(localIndex));
    }
    return new IndexCheckResult(true, "0");
  }
Receive TsFile based on startIndex.

@return {@link TSStatusCode#SUCCESS_STATUS} if receive successfully; {@link
    TSStatusCode#SYNC_FILE_REDIRECTION_ERROR} if startIndex needs to rollback because
    mismatched; {@link TSStatusCode#SYNC_FILE_ERROR} if fail to receive file.
@throws TException The connection between the sender and the receiver has not been established
    by {@link IoTDBLegacyPipeReceiverAgent#handshake}
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java