Return-Path: X-Original-To: apmail-streams-dev-archive@minotaur.apache.org Delivered-To: apmail-streams-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5546CCF92 for ; Thu, 7 Aug 2014 18:28:14 +0000 (UTC) Received: (qmail 76010 invoked by uid 500); 7 Aug 2014 18:28:13 -0000 Delivered-To: apmail-streams-dev-archive@streams.apache.org Received: (qmail 75956 invoked by uid 500); 7 Aug 2014 18:28:13 -0000 Mailing-List: contact dev-help@streams.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@streams.incubator.apache.org Delivered-To: mailing list dev@streams.incubator.apache.org Received: (qmail 75390 invoked by uid 99); 7 Aug 2014 18:28:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2014 18:28:12 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 07 Aug 2014 18:28:14 +0000 Received: (qmail 73414 invoked by uid 99); 7 Aug 2014 18:27:47 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2014 18:27:47 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 66DCB94A212; Thu, 7 Aug 2014 18:27:47 +0000 (UTC) From: robdouglas To: dev@streams.incubator.apache.org Reply-To: dev@streams.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-streams pull request: Streams 115 Content-Type: text/plain Message-Id: <20140807182747.66DCB94A212@tyr.zones.apache.org> Date: Thu, 7 Aug 2014 18:27:47 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user robdouglas commented on a diff in the pull request: https://github.com/apache/incubator-streams/pull/51#discussion_r15954062 --- Diff: streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java --- @@ -272,12 +210,11 @@ void shutdownAndAwaitTermination(ExecutorService pool) { } } - @Override public void prepare(Object o) { --- End diff -- I'm not sure I agree that using the numericIdsOnly and screenNamesOnly are the best call in the prepare method. Is the goal here to ensure that our "id" list contains nothing but numeric IDs, given the possibility that the list of identifiers that we start with can have both screenNames as well as numeric IDs? If that's the case then I would suggest getting rid of the numericIdsOnly and screenNamesOnly methods and replace them with something like this: '''' @Override public void prepare(Object o) { executor = getExecutor(); try { lock.writeLock().lock(); providerQueue = constructQueue(); } finally { lock.writeLock().unlock(); } Preconditions.checkNotNull(providerQueue); Preconditions.checkNotNull(this.klass); Preconditions.checkNotNull(config.getOauth().getConsumerKey()); Preconditions.checkNotNull(config.getOauth().getConsumerSecret()); Preconditions.checkNotNull(config.getOauth().getAccessToken()); Preconditions.checkNotNull(config.getOauth().getAccessTokenSecret()); Preconditions.checkNotNull(config.getInfo()); consolidateToIDs(); } /** * Using the "info" list that is contained in the configuration, ensure that all * account identifiers are converted to IDs (Longs) instead of screenNames (Strings) */ private void consolidateToIDs() { List screenNames = Lists.newArrayList(); ids = Lists.newArrayList(); for(Object account : config.getInfo()) { if(account instanceof String) { screenNames.add((String)account); } else if (account instanceof Long) { ids.add(Long.parseLong(Objects.toString(account, null))); } } // Twitter allows for batches up to 100 per request, but you cannot mix types screenNameBatches = new ArrayList(); while(screenNames.size() >= 100) { screenNameBatches.add(screenNames.subList(0, 100).toArray(new String[0])); screenNames = screenNames.subList(100, screenNames.size()); } if(screenNames.size() > 0) screenNameBatches.add(screenNames.toArray(new String[ids.size()])); Iterator screenNameBatchIterator = screenNameBatches.iterator(); while(screenNameBatchIterator.hasNext()) { Collection batchIds = retrieveIds(screenNameBatchIterator.next()); ids.addAll(batchIds); } } '''' --- 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---