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

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

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

Range.lessThan介绍

暂无

代码示例

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

@Test
public void testBuildQueryOr()
{
  TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(
      COL1, Domain.create(ValueSet.ofRanges(lessThan(BIGINT, 100L), greaterThan(BIGINT, 200L)), false)));
  Document query = MongoSession.buildQuery(tupleDomain);
  Document expected = new Document("$or", asList(
      new Document(COL1.getName(), new Document("$lt", 100L)),
      new Document(COL1.getName(), new Document("$gt", 200L))));
  assertEquals(query, expected);
}

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

@Test
public void testJsonSerialization()
    throws Exception
  assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
  range = Range.lessThan(BIGINT, Long.MAX_VALUE);
  assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));

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

@Test
public void testGetSingleValue()
{
  assertEquals(Range.equal(BIGINT, 0L).getSingleValue(), 0L);
  try {
    Range.lessThan(BIGINT, 0L).getSingleValue();
    fail();
  }
  catch (IllegalStateException e) {
  }
}

代码示例来源:origin: prestodb/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: prestodb/presto

@Test
public void testExceptionalIntersect()
{
  try {
    Range.greaterThan(BIGINT, 2L).intersect(Range.lessThan(BIGINT, 2L));
    fail();
  }
  catch (IllegalArgumentException e) {
  }
  try {
    Range.range(BIGINT, 1L, true, 3L, false).intersect(Range.range(BIGINT, 3L, true, 10L, false));
    fail();
  }
  catch (IllegalArgumentException e) {
  }
}

代码示例来源:origin: prestodb/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: prestodb/presto

@Test
public void testJsonSerialization()
    throws Exception
{
  TestingTypeManager typeManager = new TestingTypeManager();
  TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde(typeManager);
  ObjectMapper mapper = new ObjectMapperProvider().get()
      .registerModule(new SimpleModule()
          .addDeserializer(Type.class, new TestingTypeDeserializer(typeManager))
          .addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde))
          .addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
  Domain domain = Domain.all(BIGINT);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.none(DOUBLE);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.notNull(BOOLEAN);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.notNull(HYPER_LOG_LOG);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.onlyNull(VARCHAR);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.onlyNull(HYPER_LOG_LOG);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.singleValue(BIGINT, Long.MIN_VALUE);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.singleValue(ID, Long.MIN_VALUE);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
  domain = Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 0L), Range.equal(BIGINT, 1L), Range.range(BIGINT, 2L, true, 3L, true)), true);
  assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
}

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

@Test
public void testToPredicate()
  assertEquals(toPredicate(tupleDomain), greaterThanOrEqual(C_BIGINT, bigintLiteral(1L)));
  tupleDomain = withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L)), false)));
  assertEquals(toPredicate(tupleDomain), lessThan(C_BIGINT, bigintLiteral(1L)));
  assertEquals(toPredicate(tupleDomain), in(C_BIGINT, ImmutableList.of(1L, 2L)));
  tupleDomain = withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L)), true)));
  assertEquals(toPredicate(tupleDomain), or(lessThan(C_BIGINT, bigintLiteral(1L)), isNull(C_BIGINT)));

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

@Test
public void testLessThanRange()
{
  Range range = Range.lessThan(BIGINT, 1L);
  assertEquals(range.getLow(), Marker.lowerUnbounded(BIGINT));
  assertEquals(range.getHigh(), Marker.below(BIGINT, 1L));
  assertFalse(range.isSingleValue());
  assertFalse(range.isAll());
  assertEquals(range.getType(), BIGINT);
  assertTrue(range.includes(Marker.lowerUnbounded(BIGINT)));
  assertFalse(range.includes(Marker.exactly(BIGINT, 1L)));
  assertTrue(range.includes(Marker.exactly(BIGINT, 0L)));
  assertFalse(range.includes(Marker.upperUnbounded(BIGINT)));
}

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

@Test
public void testTupleDomain()
      ImmutableMap.of(textColumn, Domain.create(ValueSet.ofRanges(Range.lessThan(VARCHAR, utf8Slice("foo"))), false))));

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

@Test
public void testColumnWiseUnion()
{
  TupleDomain<ColumnHandle> tupleDomain1 = TupleDomain.withColumnDomains(
      ImmutableMap.<ColumnHandle, Domain>builder()
          .put(A, Domain.all(VARCHAR))
          .put(B, Domain.notNull(DOUBLE))
          .put(C, Domain.onlyNull(BIGINT))
          .put(D, Domain.singleValue(BIGINT, 1L))
          .put(E, Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(DOUBLE, 0.0)), true))
          .build());
  TupleDomain<ColumnHandle> tupleDomain2 = TupleDomain.withColumnDomains(
      ImmutableMap.<ColumnHandle, Domain>builder()
          .put(A, Domain.singleValue(VARCHAR, utf8Slice("value")))
          .put(B, Domain.singleValue(DOUBLE, 0.0))
          .put(C, Domain.notNull(BIGINT))
          .put(D, Domain.singleValue(BIGINT, 1L))
          .put(E, Domain.create(ValueSet.ofRanges(Range.lessThan(DOUBLE, 10.0)), false))
          .build());
  TupleDomain<ColumnHandle> expectedTupleDomain = TupleDomain.withColumnDomains(
      ImmutableMap.<ColumnHandle, Domain>builder()
          .put(A, Domain.all(VARCHAR))
          .put(B, Domain.notNull(DOUBLE))
          .put(C, Domain.all(BIGINT))
          .put(D, Domain.singleValue(BIGINT, 1L))
          .put(E, Domain.all(DOUBLE))
          .build());
  assertEquals(columnWiseUnion(tupleDomain1, tupleDomain2), expectedTupleDomain);
}

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

