Search in sources :

Example 1 with ScalarHeader

use of com.facebook.presto.operator.scalar.ScalarHeader in project presto by prestodb.

the class ScalarImplementationHeader method fromAnnotatedElement.

public static List<ScalarImplementationHeader> fromAnnotatedElement(AnnotatedElement annotated) {
    ScalarFunction scalarFunction = annotated.getAnnotation(ScalarFunction.class);
    ScalarOperator scalarOperator = annotated.getAnnotation(ScalarOperator.class);
    Optional<String> description = parseDescription(annotated);
    ImmutableList.Builder<ScalarImplementationHeader> builder = ImmutableList.builder();
    if (scalarFunction != null) {
        String baseName = scalarFunction.value().isEmpty() ? camelToSnake(annotatedName(annotated)) : scalarFunction.value();
        builder.add(new ScalarImplementationHeader(baseName, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), scalarFunction.calledOnNullInput())));
        for (String alias : scalarFunction.alias()) {
            builder.add(new ScalarImplementationHeader(alias, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), scalarFunction.calledOnNullInput())));
        }
    }
    if (scalarOperator != null) {
        builder.add(new ScalarImplementationHeader(scalarOperator.value(), new ScalarHeader(description, HIDDEN, true, scalarOperator.value().isCalledOnNullInput())));
    }
    List<ScalarImplementationHeader> result = builder.build();
    checkArgument(!result.isEmpty());
    return result;
}
Also used : ScalarOperator(com.facebook.presto.spi.function.ScalarOperator) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) ImmutableList(com.google.common.collect.ImmutableList) ScalarHeader(com.facebook.presto.operator.scalar.ScalarHeader)

Aggregations

ScalarHeader (com.facebook.presto.operator.scalar.ScalarHeader)1 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)1 ScalarOperator (com.facebook.presto.spi.function.ScalarOperator)1 ImmutableList (com.google.common.collect.ImmutableList)1