io.prestosql.spi.predicate.Range.range()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(207)

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

Range.range介绍

暂无

代码示例

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

public ShardAssertion between(RaptorColumnHandle column, Type type, Object low, Object high)
{
  return range(column, Range.range(type, low, true, high, true));
}

代码示例来源:origin: io.prestosql/presto-spi

@Test
public void testSingleValue()
{
  assertTrue(Range.range(BIGINT, 1L, true, 1L, true).isSingleValue());
  assertFalse(Range.range(BIGINT, 1L, true, 2L, true).isSingleValue());
  assertTrue(Range.range(DOUBLE, 1.1, true, 1.1, true).isSingleValue());
  assertTrue(Range.range(VARCHAR, utf8Slice("a"), true, utf8Slice("a"), true).isSingleValue());
  assertTrue(Range.range(BOOLEAN, true, true, true, true).isSingleValue());
  assertFalse(Range.range(BOOLEAN, false, true, true, true).isSingleValue());
}

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

@Test
public void testSingleValue()
{
  assertTrue(Range.range(BIGINT, 1L, true, 1L, true).isSingleValue());
  assertFalse(Range.range(BIGINT, 1L, true, 2L, true).isSingleValue());
  assertTrue(Range.range(DOUBLE, 1.1, true, 1.1, true).isSingleValue());
  assertTrue(Range.range(VARCHAR, utf8Slice("a"), true, utf8Slice("a"), true).isSingleValue());
  assertTrue(Range.range(BOOLEAN, true, true, true, true).isSingleValue());
  assertFalse(Range.range(BOOLEAN, false, true, true, true).isSingleValue());
}

代码示例来源:origin: io.prestosql/presto-spi

@Test
public void testIntersect()
{
  assertEquals(Range.greaterThan(BIGINT, 1L).intersect(Range.lessThanOrEqual(BIGINT, 2L)), Range.range(BIGINT, 1L, false, 2L, true));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).intersect(Range.equal(BIGINT, 2L)), Range.equal(BIGINT, 2L));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).intersect(Range.range(BIGINT, 2L, false, 10L, false)), Range.range(BIGINT, 2L, false, 3L, false));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, true).intersect(Range.range(BIGINT, 3L, true, 10L, false)), Range.equal(BIGINT, 3L));
  assertEquals(Range.all(BIGINT).intersect(Range.equal(BIGINT, Long.MAX_VALUE)), Range.equal(BIGINT, Long.MAX_VALUE));
}

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

@Test
public void testIntersect()
{
  assertEquals(Range.greaterThan(BIGINT, 1L).intersect(Range.lessThanOrEqual(BIGINT, 2L)), Range.range(BIGINT, 1L, false, 2L, true));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).intersect(Range.equal(BIGINT, 2L)), Range.equal(BIGINT, 2L));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).intersect(Range.range(BIGINT, 2L, false, 10L, false)), Range.range(BIGINT, 2L, false, 3L, false));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, true).intersect(Range.range(BIGINT, 3L, true, 10L, false)), Range.equal(BIGINT, 3L));
  assertEquals(Range.all(BIGINT).intersect(Range.equal(BIGINT, Long.MAX_VALUE)), Range.equal(BIGINT, Long.MAX_VALUE));
}

代码示例来源: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

@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: io.prestosql/presto-orc

private static <F, T extends Comparable<T>> Domain createDomain(Type type, boolean hasNullValue, RangeStatistics<F> rangeStatistics, Function<F, T> function)
{
  F min = rangeStatistics.getMin();
  F max = rangeStatistics.getMax();
  if (min != null && max != null) {
    return Domain.create(ValueSet.ofRanges(Range.range(type, function.apply(min), true, function.apply(max), true)), hasNullValue);
  }
  if (max != null) {
    return Domain.create(ValueSet.ofRanges(Range.lessThanOrEqual(type, function.apply(max))), hasNullValue);
  }
  if (min != null) {
    return Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(type, function.apply(min))), hasNullValue);
  }
  return Domain.create(ValueSet.all(type), hasNullValue);
}

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

