@Override public void consume(BulletRecord data) { sketch.update(composeField(data)); }
@Override public Clip getResult(String metaKey, Map<String, String> conceptKeys) { Clip data = super.getResult(metaKey, conceptKeys); data.add(getRecords()); return data; }
/** * Constructor that requires an {@link Aggregation} and a {@link BulletConfig} configuration. * * @param aggregation An {@link Aggregation} with valid fields and attributes for this aggregation type. * @param config The config that has relevant configs for this strategy. */ @SuppressWarnings("unchecked") public TopK(Aggregation aggregation, BulletConfig config) { super(aggregation, config); String errorConfiguration = config.getAs(BulletConfig.TOP_K_AGGREGATION_SKETCH_ERROR_TYPE, String.class); ErrorType errorType = getErrorType(errorConfiguration); Map<String, Object> attributes = aggregation.getAttributes(); newName = attributes == null ? DEFAULT_NEW_NAME : attributes.getOrDefault(NEW_NAME_FIELD, DEFAULT_NEW_NAME).toString(); int maxMapSize = config.getAs(BulletConfig.TOP_K_AGGREGATION_SKETCH_ENTRIES, Integer.class); Number threshold = getThreshold(attributes); int size = aggregation.getSize(); BulletRecordProvider provider = config.getBulletRecordProvider(); sketch = threshold != null ? new FrequentItemsSketch(errorType, maxMapSize, threshold.longValue(), size, provider) : new FrequentItemsSketch(errorType, maxMapSize, size, provider); }