use of com.yahoo.bullet.result.Clip in project bullet-core by yahoo.
the class FrequentItemsSketch method getResult.
@Override
public Clip getResult(String metaKey, Map<String, String> conceptKeys) {
Clip data = super.getResult(metaKey, conceptKeys);
data.add(getRecords());
return data;
}
use of com.yahoo.bullet.result.Clip in project bullet-core by yahoo.
the class QuerierTest method testTimes.
@Test
public void testTimes() {
BulletConfig defaults = new BulletConfig();
Map<String, String> names = (Map<String, String>) defaults.get(BulletConfig.RESULT_METADATA_METRICS);
long startTime = System.currentTimeMillis();
Querier querier = make(Querier.Mode.ALL, "", "{'aggregation' : {}}", emptyMap());
Map<String, Object> meta = querier.getMetadata().asMap();
Assert.assertEquals(meta.size(), 2);
Map<String, Object> queryMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.QUERY_METADATA.getName()));
Map<String, Object> windowMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.WINDOW_METADATA.getName()));
long creationTime = ((Number) queryMeta.get(names.get(Meta.Concept.QUERY_RECEIVE_TIME.getName()))).longValue();
long emitTime = ((Number) windowMeta.get(names.get(Meta.Concept.WINDOW_EMIT_TIME.getName()))).longValue();
long endTime = System.currentTimeMillis();
Assert.assertTrue(creationTime >= startTime && creationTime <= endTime);
Assert.assertTrue(emitTime >= startTime && emitTime <= endTime);
Clip finalResult = querier.finish();
Assert.assertNotNull(finalResult);
Assert.assertTrue(finalResult.getRecords().isEmpty());
meta = finalResult.getMeta().asMap();
queryMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.QUERY_METADATA.getName()));
windowMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.WINDOW_METADATA.getName()));
creationTime = ((Number) queryMeta.get(names.get(Meta.Concept.QUERY_RECEIVE_TIME.getName()))).longValue();
emitTime = ((Number) windowMeta.get(names.get(Meta.Concept.WINDOW_EMIT_TIME.getName()))).longValue();
long finishTime = ((Number) queryMeta.get(names.get(Meta.Concept.QUERY_FINISH_TIME.getName()))).longValue();
endTime = System.currentTimeMillis();
Assert.assertTrue(creationTime >= startTime && creationTime <= finishTime);
Assert.assertTrue(emitTime >= startTime && emitTime <= finishTime);
Assert.assertTrue(finishTime <= endTime);
}
use of com.yahoo.bullet.result.Clip in project bullet-core by yahoo.
the class QuerierTest method testDisabledQueryMeta.
@Test
public void testDisabledQueryMeta() {
BulletConfig defaults = new BulletConfig();
defaults.set(BulletConfig.RESULT_METADATA_METRICS, emptyMap());
Querier querier = make(Querier.Mode.ALL, "", "{'aggregation' : {}}", defaults);
Assert.assertTrue(querier.getMetadata().asMap().isEmpty());
Clip result = querier.finish();
Assert.assertNotNull(result);
Assert.assertTrue(result.getRecords().isEmpty());
Assert.assertTrue(result.getMeta().asMap().isEmpty());
}
use of com.yahoo.bullet.result.Clip in project bullet-storm by yahoo.
the class JoinBolt method emitRateLimitError.
private void emitRateLimitError(String id, Querier querier, RateLimitError error) {
Metadata metadata = bufferedMetadata.get(id);
Meta meta = error.makeMeta();
Clip clip = querier.finish();
clip.getMeta().merge(meta);
emitResult(id, withSignal(metadata, Metadata.Signal.FAIL), clip);
emitMetaSignal(id, Metadata.Signal.KILL);
updateCount(rateExceededQueries, 1L);
removeQuery(id);
}
use of com.yahoo.bullet.result.Clip in project bullet-core by yahoo.
the class FrequentItemsSketchTest method testUnioning.
@Test
public void testUnioning() {
FrequentItemsSketch sketch = new FrequentItemsSketch(ErrorType.NO_FALSE_NEGATIVES, 32, 32);
IntStream.range(0, 10).forEach(i -> IntStream.range(0, 10).forEach(j -> sketch.update(String.valueOf(i))));
IntStream.range(10, 100).forEach(i -> sketch.update("bar"));
FrequentItemsSketch another = new FrequentItemsSketch(ErrorType.NO_FALSE_NEGATIVES, 32, 32);
another.update("foo");
another.update("bar");
another.update("baz");
FrequentItemsSketch union = new FrequentItemsSketch(ErrorType.NO_FALSE_NEGATIVES, 32, 32);
union.union(sketch.serialize());
union.union(another.serialize());
Clip result = union.getResult("meta", ALL_METADATA);
Map<String, Object> metadata = (Map<String, Object>) result.getMeta().asMap().get("meta");
Assert.assertEquals(metadata.size(), 5);
Assert.assertFalse((Boolean) metadata.get("isEst"));
List<BulletRecord> records = result.getRecords();
Assert.assertEquals(records.size(), 13);
for (BulletRecord actual : records) {
String item = actual.get(FrequentItemsSketch.ITEM_FIELD).toString();
Assert.assertEquals(actual.fieldCount(), 2);
if ("bar".equals(item)) {
Assert.assertEquals(actual.get(FrequentItemsSketch.COUNT_FIELD), 91L);
} else if ("foo".equals(item) || "baz".equals(item)) {
Assert.assertEquals(actual.get(FrequentItemsSketch.COUNT_FIELD), 1L);
} else if (Integer.valueOf(item) < 10) {
Assert.assertEquals(actual.get(FrequentItemsSketch.COUNT_FIELD), 10L);
} else {
Assert.fail("This should not be a case");
}
}
Assert.assertEquals(union.getRecords(), records);
Assert.assertEquals(union.getMetadata("meta", ALL_METADATA).asMap(), result.getMeta().asMap());
}
Aggregations