private static <F, T extends Comparable<T>> Domain createDomain(Type type, boolean hasNullValue, RangeStatistics<F> rangeStatistics, Function<F, T> function)
{
  F min = rangeStatistics.getMin();
  F max = rangeStatistics.getMax();
  if (min != null && max != null) {
    return Domain.create(ValueSet.ofRanges(Range.range(type, function.apply(min), true, function.apply(max), true)), hasNullValue);
  }
  if (max != null) {
    return Domain.create(ValueSet.ofRanges(Range.lessThanOrEqual(type, function.apply(max))), hasNullValue);
  }
  if (min != null) {
    return Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(type, function.apply(min))), hasNullValue);
  }
  return Domain.create(ValueSet.all(type), hasNullValue);
}

代码示例来源:origin: io.prestosql/presto-spi

@Test
public void testSpan()
{
  assertEquals(Range.greaterThan(BIGINT, 1L).span(Range.lessThanOrEqual(BIGINT, 2L)), Range.all(BIGINT));
  assertEquals(Range.greaterThan(BIGINT, 2L).span(Range.lessThanOrEqual(BIGINT, 0L)), Range.all(BIGINT));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).span(Range.equal(BIGINT, 2L)), Range.range(BIGINT, 1L, true, 3L, false));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).span(Range.range(BIGINT, 2L, false, 10L, false)), Range.range(BIGINT, 1L, true, 10L, false));
  assertEquals(Range.greaterThan(BIGINT, 1L).span(Range.equal(BIGINT, 0L)), Range.greaterThanOrEqual(BIGINT, 0L));
  assertEquals(Range.greaterThan(BIGINT, 1L).span(Range.greaterThanOrEqual(BIGINT, 10L)), Range.greaterThan(BIGINT, 1L));
  assertEquals(Range.lessThan(BIGINT, 1L).span(Range.lessThanOrEqual(BIGINT, 1L)), Range.lessThanOrEqual(BIGINT, 1L));
  assertEquals(Range.all(BIGINT).span(Range.lessThanOrEqual(BIGINT, 1L)), Range.all(BIGINT));
}

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

@Test
public void testSpan()
{
  assertEquals(Range.greaterThan(BIGINT, 1L).span(Range.lessThanOrEqual(BIGINT, 2L)), Range.all(BIGINT));
  assertEquals(Range.greaterThan(BIGINT, 2L).span(Range.lessThanOrEqual(BIGINT, 0L)), Range.all(BIGINT));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).span(Range.equal(BIGINT, 2L)), Range.range(BIGINT, 1L, true, 3L, false));
  assertEquals(Range.range(BIGINT, 1L, true, 3L, false).span(Range.range(BIGINT, 2L, false, 10L, false)), Range.range(BIGINT, 1L, true, 10L, false));
  assertEquals(Range.greaterThan(BIGINT, 1L).span(Range.equal(BIGINT, 0L)), Range.greaterThanOrEqual(BIGINT, 0L));
  assertEquals(Range.greaterThan(BIGINT, 1L).span(Range.greaterThanOrEqual(BIGINT, 10L)), Range.greaterThan(BIGINT, 1L));
  assertEquals(Range.lessThan(BIGINT, 1L).span(Range.lessThanOrEqual(BIGINT, 1L)), Range.lessThanOrEqual(BIGINT, 1L));
  assertEquals(Range.all(BIGINT).span(Range.lessThanOrEqual(BIGINT, 1L)), Range.all(BIGINT));
}

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

@Test
public void testBuildQuery()
{
  TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(
      COL1, Domain.create(ValueSet.ofRanges(range(BIGINT, 100L, false, 200L, true)), false),
      COL2, Domain.singleValue(createUnboundedVarcharType(), utf8Slice("a value"))));
  Document query = MongoSession.buildQuery(tupleDomain);
  Document expected = new Document()
      .append(COL1.getName(), new Document().append("$gt", 100L).append("$lte", 200L))
      .append(COL2.getName(), new Document("$eq", "a value"));
  assertEquals(query, expected);
}

