public boolean overlaps()

in java/tsfile/src/main/java/org/apache/tsfile/read/common/TimeRange.java [222:242]


  public boolean overlaps(TimeRange rhs) {
    if ((!this.leftClose || !rhs.rightClose) && (rhs.max <= this.min)) {
      // e.g., rhs:[1,3] does not overlap with this:(3,5].
      return false;
    } else if (!this.leftClose && !rhs.rightClose && rhs.max <= this.min + 1) {
      // e.g., rhs:[1,4) does not overlap with this:(3,5]
      return false;
    } else if (this.leftClose && rhs.rightClose && rhs.max < this.min) {
      // e.g., rhs:[1,4] does not overlap with this:[5,6]
      return false;
    } else if ((!this.rightClose || !rhs.leftClose) && (rhs.min >= this.max)) {
      // e.g., this:[1,5) does not overlap with rhs:[5,6]
      return false;
    } else if (!this.rightClose && !rhs.leftClose && rhs.min + 1 >= this.max) {
      // e.g., this:[1,5) does not overlap with rhs:(4,6]
      return false;
    } else {
      // e.g., this:[1,5] does not overlap with rhs:[6,8]
      return !this.rightClose || !rhs.leftClose || rhs.min <= this.max;
    }
  }