Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.spi.predicate;
import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.type.Type;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;
import java.util.Optional;
import static java.util.Objects.requireNonNull;
/**
* 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.
*/
public final class Marker
implements Comparable
{
public enum Bound
{
BELOW, // lower than the value, but infinitesimally close to the value
EXACTLY, // exactly the value
ABOVE // higher than the value, but infinitesimally close to the value
}
private final Type type;
private final Optional valueBlock;
private final Bound bound;
/**
* LOWER UNBOUNDED is specified with an empty value and a ABOVE bound
* UPPER UNBOUNDED is specified with an empty value and a BELOW bound
*/
@JsonCreator
public Marker(
@JsonProperty("type") Type type,
@JsonProperty("valueBlock") Optional valueBlock,
@JsonProperty("bound") Bound bound)
{
requireNonNull(type, "type is null");
requireNonNull(valueBlock, "valueBlock is null");
requireNonNull(bound, "bound is null");
if (!type.isOrderable()) {
throw new IllegalArgumentException("type must be orderable");
}
if (!valueBlock.isPresent() && bound == Bound.EXACTLY) {
throw new IllegalArgumentException("Can not be equal to unbounded");
}
if (valueBlock.isPresent() && valueBlock.get().getPositionCount() != 1) {
throw new IllegalArgumentException("value block should only have one position");
}
this.type = type;
this.valueBlock = valueBlock;
this.bound = bound;
}
private static Marker create(Type type, Optional