Java Code Examples for org.apache.storm.tuple.ITuple

The following examples show how to use org.apache.storm.tuple.ITuple. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: streamline   Source File: StreamlineJdbcMapper.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<Column> getColumns(ITuple tuple) {
    StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    List<Column> res = new ArrayList<>();
    if (fieldsToColumns.isEmpty()) {
        initFieldsToColumns();
    }
    for(String field: fields) {
        Column<?> column = getColumn(field);
        String columnName = column.getColumnName();
        Integer columnSqlType = column.getSqlType();
        Object value = Util.getJavaType(columnSqlType).cast(event.get(field));
        res.add(new Column<>(columnName, value, columnSqlType));
    }
    return res;
}
 
Example 2
Source Project: streamline   Source File: StreamlineSolrJsonMapper.java    License: Apache License 2.0 5 votes vote down vote up
private String getJsonFromTuple(ITuple tuple) throws SolrMapperException {
    final StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    try {
        return objectMapper.writeValueAsString(event);
    } catch (JsonProcessingException e) {
        throw new SolrMapperException(e.getMessage());
    }
}
 
Example 3
Source Project: streamline   Source File: StreamlineSolrJsonMapper.java    License: Apache License 2.0 5 votes vote down vote up
private String getJsonFromTuples(List<? extends ITuple> tuples) throws SolrMapperException {
    final StringBuilder jsonListBuilder = new StringBuilder("[");
    for (ITuple tuple : tuples) {
        final String json = getJsonFromTuple(tuple);
        jsonListBuilder.append(json).append(",");
    }
    jsonListBuilder.setCharAt(jsonListBuilder.length() - 1, ']');
    return jsonListBuilder.toString();
}
 
Example 4
Source Project: streamline   Source File: OpenTsdbTupleDatapointMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public OpenTsdbMetricDatapoint getMetricPoint(ITuple tuple) {
    StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    return new OpenTsdbMetricDatapoint(
            (String) event.get(metricField),
            (Map<String, String>) event.get(tagsField),
            (Long) event.get(timestampField),
            (Number) event.get(valueField));
}
 
Example 5
@Override
public String getKeyFromTuple(ITuple tuple) {
    return tuple.getStringByField("word");
}
 
Example 6
@Override
public String getValueFromTuple(ITuple tuple) {
    return tuple.getIntegerByField("count") + "";
}
 
Example 7
Source Project: streamline   Source File: StreamlineFieldSelector.java    License: Apache License 2.0 4 votes vote down vote up
protected Object getFieldValue(ITuple tuple) {
    StreamlineEvent streamlineEvent = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    return streamlineEvent.get(field);
}
 
Example 8
Source Project: streamline   Source File: StreamlineSolrJsonMapper.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SolrRequest toSolrRequest(List<? extends ITuple> tupleList) throws SolrMapperException {
    return createSolrRequest(getJsonFromTuples(tupleList));
}
 
Example 9
Source Project: streamline   Source File: StreamlineSolrJsonMapper.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SolrRequest toSolrRequest(ITuple tuple) throws SolrMapperException {
    final String json = getJsonFromTuple(tuple);
    return createSolrRequest(json);
}
 
Example 10
Source Project: streamline   Source File: DruidEventMapper.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, Object> getEvent(ITuple tuple) {
    StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(eventFiledName);
    return new DruidEvent(event.addFieldAndValue(DruidBeamFactoryImpl.PROCESSING_TIME, System.currentTimeMillis()));
}
 
Example 11
Source Project: storm-net-adapter   Source File: WordCountToBolt.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String getKeyFromTuple(ITuple tuple) {
    return tuple.getStringByField("key");
}
 
Example 12
Source Project: storm-net-adapter   Source File: WordCountToBolt.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String getValueFromTuple(ITuple tuple) {
    return String.valueOf(tuple.getLongByField("value"));
}