private boolean tryFilter(final long timestamp, final T value) {
    final long timeDiff = timestamp - lastStoredTimestamp;
    final long absTimeDiff = Math.abs(timeDiff);

    if (absTimeDiff <= processor.getCompressionMinTimeInterval()) {
      return false;
    }

    if (absTimeDiff >= processor.getCompressionMaxTimeInterval()) {
      reset(timestamp, value);
      return true;
    }

    // For boolean and string type, we only compare the value
    if (value instanceof Boolean
        || value instanceof String
        || value instanceof Binary
        || value instanceof LocalDate) {
      if (Objects.equals(lastStoredValue, value)) {
        return false;
      }

      reset(timestamp, value);
      return true;
    }

    // For other numerical types, we compare the value and the time difference
    final double doubleValue = Double.parseDouble(value.toString());
    final double lastStoredDoubleValue = Double.parseDouble(lastStoredValue.toString());
    final double valueDiff = doubleValue - lastStoredDoubleValue;

    final double currentUpperSlope = (valueDiff - processor.getCompressionDeviation()) / timeDiff;
    if (currentUpperSlope > upperDoor) {
      upperDoor = currentUpperSlope;
    }

    final double currentLowerSlope = (valueDiff + processor.getCompressionDeviation()) / timeDiff;
    if (currentLowerSlope < lowerDoor) {
      lowerDoor = currentLowerSlope;
    }

    if (upperDoor > lowerDoor) {
      lastStoredTimestamp = lastReadTimestamp;
      lastStoredValue = lastReadValue;

      upperDoor = currentUpperSlope;
      lowerDoor = currentLowerSlope;

      lastReadValue = value;
      lastReadTimestamp = timestamp;

      return true;
    }

    lastReadValue = value;
    lastReadTimestamp = timestamp;

    return false;
  }
The last stored time and value we compare current point against lastReadTimestamp and
lastReadValue
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/processor/downsampling/sdt/SwingingDoorTrendingFilter.java