Search in sources :

Example 6 with StreamlineEventImpl

use of com.hortonworks.streamline.streams.common.StreamlineEventImpl in project streamline by hortonworks.

the class StreamlineEventMapper method entity.

@Override
public StreamlineEvent entity(Result result) {
    String id = Bytes.toString(result.getRow());
    Map<String, Object> fieldsAndValues = new HashMap<>();
    for (Map.Entry<byte[], byte[]> entry : result.getFamilyMap(CF_FIELDS).entrySet()) {
        fieldsAndValues.put(Bytes.toString(entry.getKey()), Bytes.toString(entry.getValue()));
    }
    String dataSourceId = Bytes.toString(result.getFamilyMap(CF_DATASOURCE_ID).firstEntry().getKey());
    StreamlineEventImpl event = StreamlineEventImpl.builder().fieldsAndValues(fieldsAndValues).dataSourceId(dataSourceId).build();
    return new IdPreservedStreamlineEvent(event, id);
}
Also used : HashMap(java.util.HashMap) IdPreservedStreamlineEvent(com.hortonworks.streamline.streams.common.IdPreservedStreamlineEvent) StreamlineEventImpl(com.hortonworks.streamline.streams.common.StreamlineEventImpl) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

StreamlineEventImpl (com.hortonworks.streamline.streams.common.StreamlineEventImpl)6 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Values (org.apache.storm.tuple.Values)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Result (com.hortonworks.streamline.streams.Result)1 StreamlineEvent (com.hortonworks.streamline.streams.StreamlineEvent)1 IdPreservedStreamlineEvent (com.hortonworks.streamline.streams.common.IdPreservedStreamlineEvent)1 ArrayList (java.util.ArrayList)1 ParseException (org.apache.storm.hdfs.spout.ParseException)1 Tuple (org.apache.storm.tuple.Tuple)1