代码示例来源:origin: io.prestosql/presto-thrift-api

@Test
public void testFromValueSetOfRangesBounded()
{
  PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.ofRanges(
      range(BIGINT, -10L, true, -1L, false),
      range(BIGINT, -1L, false, 100L, true)));
  assertNotNull(thriftValueSet.getRangeValueSet());
  assertEquals(thriftValueSet.getRangeValueSet().getRanges(), ImmutableList.of(
      new PrestoThriftRange(new PrestoThriftMarker(longValue(-10), EXACTLY), new PrestoThriftMarker(longValue(-1), BELOW)),
      new PrestoThriftRange(new PrestoThriftMarker(longValue(-1), ABOVE), new PrestoThriftMarker(longValue(100), EXACTLY))));
}

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

@Test
public void testFromValueSetOfRangesBounded()
{
  PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.ofRanges(
      range(BIGINT, -10L, true, -1L, false),
      range(BIGINT, -1L, false, 100L, true)));
  assertNotNull(thriftValueSet.getRangeValueSet());
  assertEquals(thriftValueSet.getRangeValueSet().getRanges(), ImmutableList.of(
      new PrestoThriftRange(new PrestoThriftMarker(longValue(-10), EXACTLY), new PrestoThriftMarker(longValue(-1), BELOW)),
      new PrestoThriftRange(new PrestoThriftMarker(longValue(-1), ABOVE), new PrestoThriftMarker(longValue(100), EXACTLY))));
}

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

@Test
public void testBuildQueryStringType()
{
  TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(
      COL1, Domain.create(ValueSet.ofRanges(range(createUnboundedVarcharType(), utf8Slice("hello"), false, utf8Slice("world"), true)), false),
      COL2, Domain.create(ValueSet.ofRanges(greaterThanOrEqual(createUnboundedVarcharType(), utf8Slice("a value"))), false)));
  Document query = MongoSession.buildQuery(tupleDomain);
  Document expected = new Document()
      .append(COL1.getName(), new Document().append("$gt", "hello").append("$lte", "world"))
      .append(COL2.getName(), new Document("$gte", "a value"));
  assertEquals(query, expected);
}

代码示例来源:origin: io.prestosql/presto-spi

@Test
public void testSpan()
{
  try {
    SortedRangeSet.none(BIGINT).getSpan();
    fail();
  }
  catch (IllegalStateException e) {
  }
  assertEquals(SortedRangeSet.all(BIGINT).getSpan(), Range.all(BIGINT));
  assertEquals(SortedRangeSet.of(BIGINT, 0L).getSpan(), Range.equal(BIGINT, 0L));
  assertEquals(SortedRangeSet.of(Range.equal(BIGINT, 0L), Range.equal(BIGINT, 1L)).getSpan(), Range.range(BIGINT, 0L, true, 1L, true));
  assertEquals(SortedRangeSet.of(Range.equal(BIGINT, 0L), Range.greaterThan(BIGINT, 1L)).getSpan(), Range.greaterThanOrEqual(BIGINT, 0L));
  assertEquals(SortedRangeSet.of(Range.lessThan(BIGINT, 0L), Range.greaterThan(BIGINT, 1L)).getSpan(), Range.all(BIGINT));
}

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