@Test
public void testFromFlippedBasicComparisons()
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), true))));

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

@Test
public void testIntersection()
{
  TupleDomain<ColumnHandle> tupleDomain1 = TupleDomain.withColumnDomains(
      ImmutableMap.<ColumnHandle, Domain>builder()
          .put(A, Domain.all(VARCHAR))
          .put(B, Domain.notNull(DOUBLE))
          .put(C, Domain.singleValue(BIGINT, 1L))
          .put(D, Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(DOUBLE, 0.0)), true))
          .build());
  TupleDomain<ColumnHandle> tupleDomain2 = TupleDomain.withColumnDomains(
      ImmutableMap.<ColumnHandle, Domain>builder()
          .put(A, Domain.singleValue(VARCHAR, utf8Slice("value")))
          .put(B, Domain.singleValue(DOUBLE, 0.0))
          .put(C, Domain.singleValue(BIGINT, 1L))
          .put(D, Domain.create(ValueSet.ofRanges(Range.lessThan(DOUBLE, 10.0)), false))
          .build());
  TupleDomain<ColumnHandle> expectedTupleDomain = TupleDomain.withColumnDomains(
      ImmutableMap.<ColumnHandle, Domain>builder()
          .put(A, Domain.singleValue(VARCHAR, utf8Slice("value")))
          .put(B, Domain.singleValue(DOUBLE, 0.0))
          .put(C, Domain.singleValue(BIGINT, 1L))
          .put(D, Domain.create(ValueSet.ofRanges(Range.range(DOUBLE, 0.0, true, 10.0, false)), false))
          .build());
  assertEquals(tupleDomain1.intersect(tupleDomain2), expectedTupleDomain);
}

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

@Test
public void testFromBasicComparisons()
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), true))));
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), false))));

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

@Test
public void testSingleValue()
{
  SortedRangeSet rangeSet = SortedRangeSet.of(BIGINT, 10L);
  SortedRangeSet complement = SortedRangeSet.of(Range.greaterThan(BIGINT, 10L), Range.lessThan(BIGINT, 10L));
  assertEquals(rangeSet.getType(), BIGINT);
  assertFalse(rangeSet.isNone());
  assertFalse(rangeSet.isAll());
  assertTrue(rangeSet.isSingleValue());
  assertTrue(Iterables.elementsEqual(rangeSet.getOrderedRanges(), ImmutableList.of(Range.equal(BIGINT, 10L))));
  assertEquals(rangeSet.getRangeCount(), 1);
  assertEquals(rangeSet.complement(), complement);
  assertFalse(rangeSet.includesMarker(Marker.lowerUnbounded(BIGINT)));
  assertTrue(rangeSet.includesMarker(Marker.exactly(BIGINT, 10L)));
  assertFalse(rangeSet.includesMarker(Marker.exactly(BIGINT, 9L)));
  assertFalse(rangeSet.includesMarker(Marker.upperUnbounded(BIGINT)));
}

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

@Test
public void testFromComparisonsWithCoercions()
      withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.lessThan(INTEGER, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.lessThan(INTEGER, 2L), Range.greaterThan(INTEGER, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.lessThan(INTEGER, 2L), Range.greaterThan(INTEGER, 2L)), true))));
      withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.lessThan(INTEGER, 2L)), false))));
      withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.lessThan(INTEGER, 2L), Range.greaterThan(INTEGER, 2L)), false))));

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

@Test
  public void testNotPushDoublePredicates()
  {
    IonSqlQueryBuilder queryBuilder = new IonSqlQueryBuilder(new TypeRegistry());
    List<HiveColumnHandle> columns = ImmutableList.of(
        new HiveColumnHandle("quantity", HIVE_INT, parseTypeSignature(INTEGER), 0, REGULAR, Optional.empty()),
        new HiveColumnHandle("extendedprice", HIVE_DOUBLE, parseTypeSignature(StandardTypes.DOUBLE), 1, REGULAR, Optional.empty()),
        new HiveColumnHandle("discount", HIVE_DOUBLE, parseTypeSignature(StandardTypes.DOUBLE), 2, REGULAR, Optional.empty()));
    TupleDomain<HiveColumnHandle> tupleDomain = withColumnDomains(
        ImmutableMap.of(
            columns.get(0), Domain.create(ofRanges(Range.lessThan(BIGINT, 50L)), false),
            columns.get(1), Domain.create(ofRanges(Range.equal(DOUBLE, 0.05)), false),
            columns.get(2), Domain.create(ofRanges(Range.range(DOUBLE, 0.0, true, 0.02, true)), false)));
    assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s WHERE ((case s._1 when '' then null else CAST(s._1 AS INT) end < 50))",
        queryBuilder.buildSql(columns, tupleDomain));
  }
}

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

