use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class StreamlineJdbcMapper method getColumns.
@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;
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class StreamlineJPMMLModelRunner method extractRawInputs.
/**
* @return The raw inputs extracted from the tuple for all 'active fields'
*/
@Override
public Map<FieldName, Object> extractRawInputs(Tuple tuple) {
LOG.debug("Extracting raw inputs from tuple: = [{}]", tuple);
Object event = tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
final Map<FieldName, Object> rawInputs = new LinkedHashMap<>();
if (event instanceof StreamlineEvent) {
StreamlineEvent streamlineEvent = (StreamlineEvent) event;
for (FieldName fieldName : getActiveFields()) {
if (streamlineEvent.containsKey(fieldName.getValue())) {
rawInputs.put(fieldName, streamlineEvent.get(fieldName.getValue()));
}
}
} else {
LOG.debug("Not processing invalid input tuple:[{}] with streamline event:[{}]", tuple, event);
}
LOG.debug("Raw inputs = [{}]", rawInputs);
return rawInputs;
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class DefaultSplitter method splitEvent.
@Override
public List<Result> splitEvent(StreamlineEvent inputEvent, Set<String> outputStreams) {
List<Result> results = new ArrayList<>();
String groupId = getGroupId(inputEvent);
int curPartNo = 0;
int totalParts = outputStreams.size();
for (String stream : outputStreams) {
StreamlineEvent partitionedEvent = createPartitionEvent(inputEvent, groupId, ++curPartNo, stream, totalParts);
results.add(new Result(stream, Collections.singletonList(partitionedEvent)));
}
return results;
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class StreamlineEventImplTest method testGetDataSourceId.
@Test
public void testGetDataSourceId() throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("a", "aval");
map.put("b", "bval");
StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(map).dataSourceId("1").build();
assertEquals("1", event.getDataSourceId());
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class StreamlineEventImplTest method testToFromString.
@Test
public void testToFromString() {
Map<String, Object> map = new HashMap<>();
map.put("a", "aval");
map.put("b", "bval");
StreamlineEventImpl se1 = StreamlineEventImpl.builder().putAll(map).build();
String s = se1.toString();
StreamlineEvent se2 = StreamlineEventImpl.fromString(s);
assertEquals("aval", se2.get("a"));
assertEquals("bval", se2.get("b"));
}
Aggregations