You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2017/12/21 19:06:02 UTC

[GitHub] revans2 commented on issue #1000: Make sure nextTuple emits tuple with non-null values

revans2 commented on issue #1000: Make sure nextTuple emits tuple with non-null values
URL: https://github.com/apache/incubator-pulsar/pull/1000#issuecomment-353431864
 
 
   I am not sure this is the best solution.  You are using recursion to try and fix a problem that should be simple to do in an iterative way.
   
   Why not have mapToValueAndEmit just return a boolean saying did I emit something or not, and then loop until something is emitted.
   For Example
   ```
                if (LOG.isDebugEnabled()) {
                    LOG.debug("[{}] Receiving the next message from pulsar consumer to emit to the collector", spoutId);
                }
                try {
                    boolean done=false;
                    while (!done) {
                        msg = consumer.receive(1, TimeUnit.SECONDS);
                        if (msg != null) {
                            ++messagesReceived;
                            messageSizeReceived += msg.getData().length;
                            done = mapToValueAndEmit(msg);
                        } else {
                           //There was nothing queued to emit so don't try again right now.
                           done = true;
                        }
                   }
                } catch (PulsarClientException e) {
                    LOG.error("[{}] Error receiving message from pulsar consumer", spoutId, e);
                }
   ``` 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services