@Test
public void testLegacyCharComparedToVarcharExpression()
  testSimpleComparison(lessThan(cast(C_CHAR, VARCHAR), stringLiteral("1234567890", VARCHAR)), C_CHAR, Range.lessThan(createCharType(10), Slices.utf8Slice("1234567890")));
  testSimpleComparison(lessThan(cast(C_CHAR, VARCHAR), stringLiteral("12345678901", VARCHAR)), C_CHAR, Range.lessThanOrEqual(createCharType(10), Slices.utf8Slice("1234567890")));
      Range.lessThan(createCharType(10), Slices.utf8Slice("1234567890")), Range.greaterThan(createCharType(10), Slices.utf8Slice("1234567890"))), false));
  testSimpleComparison(notEqual(cast(C_CHAR, VARCHAR), stringLiteral("12345678901", VARCHAR)), C_CHAR, Domain.notNull(createCharType(10)));
      Range.lessThan(createCharType(10), Slices.utf8Slice("1234567890")), Range.greaterThan(createCharType(10), Slices.utf8Slice("1234567890"))), true));
  testSimpleComparison(isDistinctFrom(cast(C_CHAR, VARCHAR), stringLiteral("12345678901", VARCHAR)), C_CHAR, Domain.all(createCharType(10)));

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

@Test
public void testOrderableSingleValue()
{
  Domain domain = Domain.singleValue(BIGINT, 0L);
  assertFalse(domain.isNone());
  assertFalse(domain.isAll());
  assertTrue(domain.isSingleValue());
  assertTrue(domain.isNullableSingleValue());
  assertFalse(domain.isOnlyNull());
  assertFalse(domain.isNullAllowed());
  assertEquals(domain.getValues(), ValueSet.ofRanges(Range.equal(BIGINT, 0L)));
  assertEquals(domain.getType(), BIGINT);
  assertFalse(domain.includesNullableValue(Long.MIN_VALUE));
  assertTrue(domain.includesNullableValue(0L));
  assertFalse(domain.includesNullableValue(Long.MAX_VALUE));
  assertEquals(domain.complement(), Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 0L), Range.greaterThan(BIGINT, 0L)), true));
  assertEquals(domain.getSingleValue(), 0L);
  assertEquals(domain.getNullableSingleValue(), 0L);
  try {
    Domain.create(ValueSet.ofRanges(Range.range(BIGINT, 1L, true, 2L, true)), false).getSingleValue();
    fail();
  }
  catch (IllegalStateException e) {
  }
}

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

@Test
public void testUnion()
{
  assertUnion(SortedRangeSet.none(BIGINT), SortedRangeSet.none(BIGINT), SortedRangeSet.none(BIGINT));
  assertUnion(SortedRangeSet.all(BIGINT), SortedRangeSet.all(BIGINT), SortedRangeSet.all(BIGINT));
  assertUnion(SortedRangeSet.none(BIGINT), SortedRangeSet.all(BIGINT), SortedRangeSet.all(BIGINT));
  assertUnion(
      SortedRangeSet.of(Range.equal(BIGINT, 1L), Range.equal(BIGINT, 2L)),
      SortedRangeSet.of(Range.equal(BIGINT, 2L), Range.equal(BIGINT, 3L)),
      SortedRangeSet.of(Range.equal(BIGINT, 1L), Range.equal(BIGINT, 2L), Range.equal(BIGINT, 3L)));
  assertUnion(SortedRangeSet.all(BIGINT), SortedRangeSet.of(Range.equal(BIGINT, 0L)), SortedRangeSet.all(BIGINT));
  assertUnion(
      SortedRangeSet.of(Range.range(BIGINT, 0L, true, 4L, false)),
      SortedRangeSet.of(Range.greaterThan(BIGINT, 3L)),
      SortedRangeSet.of(Range.greaterThanOrEqual(BIGINT, 0L)));
  assertUnion(
      SortedRangeSet.of(Range.greaterThanOrEqual(BIGINT, 0L)),
      SortedRangeSet.of(Range.lessThanOrEqual(BIGINT, 0L)),
      SortedRangeSet.of(Range.all(BIGINT)));
  assertUnion(
      SortedRangeSet.of(Range.greaterThan(BIGINT, 0L)),
      SortedRangeSet.of(Range.lessThan(BIGINT, 0L)),
      SortedRangeSet.of(BIGINT, 0L).complement());
}

相关文章