private MultiKeyUntyped getKeys(EventBean event) { Object[] keys = new Object[partitionExpressions.length]; eventsPerStream[0] = event; int count = 0; for (ExprEvaluator node : partitionExpressions) { keys[count++] = node.evaluate(eventsPerStream, true, exprEvaluatorContext); } return new MultiKeyUntyped(keys); }
public boolean matches(EventBean[] eventsPerStream, ExprEvaluatorContext exprEvaluatorContext) { if (exprNode == null) { return true; } Boolean result = (Boolean) exprNode.evaluate(eventsPerStream, true, exprEvaluatorContext); if (result != null) { return result; } return false; }
public Object evaluate( long startTs, long endTs, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) { Object parameter = evaluatorTimestamp.evaluate(eventsPerStream, isNewData, context); if (parameter == null) { return parameter; } return intervalOpEval.evaluate(startTs, endTs, parameter, eventsPerStream, isNewData, context); }
public Object evaluate( long startTs, long endTs, Object parameterStartTs, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) { Object paramEndTs = evaluatorEndTimestamp.evaluate(eventsPerStream, isNewData, context); if (paramEndTs == null) { return null; } return evaluate( startTs, endTs, parameterStartTs, paramEndTs, eventsPerStream, isNewData, context); }
private static Object coerceProperty( String propertyName, Class containingType, Object value, Class type, EngineImportService engineImportService, boolean forceNumeric) throws ExprValidationException { if (value instanceof ExprNode && type != ExprNode.class) { if (value instanceof ExprIdentNode) { ExprIdentNode identNode = (ExprIdentNode) value; Property prop; try { prop = PropertyParser.parse(identNode.getFullUnresolvedName(), false); } catch (Exception ex) { throw new ExprValidationException( "Failed to parse property '" + identNode.getFullUnresolvedName() + "'"); } if (!(prop instanceof MappedProperty)) { throw new ExprValidationException( "Unrecognized property '" + identNode.getFullUnresolvedName() + "'"); } MappedProperty mappedProperty = (MappedProperty) prop; if (mappedProperty.getPropertyNameAtomic().toLowerCase().equals(SYSTEM_PROPETIES_NAME)) { return System.getProperty(mappedProperty.getKey()); } } else { ExprNode exprNode = (ExprNode) value; ExprEvaluator evaluator = exprNode.getExprEvaluator(); if (evaluator == null) { throw new ExprValidationException( "Failed to evaluate expression '" + exprNode.toExpressionString() + "'"); } value = evaluator.evaluate(null, true, null); } } if (value == null) { return null; } if (value.getClass() == type) { return value; } if (JavaClassHelper.isAssignmentCompatible(value.getClass(), type)) { if (forceNumeric && JavaClassHelper.getBoxedType(value.getClass()) != JavaClassHelper.getBoxedType(type) && JavaClassHelper.isNumeric(type) && JavaClassHelper.isNumeric(value.getClass())) { value = JavaClassHelper.coerceBoxed((Number) value, JavaClassHelper.getBoxedType(type)); } return value; } if (JavaClassHelper.isSubclassOrImplementsInterface(value.getClass(), type)) { return value; } if (type.isArray()) { if (!(value instanceof Collection)) { throw new ExprValidationException( "Property '" + propertyName + "' of class " + JavaClassHelper.getClassNameFullyQualPretty(containingType) + " expects an array but receives a value of type " + value.getClass().getName()); } Object[] items = ((Collection) value).toArray(); Object coercedArray = Array.newInstance(type.getComponentType(), items.length); for (int i = 0; i < items.length; i++) { Object coercedValue = coerceProperty( propertyName + " (array element)", type, items[i], type.getComponentType(), engineImportService, false); Array.set(coercedArray, i, coercedValue); } return coercedArray; } if (!(value instanceof Map)) { throw new ExprValidationException( "Property '" + propertyName + "' of class " + JavaClassHelper.getClassNameFullyQualPretty(containingType) + " expects an " + JavaClassHelper.getClassNameFullyQualPretty(type) + " but receives a value of type " + value.getClass().getName()); } Map<String, Object> props = (Map<String, Object>) value; return instantiatePopulateObject(props, type, engineImportService); }