com.facebook.presto.spi.predicate.Marker.compareTo()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中com.facebook.presto.spi.predicate.Marker.compareTo()方法的一些代码示例,展示了Marker.compareTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Marker.compareTo()方法的具体详情如下:
包路径:com.facebook.presto.spi.predicate.Marker
类名称:Marker
方法名:compareTo

Marker.compareTo介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

public static Marker max(Marker marker1, Marker marker2)
{
  return marker1.compareTo(marker2) >= 0 ? marker1 : marker2;
}

代码示例来源:origin: prestodb/presto

public static Marker min(Marker marker1, Marker marker2)
{
  return marker1.compareTo(marker2) <= 0 ? marker1 : marker2;
}

代码示例来源:origin: prestodb/presto

public boolean includes(Marker marker)
{
  requireNonNull(marker, "marker is null");
  checkTypeCompatibility(marker);
  return low.compareTo(marker) <= 0 && high.compareTo(marker) >= 0;
}

代码示例来源:origin: prestodb/presto

public boolean overlaps(Range other)
{
  checkTypeCompatibility(other);
  return this.getLow().compareTo(other.getHigh()) <= 0 &&
      other.getLow().compareTo(this.getHigh()) <= 0;
}

代码示例来源:origin: prestodb/presto

public boolean contains(Range other)
{
  checkTypeCompatibility(other);
  return this.getLow().compareTo(other.getLow()) <= 0 &&
      this.getHigh().compareTo(other.getHigh()) >= 0;
}

代码示例来源:origin: prestodb/presto

@JsonCreator
public Range(
    @JsonProperty("low") Marker low,
    @JsonProperty("high") Marker high)
{
  requireNonNull(low, "value is null");
  requireNonNull(high, "value is null");
  if (!low.getType().equals(high.getType())) {
    throw new IllegalArgumentException(String.format("Marker types do not match: %s vs %s", low.getType(), high.getType()));
  }
  if (low.getBound() == Marker.Bound.BELOW) {
    throw new IllegalArgumentException("low bound must be EXACTLY or ABOVE");
  }
  if (high.getBound() == Marker.Bound.ABOVE) {
    throw new IllegalArgumentException("high bound must be EXACTLY or BELOW");
  }
  if (low.compareTo(high) > 0) {
    throw new IllegalArgumentException("low must be less than or equal to high");
  }
  this.low = low;
  this.high = high;
}

代码示例来源:origin: prestodb/presto

@Override
public SortedRangeSet intersect(ValueSet other)
{
  SortedRangeSet otherRangeSet = checkCompatibility(other);
  Builder builder = new Builder(type);
  Iterator<Range> iterator1 = getOrderedRanges().iterator();
  Iterator<Range> iterator2 = otherRangeSet.getOrderedRanges().iterator();
  if (iterator1.hasNext() && iterator2.hasNext()) {
    Range range1 = iterator1.next();
    Range range2 = iterator2.next();
    while (true) {
      if (range1.overlaps(range2)) {
        builder.add(range1.intersect(range2));
      }
      if (range1.getHigh().compareTo(range2.getHigh()) <= 0) {
        if (!iterator1.hasNext()) {
          break;
        }
        range1 = iterator1.next();
      }
      else {
        if (!iterator2.hasNext()) {
          break;
        }
        range2 = iterator2.next();
      }
    }
  }
  return builder.build();
}

代码示例来源:origin: prestodb/presto

@Test
public void testComparisons()
{
  ImmutableList<Marker> markers = ImmutableList.of(
      Marker.lowerUnbounded(BIGINT),
      Marker.above(BIGINT, 0L),
      Marker.below(BIGINT, 1L),
      Marker.exactly(BIGINT, 1L),
      Marker.above(BIGINT, 1L),
      Marker.below(BIGINT, 2L),
      Marker.upperUnbounded(BIGINT));
  assertTrue(Ordering.natural().isStrictlyOrdered(markers));
  // Compare every marker with every other marker
  // Since the markers are strictly ordered, the value of the comparisons should be equivalent to the comparisons
  // of their indexes.
  for (int i = 0; i < markers.size(); i++) {
    for (int j = 0; j < markers.size(); j++) {
      assertTrue(markers.get(i).compareTo(markers.get(j)) == Integer.compare(i, j));
    }
  }
}

代码示例来源:origin: com.facebook.presto/presto-spi

public static Marker min(Marker marker1, Marker marker2)
{
  return marker1.compareTo(marker2) <= 0 ? marker1 : marker2;
}

代码示例来源:origin: com.facebook.presto/presto-spi

public static Marker max(Marker marker1, Marker marker2)
{
  return marker1.compareTo(marker2) >= 0 ? marker1 : marker2;
}

代码示例来源:origin: com.facebook.presto/presto-spi

public boolean includes(Marker marker)
{
  requireNonNull(marker, "marker is null");
  checkTypeCompatibility(marker);
  return low.compareTo(marker) <= 0 && high.compareTo(marker) >= 0;
}

代码示例来源:origin: com.facebook.presto/presto-spi

public boolean contains(Range other)
{
  checkTypeCompatibility(other);
  return this.getLow().compareTo(other.getLow()) <= 0 &&
      this.getHigh().compareTo(other.getHigh()) >= 0;
}

代码示例来源:origin: com.facebook.presto/presto-spi

public boolean overlaps(Range other)
{
  checkTypeCompatibility(other);
  return this.getLow().compareTo(other.getHigh()) <= 0 &&
      other.getLow().compareTo(this.getHigh()) <= 0;
}

代码示例来源:origin: com.facebook.presto/presto-spi

@JsonCreator
public Range(
    @JsonProperty("low") Marker low,
    @JsonProperty("high") Marker high)
{
  requireNonNull(low, "value is null");
  requireNonNull(high, "value is null");
  if (!low.getType().equals(high.getType())) {
    throw new IllegalArgumentException(String.format("Marker types do not match: %s vs %s", low.getType(), high.getType()));
  }
  if (low.getBound() == Marker.Bound.BELOW) {
    throw new IllegalArgumentException("low bound must be EXACTLY or ABOVE");
  }
  if (high.getBound() == Marker.Bound.ABOVE) {
    throw new IllegalArgumentException("high bound must be EXACTLY or BELOW");
  }
  if (low.compareTo(high) > 0) {
    throw new IllegalArgumentException("low must be less than or equal to high");
  }
  this.low = low;
  this.high = high;
}

代码示例来源:origin: com.facebook.presto/presto-spi

@Override
public SortedRangeSet intersect(ValueSet other)
{
  SortedRangeSet otherRangeSet = checkCompatibility(other);
  Builder builder = new Builder(type);
  Iterator<Range> iterator1 = getOrderedRanges().iterator();
  Iterator<Range> iterator2 = otherRangeSet.getOrderedRanges().iterator();
  if (iterator1.hasNext() && iterator2.hasNext()) {
    Range range1 = iterator1.next();
    Range range2 = iterator2.next();
    while (true) {
      if (range1.overlaps(range2)) {
        builder.add(range1.intersect(range2));
      }
      if (range1.getHigh().compareTo(range2.getHigh()) <= 0) {
        if (!iterator1.hasNext()) {
          break;
        }
        range1 = iterator1.next();
      }
      else {
        if (!iterator2.hasNext()) {
          break;
        }
        range2 = iterator2.next();
      }
    }
  }
  return builder.build();
}

相关文章