Skip to content

Commit bf2ac73

Browse files
committed
Fixing settings and removing map reuse
1 parent 24993e2 commit bf2ac73

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

docs/quick-start.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,18 @@ cp $BULLET_EXAMPLES/storm/src/main/resources/bullet_settings.yaml $BULLET_HOME/b
100100

101101
!!! note "Settings"
102102

103-
Take a look at bullet_settings.yaml for the settings that are being overridden for this example. You can add or change settings as you like by referring to [bullet_defaults.yaml](https://github.com/yahoo/bullet-storm/blob/master/src/main/resources/bullet_defaults.yaml).
103+
Take a look at bullet_settings.yaml for the settings that are being overridden for this example. You can add or change settings as you like by referring to [bullet_defaults.yaml](https://github.com/yahoo/bullet-storm/blob/master/src/main/resources/bullet_defaults.yaml). In particular, we
104+
have customized these settings that affect the Bullet queries you can run:
105+
106+
```bullet.rule.max.duration: 570000``` Longest query time can be 570s. The Storm cluster default DRPC timeout is 600s.
107+
108+
```bullet.rule.aggregation.raw.max.size: 500``` The max ```RAW``` records you can fetch is 500.
109+
110+
```bullet.rule.aggregation.max.size: 1024``` The max records you can fetch for any query is 1024.
111+
112+
```bullet.rule.aggregation.count.distinct.sketch.entries: 16384``` We can count 16384 unique values exactly. Approximates after.
113+
114+
```bullet.rule.aggregation.group.sketch.entries: 1024``` The max unique groups can be 1024. Uniform sample after.
104115

105116
#### Step 6: Launch the topology
106117

@@ -273,28 +284,27 @@ This method above emits the tuples. The Storm framework calls this method. This
273284
booleanMap.put(uuid.substring(19, 23), random.nextBoolean());
274285
record.setBooleanMap(BOOLEAN_MAP, booleanMap);
275286

276-
STATS_MAP_VALUE.put(PERIOD_COUNT, periodCount);
277-
STATS_MAP_VALUE.put(RECORD_NUMBER, periodCount * maxPerPeriod + generatedThisPeriod);
278-
STATS_MAP_VALUE.put(NANO_TIME, System.nanoTime());
279-
STATS_MAP_VALUE.put(TIMESTAMP, System.currentTimeMillis());
280-
record.setLongMap(STATS_MAP, STATS_MAP_VALUE);
281-
282-
RANDOM_MAP_VALUE_A.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
283-
RANDOM_MAP_VALUE_A.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
284-
RANDOM_MAP_VALUE_B.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
285-
RANDOM_MAP_VALUE_B.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
286-
record.setListOfStringMap(LIST, asList(RANDOM_MAP_VALUE_A, RANDOM_MAP_VALUE_B));
287+
Map<String, Long> statsMap = new HashMap<>(4);
288+
statsMap.put(PERIOD_COUNT, periodCount);
289+
statsMap.put(RECORD_NUMBER, periodCount * maxPerPeriod + generatedThisPeriod);
290+
statsMap.put(NANO_TIME, System.nanoTime());
291+
statsMap.put(TIMESTAMP, System.currentTimeMillis());
292+
record.setLongMap(STATS_MAP, statsMap);
293+
294+
Map<String, String> randomMapA = new HashMap<>(2);
295+
Map<String, String> randomMapB = new HashMap<>(2);
296+
randomMapA.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
297+
randomMapA.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
298+
randomMapB.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
299+
randomMapB.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
300+
record.setListOfStringMap(LIST, asList(randomMapA, randomMapB));
287301

288302
return record;
289303
}
290304
```
291305

292306
This method generates some fields randomly and inserts them into a BulletRecord. Note that the BulletRecord is typed and all data must be inserted with the proper types. If you put Bullet on your data, you will need to write a Spout (or a topology if your reading is complex), that reads from your data source and emits BulletRecords with the fields you wish to be queryable placed into a BulletRecord.
293307

294-
!!! note "Reusing Maps?"
295-
296-
There is no need to reuse maps. This example tries to be as efficient as possible in order to allow variable throughputs.
297-
298308
### Web Service
299309

300310
We launched the Web Service using two custom files - a properties file and JSON schema file.

examples/storm/src/main/java/com/yahoo/bullet/storm/examples/RandomSpout.java

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,6 @@ public class RandomSpout extends BaseRichSpout {
6666

6767
// Some static values in BulletRecord for the fields
6868
public static final String[] STRING_POOL = { "foo", "bar", "baz", "qux", "quux", "norf" };
69-
public static final Map<String, Long> STATS_MAP_VALUE = new HashMap<>();
70-
static {
71-
STATS_MAP_VALUE.put(PERIOD_COUNT, null);
72-
STATS_MAP_VALUE.put(RECORD_NUMBER, null);
73-
STATS_MAP_VALUE.put(NANO_TIME, null);
74-
STATS_MAP_VALUE.put(TIMESTAMP, null);
75-
}
76-
public static final Map<String, String> RANDOM_MAP_VALUE_A = new HashMap<>();
77-
public static final Map<String, String> RANDOM_MAP_VALUE_B = new HashMap<>();
78-
static {
79-
RANDOM_MAP_VALUE_A.put(RANDOM_MAP_KEY_A, null);
80-
RANDOM_MAP_VALUE_A.put(RANDOM_MAP_KEY_B, null);
81-
RANDOM_MAP_VALUE_B.put(RANDOM_MAP_KEY_A, null);
82-
RANDOM_MAP_VALUE_B.put(RANDOM_MAP_KEY_B, null);
83-
}
8469

8570
/**
8671
* @param args A List of Strings for your Spout. This example takes a number of messages to emit before sleeping and the amount
@@ -162,17 +147,20 @@ private BulletRecord generateRecord() {
162147
booleanMap.put(uuid.substring(19, 23), random.nextBoolean());
163148
record.setBooleanMap(BOOLEAN_MAP, booleanMap);
164149

165-
STATS_MAP_VALUE.put(PERIOD_COUNT, periodCount);
166-
STATS_MAP_VALUE.put(RECORD_NUMBER, periodCount * maxPerPeriod + generatedThisPeriod);
167-
STATS_MAP_VALUE.put(NANO_TIME, System.nanoTime());
168-
STATS_MAP_VALUE.put(TIMESTAMP, System.currentTimeMillis());
169-
record.setLongMap(STATS_MAP, STATS_MAP_VALUE);
170-
171-
RANDOM_MAP_VALUE_A.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
172-
RANDOM_MAP_VALUE_A.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
173-
RANDOM_MAP_VALUE_B.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
174-
RANDOM_MAP_VALUE_B.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
175-
record.setListOfStringMap(LIST, asList(RANDOM_MAP_VALUE_A, RANDOM_MAP_VALUE_B));
150+
Map<String, Long> statsMap = new HashMap<>(4);
151+
statsMap.put(PERIOD_COUNT, periodCount);
152+
statsMap.put(RECORD_NUMBER, periodCount * maxPerPeriod + generatedThisPeriod);
153+
statsMap.put(NANO_TIME, System.nanoTime());
154+
statsMap.put(TIMESTAMP, System.currentTimeMillis());
155+
record.setLongMap(STATS_MAP, statsMap);
156+
157+
Map<String, String> randomMapA = new HashMap<>(2);
158+
Map<String, String> randomMapB = new HashMap<>(2);
159+
randomMapA.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
160+
randomMapA.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
161+
randomMapB.put(RANDOM_MAP_KEY_A, STRING_POOL[random.nextInt(STRING_POOL.length)]);
162+
randomMapB.put(RANDOM_MAP_KEY_B, STRING_POOL[random.nextInt(STRING_POOL.length)]);
163+
record.setListOfStringMap(LIST, asList(randomMapA, randomMapB));
176164

177165
return record;
178166
}

examples/storm/src/main/resources/bullet_settings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ bullet.topology.join.bolt.error.tick.timeout: 3
2828
bullet.topology.join.bolt.rule.tick.timeout: 3
2929
bullet.topology.tick.interval.secs: 1
3030
bullet.rule.aggregation.raw.max.size: 500
31+
bullet.rule.aggregation.max.size: 1024
3132
bullet.rule.aggregation.count.distinct.sketch.entries: 16384
3233
bullet.rule.aggregation.group.sketch.entries: 1024
34+
bullet.rule.max.duration: 570000
3335
bullet.result.metadata.enable: true
3436
bullet.result.metadata.metrics:
3537
- name: "Rule Identifier"

0 commit comments

Comments
 (0)