@Test
public void testSpan()
{
  try {
    SortedRangeSet.none(BIGINT).getSpan();
    fail();
  }
  catch (IllegalStateException e) {
  }
  assertEquals(SortedRangeSet.all(BIGINT).getSpan(), Range.all(BIGINT));
  assertEquals(SortedRangeSet.of(BIGINT, 0L).getSpan(), Range.equal(BIGINT, 0L));
  assertEquals(SortedRangeSet.of(Range.equal(BIGINT, 0L), Range.equal(BIGINT, 1L)).getSpan(), Range.range(BIGINT, 0L, true, 1L, true));
  assertEquals(SortedRangeSet.of(Range.equal(BIGINT, 0L), Range.greaterThan(BIGINT, 1L)).getSpan(), Range.greaterThanOrEqual(BIGINT, 0L));
  assertEquals(SortedRangeSet.of(Range.lessThan(BIGINT, 0L), Range.greaterThan(BIGINT, 1L)).getSpan(), Range.all(BIGINT));
}

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

@Test
public void testBigint()
    throws ParquetCorruptionException
{
  String column = "BigintColumn";
  assertEquals(getDomain(BIGINT, 0, null, ID, column, true), all(BIGINT));
  assertEquals(getDomain(BIGINT, 10, longColumnStats(100L, 100L), ID, column, true), singleValue(BIGINT, 100L));
  assertEquals(getDomain(BIGINT, 10, longColumnStats(0L, 100L), ID, column, true), create(ValueSet.ofRanges(range(BIGINT, 0L, true, 100L, true)), false));
  // ignore corrupted statistics
  assertEquals(getDomain(BIGINT, 10, longColumnStats(100L, 0L), ID, column, false), create(ValueSet.all(BIGINT), false));
  // fail on corrupted statistics
  assertThatExceptionOfType(ParquetCorruptionException.class)
      .isThrownBy(() -> getDomain(BIGINT, 10, longColumnStats(100L, 10L), ID, column, true))
      .withMessage("Corrupted statistics for column \"BigintColumn\" in Parquet file \"testFile\": [min: 100, max: 10, num_nulls: 0]");
}

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

@Test
public void testDate()
    throws ParquetCorruptionException
{
  String column = "DateColumn";
  assertEquals(getDomain(DATE, 0, null, ID, column, true), all(DATE));
  assertEquals(getDomain(DATE, 10, intColumnStats(100, 100), ID, column, true), singleValue(DATE, 100L));
  assertEquals(getDomain(DATE, 10, intColumnStats(0, 100), ID, column, true), create(ValueSet.ofRanges(range(DATE, 0L, true, 100L, true)), false));
  // ignore corrupted statistics
  assertEquals(getDomain(DATE, 10, intColumnStats(200, 100), ID, column, false), create(ValueSet.all(DATE), false));
  // fail on corrupted statistics
  assertThatExceptionOfType(ParquetCorruptionException.class)
      .isThrownBy(() -> getDomain(DATE, 10, intColumnStats(200, 100), ID, column, true))
      .withMessage("Corrupted statistics for column \"DateColumn\" in Parquet file \"testFile\": [min: 200, max: 100, num_nulls: 0]");
}

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

@Test
public void testDouble()
    throws ParquetCorruptionException
{
  String column = "DoubleColumn";
  assertEquals(getDomain(DOUBLE, 0, null, ID, column, true), all(DOUBLE));
  assertEquals(getDomain(DOUBLE, 10, doubleColumnStats(42.24, 42.24), ID, column, true), singleValue(DOUBLE, 42.24));
  assertEquals(getDomain(DOUBLE, 10, doubleColumnStats(3.3, 42.24), ID, column, true), create(ValueSet.ofRanges(range(DOUBLE, 3.3, true, 42.24, true)), false));
  // ignore corrupted statistics
  assertEquals(getDomain(DOUBLE, 10, doubleColumnStats(42.24, 3.3), ID, column, false), create(ValueSet.all(DOUBLE), false));
  // fail on corrupted statistics
  assertThatExceptionOfType(ParquetCorruptionException.class)
      .isThrownBy(() -> getDomain(DOUBLE, 10, doubleColumnStats(42.24, 3.3), ID, column, true))
      .withMessage("Corrupted statistics for column \"DoubleColumn\" in Parquet file \"testFile\": [min: 42.24000, max: 3.30000, num_nulls: 0]");
}

相关文章