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());
}
}
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));
}
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));
}
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));
}
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;
}
Aggregations