本文整理汇总了Java中org.wso2.siddhi.query.api.definition.StreamDefinition.getAttributeList方法的典型用法代码示例。如果您正苦于以下问题:Java StreamDefinition.getAttributeList方法的具体用法?Java StreamDefinition.getAttributeList怎么用?Java StreamDefinition.getAttributeList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.siddhi.query.api.definition.StreamDefinition
的用法示例。
在下文中一共展示了StreamDefinition.getAttributeList方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructProcessExpressionExecutors
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
private static List<ExpressionExecutor> constructProcessExpressionExecutors(
SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap,
String aggregatorName, int baseAggregatorBeginIndex,
List<Expression> finalBaseAggregators,
StreamDefinition incomingOutputStreamDefinition,
MetaStreamEvent processedMetaStreamEvent,
List<VariableExpressionExecutor> processVariableExpressionExecutors, boolean groupBy) {
List<ExpressionExecutor> processExpressionExecutors = new ArrayList<>();
List<Attribute> attributeList = incomingOutputStreamDefinition.getAttributeList();
for (int i = 0; i < baseAggregatorBeginIndex; i++) {
Attribute attribute = attributeList.get(i);
VariableExpressionExecutor variableExpressionExecutor = (VariableExpressionExecutor) ExpressionParser
.parseExpression(new Variable(attribute.getName()), processedMetaStreamEvent, 0,
tableMap, processVariableExpressionExecutors, siddhiAppContext, groupBy,
0, aggregatorName);
processExpressionExecutors.add(variableExpressionExecutor);
}
for (Expression expression : finalBaseAggregators) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(expression,
processedMetaStreamEvent, 0, tableMap, processVariableExpressionExecutors,
siddhiAppContext, groupBy, 0, aggregatorName);
processExpressionExecutors.add(expressionExecutor);
}
return processExpressionExecutors;
}
示例2: initDefaultTables
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
private static HashMap<TimePeriod.Duration, Table> initDefaultTables(
String aggregatorName, List<TimePeriod.Duration> durations,
StreamDefinition streamDefinition, SiddhiAppRuntimeBuilder siddhiAppRuntimeBuilder,
List<Annotation> annotations, List<Variable> groupByVariableList) {
HashMap<TimePeriod.Duration, Table> aggregationTableMap = new HashMap<>();
// Create annotations for primary key
Annotation primaryKeyAnnotation = new Annotation(SiddhiConstants.ANNOTATION_PRIMARY_KEY);
primaryKeyAnnotation.element(null, "AGG_TIMESTAMP");
for (Variable groupByVariable : groupByVariableList) {
primaryKeyAnnotation.element(null, groupByVariable.getAttributeName());
}
annotations.add(primaryKeyAnnotation);
for (TimePeriod.Duration duration : durations) {
String tableId = aggregatorName + "_" + duration.toString();
TableDefinition tableDefinition = TableDefinition.id(tableId);
for (Attribute attribute : streamDefinition.getAttributeList()) {
tableDefinition.attribute(attribute.getName(), attribute.getType());
}
annotations.forEach(tableDefinition::annotation);
siddhiAppRuntimeBuilder.defineTable(tableDefinition);
aggregationTableMap.put(duration, siddhiAppRuntimeBuilder.getTableMap().get(tableId));
}
return aggregationTableMap;
}
示例3: getStreamDefinitionExpression
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
public String getStreamDefinitionExpression(StreamDefinition streamDefinition) {
List<String> columns = new ArrayList<>();
Preconditions.checkNotNull(streamDefinition, "StreamDefinition is null");
for (Attribute attribute : streamDefinition.getAttributeList()) {
columns.add(String.format("%s %s", attribute.getName(), attribute.getType().toString().toLowerCase()));
}
return String.format(DEFINE_STREAM_TEMPLATE, streamDefinition.getId(), StringUtils.join(columns, ","));
}
示例4: getStreamDefinitionExpression
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
public String getStreamDefinitionExpression(StreamDefinition streamDefinition) {
List<String> columns = new ArrayList<>();
Preconditions.checkNotNull(streamDefinition, "StreamDefinition is null");
for (Attribute attribute : streamDefinition.getAttributeList()) {
columns.add(String.format("%s %s", attribute.getName(), attribute.getType().toString().toLowerCase()));
}
return String.format(DEFINE_STREAM_TEMPLATE, streamDefinition.getId(), StringUtils.join(columns, ","));
}
示例5: declareOutputFields
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
if(siddhiManager == null){
init();
}
boolean useDefault = (exportedStreams.length == 1) && useDefaultAsStreamName;
for(String streamId: exportedStreams){
StreamDefinition streamDefinition = siddhiManager.getStreamDefinition(streamId);
if(streamDefinition == null){
throw new RuntimeException("Cannot find stream "+ streamId + " "+ this);
}
List<Attribute> attributeList = streamDefinition.getAttributeList();
List<String> list = new ArrayList<String>();
for(Attribute attribute: attributeList){
list.add(attribute.getName());
}
Fields feilds = new Fields(list);
if(useDefault){
//this is so that most common Storm topologies would work with
//Siddhi bolt. See setUseDefaultAsStreamName(..)
log.info(componentID + ">Siddhi: declaring stream as default");
declarer.declare(feilds);
}else{
declarer.declareStream(streamId, feilds);
}
}
}
示例6: declareOutputFields
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
if (siddhiManager == null) {
init();
}
boolean useDefault = (exportedStreams.length == 1) && useDefaultAsStreamName;
for (String streamId : exportedStreams) {
StreamDefinition streamDefinition = siddhiManager.getStreamDefinition(streamId);
if (streamDefinition == null) {
throw new RuntimeException("Cannot find stream " + streamId + " " + this);
}
List<Attribute> attributeList = streamDefinition.getAttributeList();
List<String> list = new ArrayList<String>();
for (Attribute attribute : attributeList) {
list.add(attribute.getName());
}
Fields feilds = new Fields(list);
if (useDefault) {
//this is so that most common Storm topologies would work with
//Siddhi bolt. See setUseDefaultAsStreamName(..)
log.info(componentID + ">Siddhi: declaring stream as default");
declarer.declare(feilds);
} else {
declarer.declareStream(streamId, feilds);
}
}
}
示例7: SiddhiSpout
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
public SiddhiSpout(StreamDefinition siddhiStreamDefinition, QueuedEventSource inputEventSource) {
this.inputEventSource = inputEventSource;
this.exportedSiddhiStreamDef = siddhiStreamDefinition;
List<Attribute> attributeList = siddhiStreamDefinition.getAttributeList();
this.attributeNames = new ArrayList<String>(attributeList.size());
for (Attribute attribute : attributeList) {
attributeNames.add(attribute.getName());
}
}
示例8: declareOutputFields
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
if (siddhiManager == null) {
try {
init();
} catch (StormConfigurationException e) {
log.error("Error trying to re-initialize this bolt: " + e.getMessage(), e);
}
}
boolean useDefault = (outputSiddhiStreamIds.length == 1) && useDefaultAsStreamName;
for (String streamId : outputSiddhiStreamIds) {
StreamDefinition streamDefinition = siddhiManager.getStreamDefinition(streamId);
if (streamDefinition == null) {
throw new RuntimeException("Cannot find stream " + streamId + " " + this);
}
List<Attribute> attributeList = streamDefinition.getAttributeList();
List<String> list = new ArrayList<String>();
for (Attribute attribute : attributeList) {
list.add(attribute.getName());
}
Fields feilds = new Fields(list);
if (useDefault) {
//this is so that most common Storm topologies would work with
//Siddhi bolt. See setUseDefaultAsStreamName(..)
log.info(componentID + ">Siddhi: declaring stream as default");
declarer.declare(feilds);
} else {
declarer.declareStream(streamId, feilds);
}
}
}
示例9: columnAlreadyExistsInStream
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
public static boolean columnAlreadyExistsInStream(String columnName, StreamDefinition streamMetaData) {
for (Attribute column : streamMetaData.getAttributeList()) {
if (column.getName().equalsIgnoreCase(columnName)) {
return true;
}
}
return false;
}
示例10: list
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
public List<StratioStreamingMessage> list() {
List<StratioStreamingMessage> result = new ArrayList<>();
for (StreamDefinition streamDefinition : siddhiManager.getStreamDefinitions()) {
if (suitableToList(streamDefinition.getStreamId())) {
StratioStreamingMessage message = new StratioStreamingMessage();
for (Attribute attribute : streamDefinition.getAttributeList()) {
message.addColumn(new ColumnNameTypeValue(attribute.getName(), this.getStreamingType(attribute
.getType()), null));
}
StreamStatusDTO streamStatus = streamStatusDao.get(streamDefinition.getStreamId());
if (streamStatus != null) {
Map<String, QueryDTO> attachedQueries = streamStatus.getAddedQueries();
for (Map.Entry<String, QueryDTO> entry : attachedQueries.entrySet()) {
message.addQuery(new StreamQuery(entry.getKey(), entry.getValue().getQueryRaw()));
}
message.setUserDefined(streamStatus.getUserDefined());
message.setActiveActions(streamStatusDao.getEnabledActions(streamDefinition.getStreamId()));
}
message.setStreamName(streamDefinition.getStreamId());
result.add(message);
}
}
return result;
}
示例11: build
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
/**
* Builds the execution plan from the input topics and the user-provided execution plan
*
* @return A string with the full siddhi-formatted execution plan
* @throws ExecutionPlanException if any input specified is not found
*/
public String build() throws ExecutionPlanException {
StringBuilder fullExecutionPlanBuilder = new StringBuilder();
StringBuilder streamsWithFiltersBuilder = new StringBuilder();
for (String topic : inputTopics) {
StreamDefinition streamDefinition = streamDefinitions.get(topic);
if (streamDefinition == null) {
throw new InvalidExecutionPlanException("No stream definition found for topic " + topic + " on execution plan id " + id + "!");
}
List<Attribute> attributes = streamDefinition.getAttributeList();
List<String> attributesWithType = new ArrayList<>();
List<String> attributesNameList = new ArrayList<>();
for (Attribute attribute : attributes) {
attributesWithType.add(attribute.getName() + " " + attribute.getType());
attributesNameList.add(attribute.getName());
}
String attributesWithTypeList = Joiner.on(", ").join(attributesWithType);
fullExecutionPlanBuilder.append("define stream raw_")
.append(topic)
.append(" (")
.append(attributesWithTypeList)
.append(");");
List<String> filtersList = new ArrayList<>();
for (Map.Entry<String, String> entry : filters.entrySet()) {
String field = entry.getKey();
String value = entry.getValue();
filtersList.add(field + " == '" + value + "'");
}
if (filtersList.isEmpty()) {
streamsWithFiltersBuilder.append("from raw_")
.append(topic);
} else {
String filtersString = Joiner.on(" and ").join(filtersList);
streamsWithFiltersBuilder.append("from raw_")
.append(topic)
.append("[")
.append(filtersString)
.append("]");
}
String attributesString = Joiner.on(", ").join(attributesNameList);
streamsWithFiltersBuilder.append(" select ")
.append(attributesString)
.append(" insert into ")
.append(topic)
.append(";");
}
fullExecutionPlanBuilder.append(streamsWithFiltersBuilder);
fullExecutionPlanBuilder.append(executionPlan);
return fullExecutionPlanBuilder.toString();
}
示例12: cloneStreamDefinition
import org.wso2.siddhi.query.api.definition.StreamDefinition; //导入方法依赖的package包/类
private static void cloneStreamDefinition(StreamDefinition originalStreamDefinition,
StreamDefinition newStreamDefinition) {
for (Attribute attribute : originalStreamDefinition.getAttributeList()) {
newStreamDefinition.attribute(attribute.getName(), attribute.getType());
}
}