本文整理汇总了Java中com.facebook.presto.spi.type.Type.isComparable方法的典型用法代码示例。如果您正苦于以下问题:Java Type.isComparable方法的具体用法?Java Type.isComparable怎么用?Java Type.isComparable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.presto.spi.type.Type
的用法示例。
在下文中一共展示了Type.isComparable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EquatableValueSet
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@JsonCreator
public EquatableValueSet(
@JsonProperty("type") Type type,
@JsonProperty("whiteList") boolean whiteList,
@JsonProperty("entries") Set<ValueEntry> entries)
{
requireNonNull(type, "type is null");
requireNonNull(entries, "entries is null");
if (!type.isComparable()) {
throw new IllegalArgumentException("Type is not comparable: " + type);
}
if (type.isOrderable()) {
throw new IllegalArgumentException("Use SortedRangeSet instead");
}
this.type = type;
this.whiteList = whiteList;
this.entries = Collections.unmodifiableSet(new HashSet<>(entries));
}
示例2: canBind
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public boolean canBind(Type type)
{
if (comparableRequired && !type.isComparable()) {
return false;
}
if (orderableRequired && !type.isOrderable()) {
return false;
}
if (variadicBound != null && !type.getTypeSignature().getBase().equals(variadicBound)) {
return false;
}
return true;
}
示例3: analyzeGroupingColumns
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private List<FieldOrExpression> analyzeGroupingColumns(List<Expression> groupingColumns, QuerySpecification node, RelationType tupleDescriptor, AnalysisContext context, List<FieldOrExpression> outputExpressions)
{
ImmutableList.Builder<FieldOrExpression> groupingColumnsBuilder = ImmutableList.builder();
for (Expression groupingColumn : groupingColumns) {
// first, see if this is an ordinal
FieldOrExpression groupByExpression;
if (groupingColumn instanceof LongLiteral) {
long ordinal = ((LongLiteral) groupingColumn).getValue();
if (ordinal < 1 || ordinal > outputExpressions.size()) {
throw new SemanticException(INVALID_ORDINAL, groupingColumn, "GROUP BY position %s is not in select list", ordinal);
}
groupByExpression = outputExpressions.get((int) (ordinal - 1));
}
else {
ExpressionAnalysis expressionAnalysis = analyzeExpression(groupingColumn, tupleDescriptor, context);
analysis.recordSubqueries(node, expressionAnalysis);
groupByExpression = new FieldOrExpression(groupingColumn);
}
Type type;
if (groupByExpression.isExpression()) {
Analyzer.verifyNoAggregatesOrWindowFunctions(metadata, groupByExpression.getExpression(), "GROUP BY");
type = analysis.getType(groupByExpression.getExpression());
}
else {
type = tupleDescriptor.getFieldByIndex(groupByExpression.getFieldIndex()).getType();
}
if (!type.isComparable()) {
throw new SemanticException(TYPE_MISMATCH, node, "%s is not comparable, and therefore cannot be used in GROUP BY", type);
}
groupingColumnsBuilder.add(groupByExpression);
}
return groupingColumnsBuilder.build();
}
示例4: none
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
static ValueSet none(Type type)
{
if (type.isOrderable()) {
return SortedRangeSet.none(type);
}
if (type.isComparable()) {
return EquatableValueSet.none(type);
}
return AllOrNoneValueSet.none(type);
}
示例5: all
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
static ValueSet all(Type type)
{
if (type.isOrderable()) {
return SortedRangeSet.all(type);
}
if (type.isComparable()) {
return EquatableValueSet.all(type);
}
return AllOrNoneValueSet.all(type);
}
示例6: of
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
static ValueSet of(Type type, Object first, Object... rest)
{
if (type.isOrderable()) {
return SortedRangeSet.of(type, first, rest);
}
if (type.isComparable()) {
return EquatableValueSet.of(type, first, rest);
}
throw new IllegalArgumentException("Cannot create discrete ValueSet with non-comparable type: " + type);
}
示例7: copyOf
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
static ValueSet copyOf(Type type, Collection<Object> values)
{
if (type.isOrderable()) {
return SortedRangeSet.copyOf(type, values.stream()
.map(value -> Range.equal(type, value))
.collect(toList()));
}
if (type.isComparable()) {
return EquatableValueSet.copyOf(type, values);
}
throw new IllegalArgumentException("Cannot create discrete ValueSet with non-comparable type: " + type);
}
示例8: analyzeSelect
import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private List<FieldOrExpression> analyzeSelect(QuerySpecification node, RelationType tupleDescriptor, AnalysisContext context)
{
ImmutableList.Builder<FieldOrExpression> outputExpressionBuilder = ImmutableList.builder();
for (SelectItem item : node.getSelect().getSelectItems()) {
if (item instanceof AllColumns) {
// expand * and T.*
Optional<QualifiedName> starPrefix = ((AllColumns) item).getPrefix();
List<Field> fields = tupleDescriptor.resolveFieldsWithPrefix(starPrefix);
if (fields.isEmpty()) {
if (starPrefix.isPresent()) {
throw new SemanticException(MISSING_TABLE, item, "Table '%s' not found", starPrefix.get());
}
else {
throw new SemanticException(WILDCARD_WITHOUT_FROM, item, "SELECT * not allowed in queries without FROM clause");
}
}
for (Field field : fields) {
int fieldIndex = tupleDescriptor.indexOf(field);
outputExpressionBuilder.add(new FieldOrExpression(fieldIndex));
if (node.getSelect().isDistinct() && !field.getType().isComparable()) {
throw new SemanticException(TYPE_MISMATCH, node.getSelect(), "DISTINCT can only be applied to comparable types (actual: %s)", field.getType());
}
}
}
else if (item instanceof SingleColumn) {
SingleColumn column = (SingleColumn) item;
ExpressionAnalysis expressionAnalysis = analyzeExpression(column.getExpression(), tupleDescriptor, context);
analysis.recordSubqueries(node, expressionAnalysis);
outputExpressionBuilder.add(new FieldOrExpression(column.getExpression()));
Type type = expressionAnalysis.getType(column.getExpression());
if (node.getSelect().isDistinct() && !type.isComparable()) {
throw new SemanticException(TYPE_MISMATCH, node.getSelect(), "DISTINCT can only be applied to comparable types (actual: %s): %s", type, column.getExpression());
}
}
else {
throw new IllegalArgumentException("Unsupported SelectItem type: " + item.getClass().getName());
}
}
ImmutableList<FieldOrExpression> result = outputExpressionBuilder.build();
analysis.setOutputExpressions(node, result);
return result;
}