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

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

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

Range.isSingleValue介绍

暂无

代码示例

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

@Override
public boolean isSingleValue()
{
  return lowIndexedRanges.size() == 1 && lowIndexedRanges.values().iterator().next().isSingleValue();
}

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

public Object getSingleValue()
{
  if (!isSingleValue()) {
    throw new IllegalStateException("Range does not have just a single value");
  }
  return low.getValue();
}

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

@VisibleForTesting
public static Optional<Collection<Object>> extractDiscreteValues(ValueSet valueSet)
{
  return valueSet.getValuesProcessor().transform(
      ranges -> {
        ImmutableList.Builder<Object> discreteValues = ImmutableList.builder();
        for (Range range : ranges.getOrderedRanges()) {
          if (!range.isSingleValue()) {
            return Optional.empty();
          }
          discreteValues.add(range.getSingleValue());
        }
        return Optional.of(discreteValues.build());
      },
      discreteValues -> Optional.of(discreteValues.getValues()),
      allOrNone -> allOrNone.isAll() ? Optional.empty() : Optional.of(ImmutableList.of()));
}

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

public String toString(ConnectorSession session)
  {
    StringBuilder buffer = new StringBuilder();
    if (isSingleValue()) {
      buffer.append('[').append(low.getPrintableValue(session)).append(']');
    }
    else {
      buffer.append((low.getBound() == Marker.Bound.EXACTLY) ? '[' : '(');
      buffer.append(low.isLowerUnbounded() ? "<min>" : low.getPrintableValue(session));
      buffer.append(", ");
      buffer.append(high.isUpperUnbounded() ? "<max>" : high.getPrintableValue(session));
      buffer.append((high.getBound() == Marker.Bound.EXACTLY) ? ']' : ')');
    }
    return buffer.toString();
  }
}

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

@Test
public void testGreaterThanRange()
{
  Range range = Range.greaterThan(BIGINT, 1L);
  assertEquals(range.getLow(), Marker.above(BIGINT, 1L));
  assertEquals(range.getHigh(), Marker.upperUnbounded(BIGINT));
  assertFalse(range.isSingleValue());
  assertFalse(range.isAll());
  assertEquals(range.getType(), BIGINT);
  assertFalse(range.includes(Marker.lowerUnbounded(BIGINT)));
  assertFalse(range.includes(Marker.exactly(BIGINT, 1L)));
  assertTrue(range.includes(Marker.exactly(BIGINT, 2L)));
  assertTrue(range.includes(Marker.upperUnbounded(BIGINT)));
}

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

@Test
public void testGreaterThanRange()
{
  Range range = Range.greaterThan(BIGINT, 1L);
  assertEquals(range.getLow(), Marker.above(BIGINT, 1L));
  assertEquals(range.getHigh(), Marker.upperUnbounded(BIGINT));
  assertFalse(range.isSingleValue());
  assertFalse(range.isAll());
  assertEquals(range.getType(), BIGINT);
  assertFalse(range.includes(Marker.lowerUnbounded(BIGINT)));
  assertFalse(range.includes(Marker.exactly(BIGINT, 1L)));
  assertTrue(range.includes(Marker.exactly(BIGINT, 2L)));
  assertTrue(range.includes(Marker.upperUnbounded(BIGINT)));
}

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

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

代码示例来源:origin: prestosql/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: io.prestosql/presto-spi

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@Test
public void testRange()
{
  Range range = Range.range(BIGINT, 0L, false, 2L, true);
  assertEquals(range.getLow(), Marker.above(BIGINT, 0L));
  assertEquals(range.getHigh(), Marker.exactly(BIGINT, 2L));
  assertFalse(range.isSingleValue());
  assertFalse(range.isAll());
  assertEquals(range.getType(), BIGINT);
  assertFalse(range.includes(Marker.lowerUnbounded(BIGINT)));
  assertFalse(range.includes(Marker.exactly(BIGINT, 0L)));
  assertTrue(range.includes(Marker.exactly(BIGINT, 1L)));
  assertTrue(range.includes(Marker.exactly(BIGINT, 2L)));
  assertFalse(range.includes(Marker.exactly(BIGINT, 3L)));
  assertFalse(range.includes(Marker.upperUnbounded(BIGINT)));
}

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

@Test
public void testRange()
{
  Range range = Range.range(BIGINT, 0L, false, 2L, true);
  assertEquals(range.getLow(), Marker.above(BIGINT, 0L));
  assertEquals(range.getHigh(), Marker.exactly(BIGINT, 2L));
  assertFalse(range.isSingleValue());
  assertFalse(range.isAll());
  assertEquals(range.getType(), BIGINT);
  assertFalse(range.includes(Marker.lowerUnbounded(BIGINT)));
  assertFalse(range.includes(Marker.exactly(BIGINT, 0L)));
  assertTrue(range.includes(Marker.exactly(BIGINT, 1L)));
  assertTrue(range.includes(Marker.exactly(BIGINT, 2L)));
  assertFalse(range.includes(Marker.exactly(BIGINT, 3L)));
  assertFalse(range.includes(Marker.upperUnbounded(BIGINT)));
}

相关文章