protected int checkTTLInternal(TSStatus[] results, long ttl, boolean breakOnFirstAlive)
      throws OutOfTTLException {

    /*
     * assume that batch has been sorted by client
     */
    int loc = 0;
    int firstAliveLoc = -1;
    while (loc < getRowCount()) {
      long currTime = getTimes()[loc];
      // skip points that do not satisfy TTL
      if (!isAlive(currTime, ttl)) {
        results[loc] =
            RpcUtils.getStatus(
                TSStatusCode.OUT_OF_TTL,
                String.format(
                    "Insertion time [%s] is less than ttl time bound [%s]",
                    DateTimeUtils.convertLongToDate(currTime),
                    DateTimeUtils.convertLongToDate(CommonDateTimeUtils.currentTime() - ttl)));
      } else {
        if (firstAliveLoc == -1) {
          firstAliveLoc = loc;
        }
        if (breakOnFirstAlive) {
          break;
        }
      }
      loc++;
    }

    if (firstAliveLoc == -1) {
      // no alive data
      throw new OutOfTTLException(
          getTimes()[getTimes().length - 1], (CommonDateTimeUtils.currentTime() - ttl));
    }
    return firstAliveLoc;
  }
@param results insertion result of each row
@param ttl the ttl
@return the position of the first alive row
@throws OutOfTTLException if all rows have expired the TTL
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertTabletNode.java