本文整理了Java中com.facebook.presto.spi.predicate.Marker
类的一些代码示例,展示了Marker
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Marker
类的具体详情如下:
包路径:com.facebook.presto.spi.predicate.Marker
类名称:Marker
[英]A point on the continuous space defined by the specified type. Each point may be just below, exact, or just above the specified value according to the Bound.
[中]由指定类型定义的连续空间上的点。根据界限,每个点可能刚好低于、精确或刚好高于指定值。
代码示例来源:origin: prestodb/presto
/**
* Adjacency is defined by two Markers being infinitesimally close to each other.
* This means they must share the same value and have adjacent Bounds.
*/
public boolean isAdjacent(Marker other)
{
checkTypeCompatibility(other);
if (isUpperUnbounded() || isLowerUnbounded() || other.isUpperUnbounded() || other.isLowerUnbounded()) {
return false;
}
if (type.compareTo(valueBlock.get(), 0, other.valueBlock.get(), 0) != 0) {
return false;
}
return (bound == Bound.EXACTLY && other.bound != Bound.EXACTLY) ||
(bound != Bound.EXACTLY && other.bound == Bound.EXACTLY);
}
代码示例来源:origin: prestodb/presto
private FormattedMarker formatMarker(Marker marker)
{
if (!marker.getValueBlock().isPresent()) {
return new FormattedMarker(Optional.empty(), marker.getBound());
}
return new FormattedMarker(Optional.of(getVarcharValue(marker.getType(), marker.getValue())), marker.getBound());
}
代码示例来源:origin: prestodb/presto
public boolean isAll()
{
return low.isLowerUnbounded() && high.isUpperUnbounded();
}
代码示例来源:origin: prestodb/presto
public boolean isSingleValue()
{
return low.getBound() == Marker.Bound.EXACTLY && low.equals(high);
}
代码示例来源:origin: prestodb/presto
private static boolean isBetween(Range range)
{
return !range.getLow().isLowerUnbounded() && range.getLow().getBound() == Marker.Bound.EXACTLY
&& !range.getHigh().isUpperUnbounded() && range.getHigh().getBound() == Marker.Bound.EXACTLY;
}
代码示例来源:origin: prestodb/presto
public static PrestoThriftMarker fromMarker(Marker marker)
{
PrestoThriftBlock value = marker.getValueBlock().isPresent() ? fromBlock(marker.getValueBlock().get(), marker.getType()) : null;
return new PrestoThriftMarker(value, fromBound(marker.getBound()));
}
}
代码示例来源:origin: xiaoyao1991/presto-ethereum
if (domains.isPresent()) {
Map<ColumnHandle, Domain> columnHandleDomainMap = domains.get();
for (Map.Entry<ColumnHandle, Domain> entry : columnHandleDomainMap.entrySet()) {
if (entry.getKey() instanceof EthereumColumnHandle
|| ((EthereumColumnHandle) entry.getKey()).getName().equals("erc20_blockNumber"))) {
entry.getValue().getValues().getRanges().getOrderedRanges().forEach(r -> {
Marker low = r.getLow();
Marker high = r.getHigh();
builder.add(EthereumBlockRange.fromMarkers(low, high));
});
entry.getValue().getValues().getRanges().getOrderedRanges().stream()
.filter(Range::isSingleValue).forEach(r -> {
String blockHash = ((Slice) r.getSingleValue()).toStringUtf8();
try {
long blockNumber = web3j.ethGetBlockByHash(blockHash, true).send().getBlock().getNumber().longValue();
Marker high = r.getHigh();
try {
long startBlock = low.isLowerUnbounded() ? 1L : findBlockByTimestamp((Long) low.getValue(), -1L);
long endBlock = high.isUpperUnbounded() ? -1L : findBlockByTimestamp((Long) high.getValue(), 1L);
builder.add(new EthereumBlockRange(startBlock, endBlock));
代码示例来源:origin: prestodb/presto
for (TupleDomain.ColumnDomain<ColumnHandle> columnDomain : constraintSummary.getColumnDomains().get()) {
int position = ((KuduColumnHandle) columnDomain.getColumn()).getOrdinalPosition();
ColumnSchema columnSchema = schema.getColumnByIndex(position);
Ranges ranges = ((SortedRangeSet) valueSet).getRanges();
Range span = ranges.getSpan();
Marker low = span.getLow();
if (!low.isLowerUnbounded()) {
KuduPredicate.ComparisonOp op = (low.getBound() == Marker.Bound.ABOVE)
? KuduPredicate.ComparisonOp.GREATER : KuduPredicate.ComparisonOp.GREATER_EQUAL;
KuduPredicate predicate = createComparisonPredicate(columnSchema, op, low.getValue());
builder.addPredicate(predicate);
Marker high = span.getHigh();
if (!high.isUpperUnbounded()) {
KuduPredicate.ComparisonOp op = (low.getBound() == Marker.Bound.BELOW)
? KuduPredicate.ComparisonOp.LESS : KuduPredicate.ComparisonOp.LESS_EQUAL;
KuduPredicate predicate = createComparisonPredicate(columnSchema, op, high.getValue());
builder.addPredicate(predicate);
代码示例来源:origin: prestodb/presto
private static OptionalInt extractUpperBound(TupleDomain<Symbol> tupleDomain, Symbol symbol)
{
if (tupleDomain.isNone()) {
return OptionalInt.empty();
}
Domain rowNumberDomain = tupleDomain.getDomains().get().get(symbol);
if (rowNumberDomain == null) {
return OptionalInt.empty();
}
ValueSet values = rowNumberDomain.getValues();
if (values.isAll() || values.isNone() || values.getRanges().getRangeCount() <= 0) {
return OptionalInt.empty();
}
Range span = values.getRanges().getSpan();
if (span.getHigh().isUpperUnbounded()) {
return OptionalInt.empty();
}
verify(rowNumberDomain.getType().equals(BIGINT));
long upperBound = (Long) span.getHigh().getValue();
if (span.getHigh().getBound() == BELOW) {
upperBound--;
}
if (upperBound > 0 && upperBound <= Integer.MAX_VALUE) {
return OptionalInt.of(toIntExact(upperBound));
}
return OptionalInt.empty();
}
代码示例来源:origin: prestodb/presto
@Test
public void testUnbounded()
{
assertTrue(Marker.lowerUnbounded(BIGINT).isLowerUnbounded());
assertFalse(Marker.lowerUnbounded(BIGINT).isUpperUnbounded());
assertTrue(Marker.upperUnbounded(BIGINT).isUpperUnbounded());
assertFalse(Marker.upperUnbounded(BIGINT).isLowerUnbounded());
assertFalse(Marker.below(BIGINT, 1L).isLowerUnbounded());
assertFalse(Marker.below(BIGINT, 1L).isUpperUnbounded());
assertFalse(Marker.exactly(BIGINT, 1L).isLowerUnbounded());
assertFalse(Marker.exactly(BIGINT, 1L).isUpperUnbounded());
assertFalse(Marker.above(BIGINT, 1L).isLowerUnbounded());
assertFalse(Marker.above(BIGINT, 1L).isUpperUnbounded());
}
代码示例来源:origin: prestodb/presto
@Test
public void testTypes()
{
assertEquals(Marker.lowerUnbounded(BIGINT).getType(), BIGINT);
assertEquals(Marker.below(BIGINT, 1L).getType(), BIGINT);
assertEquals(Marker.exactly(BIGINT, 1L).getType(), BIGINT);
assertEquals(Marker.above(BIGINT, 1L).getType(), BIGINT);
assertEquals(Marker.upperUnbounded(BIGINT).getType(), BIGINT);
}
代码示例来源:origin: prestodb/presto
if (prestoRange.isAll()) {
accumuloRange = new Range();
else if (prestoRange.isSingleValue()) {
Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getSingleValue()));
accumuloRange = new Range(split);
if (prestoRange.getLow().isLowerUnbounded()) {
boolean inclusive = prestoRange.getHigh().getBound() == Bound.EXACTLY;
Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue()));
accumuloRange = new Range(null, false, split, inclusive);
else if (prestoRange.getHigh().isUpperUnbounded()) {
boolean inclusive = prestoRange.getLow().getBound() == Bound.EXACTLY;
Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue()));
accumuloRange = new Range(split, inclusive, null, false);
boolean startKeyInclusive = prestoRange.getLow().getBound() == Bound.EXACTLY;
Text startSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue()));
boolean endKeyInclusive = prestoRange.getHigh().getBound() == Bound.EXACTLY;
Text endSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue()));
accumuloRange = new Range(startSplit, startKeyInclusive, endSplit, endKeyInclusive);
代码示例来源:origin: prestodb/presto
@Override
public SortedRangeSet complement()
{
Builder builder = new Builder(type);
if (lowIndexedRanges.isEmpty()) {
return builder.add(Range.all(type)).build();
}
Iterator<Range> rangeIterator = lowIndexedRanges.values().iterator();
Range firstRange = rangeIterator.next();
if (!firstRange.getLow().isLowerUnbounded()) {
builder.add(new Range(Marker.lowerUnbounded(type), firstRange.getLow().lesserAdjacent()));
}
Range previousRange = firstRange;
while (rangeIterator.hasNext()) {
Range currentRange = rangeIterator.next();
Marker lowMarker = previousRange.getHigh().greaterAdjacent();
Marker highMarker = currentRange.getLow().lesserAdjacent();
builder.add(new Range(lowMarker, highMarker));
previousRange = currentRange;
}
Range lastRange = previousRange;
if (!lastRange.getHigh().isUpperUnbounded()) {
builder.add(new Range(lastRange.getHigh().greaterAdjacent(), Marker.upperUnbounded(type)));
}
return builder.build();
}
代码示例来源:origin: prestodb/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: xiaoyao1991/presto-ethereum
public static EthereumBlockRange fromMarkers(Marker low, Marker high) {
long startBlock;
long endBlock;
if (low.isLowerUnbounded()) {
startBlock = 1L;
} else if (low.getBound() == Marker.Bound.EXACTLY) {
startBlock = (long) low.getValue();
} else if (low.getBound() == Marker.Bound.ABOVE) {
startBlock = (long) low.getValue() + 1L;
} else {
throw new IllegalArgumentException("Low bound cannot be BELOW");
}
if (high.isUpperUnbounded()) {
endBlock = -1L;
} else if (high.getBound() == Marker.Bound.EXACTLY) {
endBlock = (long) high.getValue();
} else if (high.getBound() == Marker.Bound.BELOW) {
endBlock = (long) high.getValue() - 1L;
} else {
throw new IllegalArgumentException("High bound cannot be ABOVE");
}
if (startBlock > endBlock && endBlock != -1L) {
throw new IllegalArgumentException("Low bound is greater than high bound");
}
return new EthereumBlockRange(startBlock, endBlock);
}
代码示例来源:origin: prestodb/presto
public String toString(ConnectorSession session)
{
StringBuilder buffer = new StringBuilder("{");
buffer.append("type=").append(type);
buffer.append(", value=");
if (isLowerUnbounded()) {
buffer.append("<min>");
}
else if (isUpperUnbounded()) {
buffer.append("<max>");
}
else {
buffer.append(getPrintableValue(session));
}
buffer.append(", bound=").append(bound);
buffer.append("}");
return buffer.toString();
}
}
代码示例来源:origin: prestodb/presto
public Object getSingleValue()
{
if (!isSingleValue()) {
throw new IllegalStateException("Range does not have just a single value");
}
return low.getValue();
}
代码示例来源: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
private void checkTypeCompatibility(Marker marker)
{
if (!getType().equals(marker.getType())) {
throw new IllegalArgumentException(String.format("Marker of %s does not match Range of %s", marker.getType(), getType()));
}
}
代码示例来源:origin: prestodb/presto
private void checkTypeCompatibility(Marker marker)
{
if (!getType().equals(marker.getType())) {
throw new IllegalStateException(String.format("Marker of %s does not match SortedRangeSet of %s", marker.getType(), getType()));
}
}
内容来源于网络,如有侵权,请联系作者删除!