streams-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfranklin <>
Subject [GitHub] incubator-streams pull request: Streams 41
Date Wed, 21 May 2014 19:07:46 GMT
Github user mfranklin commented on a diff in the pull request:
    --- Diff: streams-contrib/streams-provider-datasift/src/main/java/org/apache/streams/datasift/provider/
    @@ -1,105 +1,102 @@
    +Licensed to the Apache Software Foundation (ASF) under one
    +or more contributor license agreements.  See the NOTICE file
    +distributed with this work for additional information
    +regarding copyright ownership.  The ASF licenses this file
    +to you under the Apache License, Version 2.0 (the
    +"License"); you may not use this file except in compliance
    +with the License.  You may obtain a copy of the License at
    +Unless required by applicable law or agreed to in writing,
    +software distributed under the License is distributed on an
    +KIND, either express or implied.  See the License for the
    +specific language governing permissions and limitations
    +under the License.
     package org.apache.streams.datasift.provider;
    +import com.fasterxml.jackson.core.JsonProcessingException;
     import com.fasterxml.jackson.databind.ObjectMapper;
    +import org.apache.commons.lang.NotImplementedException;
     import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
     import org.apache.streams.datasift.Datasift;
     import org.apache.streams.datasift.serializer.DatasiftActivitySerializer;
    -import org.apache.streams.datasift.twitter.Twitter;
    +import org.apache.streams.jackson.StreamsJacksonMapper;
     import org.apache.streams.pojo.json.Activity;
    -import org.apache.streams.twitter.pojo.Tweet;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
    -import java.util.Queue;
    -import java.util.Random;
    +import java.util.List;
      * Created by sblackmon on 12/10/13.
    -public class DatasiftEventProcessor implements Runnable {
    +public class DatasiftEventProcessor implements StreamsProcessor {
         private final static Logger LOGGER = LoggerFactory.getLogger(DatasiftEventProcessor.class);
    -    private ObjectMapper mapper = new ObjectMapper();
    -    private Queue<Interaction> inQueue;
    -    private Queue<StreamsDatum> outQueue;
    -    private Class inClass;
    +    private ObjectMapper mapper;
         private Class outClass;
    -    private DatasiftActivitySerializer datasiftInteractionActivitySerializer = new DatasiftActivitySerializer();
    +    private DatasiftActivitySerializer datasiftInteractionActivitySerializer;
    +    private DatasiftTypeConverter converter;
         public final static String TERMINATE = new String("TERMINATE");
    -    public DatasiftEventProcessor(Queue<Interaction> inQueue, Queue<StreamsDatum>
outQueue, Class inClass, Class outClass) {
    -        this.inQueue = inQueue;
    -        this.outQueue = outQueue;
    -        this.inClass = inClass;
    +    public DatasiftEventProcessor(Class outClass) {
             this.outClass = outClass;
    -    public DatasiftEventProcessor(Queue<Interaction> inQueue, Queue<StreamsDatum>
outQueue, Class outClass) {
    -        this.inQueue = inQueue;
    -        this.outQueue = outQueue;
    -        this.outClass = outClass;
    +    @Override
    +    public List<StreamsDatum> process(StreamsDatum entry) {
    +        List<StreamsDatum> result = Lists.newLinkedList();
    +        Object item = entry.getDocument();
    +        try {
    +            Datasift datasift = mapper.convertValue(item, Datasift.class);
    +            result.add(this.converter.convert(datasift));
    +        } catch (Exception e) {
    +            e.printStackTrace();
    --- End diff --
    This should be output to a Logger

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message