Search in sources :

Example 21 with RE

use of org.apache.druid.java.util.common.RE in project druid by druid-io.

the class OssObjectSummaryIterator method fetchNextBatch.

private void fetchNextBatch() {
    try {
        result = OssUtils.retry(() -> client.listObjects(request));
        request.setMarker(result.getNextMarker());
        objectSummaryIterator = result.getObjectSummaries().iterator();
    } catch (OSSException e) {
        throw new RE(e, "Failed to get object summaries from aliyun OSS bucket[%s], prefix[%s]; error: %s", request.getBucketName(), request.getPrefix(), e.getMessage());
    } catch (Exception e) {
        throw new RE(e, "Failed to get object summaries from aliyun OSS bucket[%s], prefix[%s]", request.getBucketName(), request.getPrefix());
    }
}
Also used : RE(org.apache.druid.java.util.common.RE) OSSException(com.aliyun.oss.OSSException) OSSException(com.aliyun.oss.OSSException) NoSuchElementException(java.util.NoSuchElementException)

Example 22 with RE

use of org.apache.druid.java.util.common.RE in project druid by druid-io.

the class ExprListenerImpl method exitLongArray.

@Override
public void exitLongArray(ExprParser.LongArrayContext ctx) {
    Object[] values = new Object[ctx.longElement().size()];
    for (int i = 0; i < values.length; i++) {
        if (ctx.longElement(i).NULL() != null) {
            values[i] = null;
        } else if (ctx.longElement(i).LONG() != null) {
            values[i] = Long.parseLong(ctx.longElement(i).LONG().getText());
        } else {
            throw new RE("Failed to parse array element %s as a long", ctx.longElement(i).getText());
        }
    }
    nodes.put(ctx, new ArrayExpr(ExpressionType.LONG_ARRAY, values));
}
Also used : RE(org.apache.druid.java.util.common.RE)

Example 23 with RE

use of org.apache.druid.java.util.common.RE in project druid by druid-io.

the class ExprListenerImpl method exitExplicitStringArray.

@Override
public void exitExplicitStringArray(ExprParser.ExplicitStringArrayContext ctx) {
    Object[] values = new Object[ctx.literalElement().size()];
    for (int i = 0; i < values.length; i++) {
        if (ctx.literalElement(i).NULL() != null) {
            values[i] = null;
        } else if (ctx.literalElement(i).STRING() != null) {
            values[i] = escapeStringLiteral(ctx.literalElement(i).STRING().getText());
        } else if (ctx.literalElement(i).DOUBLE() != null) {
            values[i] = ctx.literalElement(i).DOUBLE().getText();
        } else if (ctx.literalElement(i).LONG() != null) {
            values[i] = ctx.literalElement(i).LONG().getText();
        } else {
            throw new RE("Failed to parse array element %s as a string", ctx.literalElement(i).getText());
        }
    }
    nodes.put(ctx, new ArrayExpr(ExpressionType.STRING_ARRAY, values));
}
Also used : RE(org.apache.druid.java.util.common.RE)

Example 24 with RE

use of org.apache.druid.java.util.common.RE in project druid by druid-io.

the class ExprListenerImpl method exitStringArray.

@Override
public void exitStringArray(ExprParser.StringArrayContext ctx) {
    Object[] values = new Object[ctx.stringElement().size()];
    for (int i = 0; i < values.length; i++) {
        if (ctx.stringElement(i).NULL() != null) {
            values[i] = null;
        } else if (ctx.stringElement(i).STRING() != null) {
            values[i] = escapeStringLiteral(ctx.stringElement(i).STRING().getText());
        } else {
            throw new RE("Failed to parse array: element %s is not a string", ctx.stringElement(i).getText());
        }
    }
    nodes.put(ctx, new ArrayExpr(ExpressionType.STRING_ARRAY, values));
}
Also used : RE(org.apache.druid.java.util.common.RE)

Example 25 with RE

use of org.apache.druid.java.util.common.RE in project druid by druid-io.

the class Parser method parse.

@VisibleForTesting
public static Expr parse(String in, ExprMacroTable macroTable, boolean withFlatten) {
    ExprLexer lexer = new ExprLexer(new ANTLRInputStream(in));
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    ExprParser parser = new ExprParser(tokens);
    parser.setBuildParseTree(true);
    ParseTree parseTree = parser.expr();
    ParseTreeWalker walker = new ParseTreeWalker();
    ExprListenerImpl listener = new ExprListenerImpl(parseTree, macroTable);
    walker.walk(listener, parseTree);
    Expr parsed = listener.getAST();
    if (parsed == null) {
        throw new RE("Failed to parse expression: %s", in);
    }
    return withFlatten ? flatten(parsed) : parsed;
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) RE(org.apache.druid.java.util.common.RE) ExprLexer(org.apache.druid.math.expr.antlr.ExprLexer) ExprParser(org.apache.druid.math.expr.antlr.ExprParser) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree) ParseTreeWalker(org.antlr.v4.runtime.tree.ParseTreeWalker) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

RE (org.apache.druid.java.util.common.RE)46 IOException (java.io.IOException)11 Request (org.apache.druid.java.util.http.client.Request)10 URL (java.net.URL)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 InputStream (java.io.InputStream)5 ExecutionException (java.util.concurrent.ExecutionException)5 ISE (org.apache.druid.java.util.common.ISE)5 Map (java.util.Map)4 StatusResponseHolder (org.apache.druid.java.util.http.client.response.StatusResponseHolder)4 JavaType (com.fasterxml.jackson.databind.JavaType)3 HashMap (java.util.HashMap)3 DataSegment (org.apache.druid.timeline.DataSegment)3 OSSException (com.aliyun.oss.OSSException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ApiException (io.kubernetes.client.openapi.ApiException)2 File (java.io.File)2