@Override public List<BulletRecord> getRecords() { List<BulletRecord> result = super.getRecords(); renameFields(result); return result; }
@Override public void reset() { aggregation.reset(); windowCount++; }
@Override public List<BulletRecord> getRecords() { return renameInPlace(super.getRecords()); }
/** * Returns a new {@link Strategy} instance that can handle this aggregation. * * @param aggregation The non-null, initialized {@link Aggregation} instance. * @param config The {@link BulletConfig} containing configuration for the strategy. * * @return The created instance of a strategy that can implement the Aggregation. */ public static Strategy findStrategy(Aggregation aggregation, BulletConfig config) { // Guaranteed to be present. switch (aggregation.getType()) { case COUNT_DISTINCT: return new CountDistinct(aggregation, config); case DISTRIBUTION: return new Distribution(aggregation, config); case RAW: return new Raw(aggregation, config); case TOP_K: return new TopK(aggregation, config); } // If we have any fields -> GroupBy return Utilities.isEmpty(aggregation.getFields()) ? new GroupAll(aggregation, config) : new GroupBy(aggregation, config); } }
@Override public void consume(BulletRecord data) { sketch.update(composeField(data)); }
@Override public void consume(BulletRecord data) { String field = composeField(data); sketch.update(field); }
@Override public Clip getResult() { Clip result = super.getResult(); renameInPlace(result.getRecords()); return result; }
@Override public Clip getResult() { Clip result = super.getResult(); renameFields(result.getRecords()); return result; }
@Override public boolean isClosed() { return aggregation.isClosed(); }
/** * This consumes any data fed to it even if it is {@link #isClosed()} or {@link #isClosedForPartition()}. * * @param data The {@link BulletRecord} to consume. */ @Override public void consume(BulletRecord data) { aggregation.consume(data); }
/** * This combines any data fed to it even if it is {@link #isClosed()} or {@link #isClosedForPartition()}. * * @param data The {@link BulletRecord} to consume. */ @Override public void combine(byte[] data) { aggregation.combine(data); }
@Override public List<BulletRecord> getRecords() { return aggregation.getRecords(); }
@Override public byte[] getData() { return aggregation.getData(); }
@Override public List<BulletRecord> getRecords() { List<BulletRecord> records = super.getRecords(); records.forEach(this::splitFields); return records; }
@Override public void consume(BulletRecord data) { // Since Raw is the only strategy that can close and is really a special case, it should check before // consumption. Otherwise, Windows will need to expose the fact that the aggregation should not be fed more data // in order to prevent Raw from accidentally consuming/combining till only the Window is closed. if (data == null || isClosed()) { return; } consumed++; aggregate.add(data); }
/** * Gets the aggregated records so far since the last call to {@link #reset()}. The records have a size that is at * most the maximum specified by the {@link Aggregation}. * * @return a {@link Clip} of the records so far. */ @Override public Clip getResult() { return Clip.of(getRecords()); }
/** * Converts a integer representing the resizing for Sketches into a {@link ResizeFactor}. * * @param config The config that has relevant configs for this strategy. * @param key The key to get the configured resize factor from the configuration. * @return A {@link ResizeFactor} represented by the integer or {@link ResizeFactor#X8} otherwise. */ @SuppressWarnings("unchecked") ResizeFactor getResizeFactor(BulletConfig config, String key) { return getResizeFactor(config.getAs(key, Integer.class)); } /**
@Override public Clip getResult() { return Clip.of(getRecords()); }
@Override public void resetForPartition() { // Do reset the strategy. aggregation.reset(); reset(); } }
@Override public boolean isClosedForPartition() { return aggregation.isClosed(); }