[
https://issues.apache.org/jira/browse/STORM-1511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15151755#comment-15151755
]
ASF GitHub Bot commented on STORM-1511:
---------------------------------------
Github user vesense commented on a diff in the pull request:
https://github.com/apache/storm/pull/1118#discussion_r53272946
--- Diff:
examples/storm-starter/src/jvm/org/apache/storm/starter/spout/RandomNumberGeneratorSpout.java
---
@@ -0,0 +1,95 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.storm.starter.spout;
+
+import org.apache.storm.Config;
+import org.apache.storm.task.TopologyContext;
+import org.apache.storm.trident.operation.TridentCollector;
+import org.apache.storm.trident.spout.IBatchSpout;
+import org.apache.storm.tuple.Fields;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * This spout generates random whole numbers with given {@code maxNumber}
value as maximum with the given {@code fields}.
+ *
+ */
+public class RandomNumberGeneratorSpout implements IBatchSpout {
+ private final Fields fields;
+ private final int batchSize;
+ private final int maxNumber;
+ private final Map<Long, List<List<Object>>> batches = new HashMap<>();
+
+ public RandomNumberGeneratorSpout(Fields fields, int batchSize, int
maxNumber) {
+ this.fields = fields;
+ this.batchSize = batchSize;
+ this.maxNumber = maxNumber;
+ }
+
+ @Override
+ public void open(Map conf, TopologyContext context) {
+ }
+
+ @Override
+ public void emitBatch(long batchId, TridentCollector collector) {
+ List<List<Object>> values = null;
+ if(batches.containsKey(batchId)) {
+ values = batches.get(batchId);
+ } else {
+ values = new ArrayList<>();
+ for (int i = 0; i < batchSize; i++) {
+ List<Object> numbers = new ArrayList<>();
+ for (int x=0; x<fields.size(); x++) {
--- End diff --
minor. space: `x < fields.size()`
> min/max operations on trident stream
> ------------------------------------
>
> Key: STORM-1511
> URL: https://issues.apache.org/jira/browse/STORM-1511
> Project: Apache Storm
> Issue Type: Improvement
> Components: storm-core
> Reporter: Satish Duggana
> Assignee: Satish Duggana
> Fix For: 1.0.0
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)