本文整理了Java中io.prestosql.spi.predicate.Range.overlaps
方法的一些代码示例,展示了Range.overlaps
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.overlaps
方法的具体详情如下:
包路径:io.prestosql.spi.predicate.Range
类名称:Range
方法名:overlaps
暂无
代码示例来源:origin: prestosql/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: prestosql/presto
SortedRangeSet build()
{
Collections.sort(ranges, Comparator.comparing(Range::getLow));
NavigableMap<Marker, Range> result = new TreeMap<>();
Range current = null;
for (Range next : ranges) {
if (current == null) {
current = next;
continue;
}
if (current.overlaps(next) || current.getHigh().isAdjacent(next.getLow())) {
current = current.span(next);
}
else {
result.put(current.getLow(), current);
current = next;
}
}
if (current != null) {
result.put(current.getLow(), current);
}
return new SortedRangeSet(type, result);
}
}
代码示例来源:origin: io.prestosql/presto-spi
@Test
public void testOverlaps()
{
assertTrue(Range.greaterThan(BIGINT, 1L).overlaps(Range.lessThanOrEqual(BIGINT, 2L)));
assertFalse(Range.greaterThan(BIGINT, 2L).overlaps(Range.lessThan(BIGINT, 2L)));
assertTrue(Range.range(BIGINT, 1L, true, 3L, false).overlaps(Range.equal(BIGINT, 2L)));
assertTrue(Range.range(BIGINT, 1L, true, 3L, false).overlaps(Range.range(BIGINT, 2L, false, 10L, false)));
assertFalse(Range.range(BIGINT, 1L, true, 3L, false).overlaps(Range.range(BIGINT, 3L, true, 10L, false)));
assertTrue(Range.range(BIGINT, 1L, true, 3L, true).overlaps(Range.range(BIGINT, 3L, true, 10L, false)));
assertTrue(Range.all(BIGINT).overlaps(Range.equal(BIGINT, Long.MAX_VALUE)));
}
代码示例来源:origin: prestosql/presto
public Range intersect(Range other)
{
checkTypeCompatibility(other);
if (!this.overlaps(other)) {
throw new IllegalArgumentException("Cannot intersect non-overlapping ranges");
}
Marker lowMarker = Marker.max(low, other.getLow());
Marker highMarker = Marker.min(high, other.getHigh());
return new Range(lowMarker, highMarker);
}
代码示例来源:origin: prestosql/presto
@Test
public void testOverlaps()
{
assertTrue(Range.greaterThan(BIGINT, 1L).overlaps(Range.lessThanOrEqual(BIGINT, 2L)));
assertFalse(Range.greaterThan(BIGINT, 2L).overlaps(Range.lessThan(BIGINT, 2L)));
assertTrue(Range.range(BIGINT, 1L, true, 3L, false).overlaps(Range.equal(BIGINT, 2L)));
assertTrue(Range.range(BIGINT, 1L, true, 3L, false).overlaps(Range.range(BIGINT, 2L, false, 10L, false)));
assertFalse(Range.range(BIGINT, 1L, true, 3L, false).overlaps(Range.range(BIGINT, 3L, true, 10L, false)));
assertTrue(Range.range(BIGINT, 1L, true, 3L, true).overlaps(Range.range(BIGINT, 3L, true, 10L, false)));
assertTrue(Range.all(BIGINT).overlaps(Range.equal(BIGINT, Long.MAX_VALUE)));
}
内容来源于网络,如有侵权,请联系作者删除!