Github user Ethanlm commented on a diff in the pull request:
https://github.com/apache/storm/pull/2641#discussion_r183400894
--- Diff:
examples/storm-perf/src/main/java/org/apache/storm/perf/spout/StringGenSpout.java
---
@@ -22,33 +22,40 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-
import org.apache.commons.lang.RandomStringUtils;
import org.apache.storm.spout.SpoutOutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseRichSpout;
import org.apache.storm.tuple.Fields;
-/** Spout pre-computes a list with 30k fixed length random strings.
- * Emits sequentially from this list, over and over again.
+/**
+ * Spout pre-computes a list with 30k fixed length random strings. Emits
sequentially from this list, over and over again.
*/
public class StringGenSpout extends BaseRichSpout {
private static final String DEFAULT_FIELD_NAME = "str";
- private int strLen;
private final int strCount = 30_000;
+ ArrayList<String> records;
+ private int strLen;
private String fieldName = DEFAULT_FIELD_NAME;
private SpoutOutputCollector collector = null;
- ArrayList<String> records;
private int curr = 0;
private int count = 0;
public StringGenSpout(int strLen) {
this.strLen = strLen;
}
+ private static ArrayList<String> genStringList(int strLen, int count) {
+ ArrayList<String> result = new ArrayList<String>(count);
+ for (int i = 0; i < count; i++) {
+ result.add(RandomStringUtils.random(strLen));
+ }
+ return result;
+ }
+
--- End diff --
It looks like you just moved the location of the function. Is there any
particular reason to do it?
---