private Clause rewriteClause(Clause clause) { Clause toReturn = clause; if (clause instanceof LogicalClause) { LogicalClause logical = ((LogicalClause) clause); logical.setClauses(rewriteClauses(logical.getClauses())); } else if (clause instanceof StringFilterClause) { toReturn = new ObjectFilterClause((StringFilterClause) clause); } return toReturn; } }
@Override public Set<String> getRequiredFields() { return computation.getExpression().getRequiredFields(); }
/** * Default constructor. GSON recommended. */ public Query() { // If no aggregation is provided, the default one is used. Aggregations must be present. aggregation = new Aggregation(); }
@Override protected com.yahoo.bullet.parsing.Expression visitDecimalLiteral(DecimalLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.DOUBLE)); return leafExpression; }
private Query constructQuery() { Query query = new Query(); query.setAggregation(aggregation); query.setDuration(duration); query.setFilters(filters); query.setProjection(projection); query.setWindow(window); query.setPostAggregations(postAggregations); return query; }
private Clause createFilterClause(Operation operation, String field, String... values) { FilterClause filterClause = new ObjectFilterClause(); filterClause.setOperation(operation); filterClause.setField(field); filterClause.setValues(Stream.of(values).map(v -> new Value(Value.Kind.VALUE, v)).collect(Collectors.toList())); return filterClause; }
@Override public String getValue(Value value) { return value.getValue(); }
/** * Returns if this query should buffer before emitting the final results. You can use this to wait for the final * results in your Join or Combine stage after a query is {@link #isDone()}. * * @return A boolean that is true if the query results should be buffered in the Join phase. */ public boolean shouldBuffer() { Window window = runningQuery.getQuery().getWindow(); boolean noWindow = window == null; // Only buffer if there is no window (including Raw) or if it's a record based window. return noWindow || !window.isTimeBased(); }
private static boolean hasNonANDLogicals(Clause clause) { if (clause instanceof FilterClause) { return false; } return clause.getOperation() != Clause.Operation.AND || hasNonANDLogicals(((LogicalClause) clause).getClauses()); }
@Override public String toString() { return "{" + super.toString() + ", " + "clauses: " + clauses + "}"; } }
/** * Creates a FieldTypeAdapterFactory of this type. * * @param base The base type for all types that this factory handles. * @param <T> The base type. * @return The created factory. */ public static <T> FieldTypeAdapterFactory<T> of(Class<T> base) { return new FieldTypeAdapterFactory<>(base); }
/** * Creates an instance of a Query object from the given String version of the query and an ID. It does also not * initialize it. * * @param id The String query ID. * @param queryString The String version of the query. * @param config The configuration to use for the query. * @throws com.google.gson.JsonParseException if there were issues parsing the query. */ public RunningQuery(String id, String queryString, BulletConfig config) { this(id, Parser.parse(queryString, config)); this.queryString = queryString; }
@Override public String toString() { return "{" + super.toString() + ", left: " + left + ", right: " + right + ", type: " + type + "}"; }
@Override protected com.yahoo.bullet.parsing.Expression visitBooleanLiteral(BooleanLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.BOOLEAN)); return leafExpression; }
@Override public String toString() { return "{" + super.toString() + ", " + "field: " + field + ", " + "values: " + values + "}"; }
@Override protected com.yahoo.bullet.parsing.Expression visitLongLiteral(LongLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.LONG)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitDoubleLiteral(DoubleLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.DOUBLE)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitStringLiteral(StringLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.STRING)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitIdentifier(Identifier node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.FIELD, node.toFormatlessString())); return leafExpression; } }
@Override protected com.yahoo.bullet.parsing.Expression visitArithmeticUnary(ArithmeticUnaryExpression node, Void context) { LeafExpression leafExpression = new LeafExpression(); Type type; if (node.getValue() instanceof LongLiteral) { type = Type.LONG; } else { type = Type.DOUBLE; } leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), type)); return leafExpression; }