本文整理汇总了Java中org.wso2.siddhi.query.api.definition.AbstractDefinition.getAttributeType方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractDefinition.getAttributeType方法的具体用法?Java AbstractDefinition.getAttributeType怎么用?Java AbstractDefinition.getAttributeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.siddhi.query.api.definition.AbstractDefinition
的用法示例。
在下文中一共展示了AbstractDefinition.getAttributeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractAndValidateFeatures
import org.wso2.siddhi.query.api.definition.AbstractDefinition; //导入方法依赖的package包/类
/**
* @param inputDefinition
* @param attributeExpressionExecutors
* @param startIndex starting index
* @param noOfFeatures
* @return
*/
public static List<VariableExpressionExecutor> extractAndValidateFeatures(
AbstractDefinition inputDefinition, ExpressionExecutor[]
attributeExpressionExecutors,
int startIndex, int noOfFeatures) {
List<VariableExpressionExecutor> featureVariableExpressionExecutors = new ArrayList<>();
// feature values start
for (int i = startIndex; i < (startIndex + noOfFeatures); i++) {
if (attributeExpressionExecutors[i] instanceof VariableExpressionExecutor) {
featureVariableExpressionExecutors.add((VariableExpressionExecutor)
attributeExpressionExecutors[i]);
// other attributes should be numeric type.
String attributeName = ((VariableExpressionExecutor)
attributeExpressionExecutors[i]).getAttribute().getName();
Attribute.Type featureAttributeType = inputDefinition.
getAttributeType(attributeName);
//feature attributes not numerical type
if (!isNumeric(featureAttributeType)) {
throw new SiddhiAppValidationException("model.features in " + (i + 1) + "th parameter is not "
+ "a numerical type attribute. Found " + attributeExpressionExecutors[i].getReturnType()
+ ". Check the input stream definition.");
}
} else {
throw new SiddhiAppValidationException((i + 1) + "th parameter is not " +
"an attribute (VariableExpressionExecutor) present in the stream definition. Found a "
+ attributeExpressionExecutors[i].getClass().getCanonicalName());
}
}
return featureVariableExpressionExecutors;
}
示例2: init
import org.wso2.siddhi.query.api.definition.AbstractDefinition; //导入方法依赖的package包/类
@Override
protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) {
if (parameters[0] instanceof IntConstant) {
timeToKeep = ((IntConstant) parameters[0]).getValue();
} else {
timeToKeep = ((LongConstant) parameters[0]).getValue();
}
String subjectedAttr = ((Variable)parameters[1]).getAttributeName();
subjectedAttrIndex = streamDefinition.getAttributePosition(subjectedAttr);
subjectedAttrType = streamDefinition.getAttributeType(subjectedAttr);
oldEventList = new ArrayList<RemoveEvent>();
if (this.siddhiContext.isDistributedProcessingEnabled()) {
newEventList = this.siddhiContext.getHazelcastInstance().getList(elementId + "-newEventList");
} else {
newEventList = new ArrayList<InEvent>();
}
if (this.siddhiContext.isDistributedProcessingEnabled()) {
window = new SchedulerSiddhiQueueGrid<StreamEvent>(elementId, this, this.siddhiContext, this.async);
} else {
window = new SchedulerSiddhiQueue<StreamEvent>(this);
}
//Ordinary scheduling
window.schedule();
}
示例3: initIncrementalAttributeAggregator
import org.wso2.siddhi.query.api.definition.AbstractDefinition; //导入方法依赖的package包/类
private static void initIncrementalAttributeAggregator(
AbstractDefinition lastInputStreamDefinition, AttributeFunction attributeFunction,
IncrementalAttributeAggregator incrementalAttributeAggregator) {
String attributeName = null;
Attribute.Type attributeType = null;
if (attributeFunction.getParameters() != null && attributeFunction.getParameters()[0] != null) {
if (attributeFunction.getParameters().length != 1) {
throw new SiddhiAppCreationException("Incremental aggregator requires only on one parameter. "
+ "Found " + attributeFunction.getParameters().length,
attributeFunction.getQueryContextStartIndex(), attributeFunction.getQueryContextEndIndex());
}
if (!(attributeFunction.getParameters()[0] instanceof Variable)) {
throw new SiddhiAppCreationException("Incremental aggregator expected a variable. " +
"However a parameter of type " + attributeFunction.getParameters()[0].getClass().getTypeName()
+ " was found",
attributeFunction.getParameters()[0].getQueryContextStartIndex(),
attributeFunction.getParameters()[0].getQueryContextEndIndex());
}
attributeName = ((Variable) attributeFunction.getParameters()[0]).getAttributeName();
attributeType = lastInputStreamDefinition.getAttributeType(attributeName);
}
incrementalAttributeAggregator.init(attributeName, attributeType);
Attribute[] baseAttributes = incrementalAttributeAggregator.getBaseAttributes();
Expression[] baseAttributeInitialValues = incrementalAttributeAggregator
.getBaseAttributeInitialValues();
Expression[] baseAggregators = incrementalAttributeAggregator.getBaseAggregators();
if (baseAttributes.length != baseAggregators.length) {
throw new SiddhiAppCreationException("Number of baseAggregators '" +
baseAggregators.length + "' and baseAttributes '" +
baseAttributes.length + "' is not equal for '" + attributeFunction + "'",
attributeFunction.getQueryContextStartIndex(), attributeFunction.getQueryContextEndIndex());
}
if (baseAttributeInitialValues.length != baseAggregators.length) {
throw new SiddhiAppCreationException("Number of baseAggregators '" +
baseAggregators.length + "' and baseAttributeInitialValues '" +
baseAttributeInitialValues.length + "' is not equal for '" +
attributeFunction + "'",
attributeFunction.getQueryContextStartIndex(), attributeFunction.getQueryContextEndIndex());
}
}