use of com.yahoo.bullet.record.BulletRecordProvider in project bullet-core by yahoo.
the class BulletConfigTest method testGetBulletRecordProvider.
@Test
public void testGetBulletRecordProvider() {
BulletConfig config = new BulletConfig();
BulletRecordProvider providerA = config.getBulletRecordProvider();
BulletRecordProvider providerB = config.getBulletRecordProvider();
// Uses the same provider
Assert.assertSame(providerA, providerB);
}
use of com.yahoo.bullet.record.BulletRecordProvider in project bullet-core by yahoo.
the class BulletConfigTest method testCreateBulletRecordProvider.
@Test
public void testCreateBulletRecordProvider() {
BulletConfig config = new BulletConfig();
BulletRecordProvider providerA = config.createBulletRecordProvider();
BulletRecordProvider providerB = config.createBulletRecordProvider();
// Creates a new provider each time
Assert.assertNotSame(providerA, providerB);
// Ensure the provider generates new records each time
BulletRecord recordA = providerA.getInstance();
BulletRecord recordB = providerA.getInstance();
Assert.assertNotNull(recordA);
Assert.assertNotNull(recordB);
recordB.setString("someField", "someValue");
Assert.assertEquals(recordB.typedGet("someField"), new TypedObject(Type.STRING, "someValue"));
Assert.assertTrue(recordA.typedGet("someField").isNull());
}
use of com.yahoo.bullet.record.BulletRecordProvider in project bullet-core by yahoo.
the class QuantileSketchingStrategy method getSketch.
private static QuantileSketch getSketch(Distribution aggregation, BulletConfig config) {
int entries = config.getAs(BulletConfig.DISTRIBUTION_AGGREGATION_SKETCH_ENTRIES, Integer.class);
int rounding = config.getAs(BulletConfig.DISTRIBUTION_AGGREGATION_GENERATED_POINTS_ROUNDING, Integer.class);
int pointLimit = config.getAs(BulletConfig.DISTRIBUTION_AGGREGATION_MAX_POINTS, Integer.class);
int maxPoints = Math.min(pointLimit, aggregation.getSize());
BulletRecordProvider provider = config.getBulletRecordProvider();
if (aggregation instanceof LinearDistribution) {
int numberOfPoints = ((LinearDistribution) aggregation).getNumberOfPoints();
return new QuantileSketch(entries, rounding, aggregation.getDistributionType(), Math.min(numberOfPoints, maxPoints), provider);
} else if (aggregation instanceof ManualDistribution) {
// Limit number of points
List<Double> points = ((ManualDistribution) aggregation).getPoints();
double[] cleanedPoints = points.stream().limit(maxPoints).mapToDouble(d -> d).toArray();
return new QuantileSketch(entries, aggregation.getDistributionType(), cleanedPoints, provider);
} else if (aggregation instanceof RegionDistribution) {
RegionDistribution distribution = (RegionDistribution) aggregation;
double start = distribution.getStart();
double end = distribution.getEnd();
double increment = distribution.getIncrement();
return new QuantileSketch(entries, aggregation.getDistributionType(), getPoints(start, end, increment, maxPoints, rounding), provider);
}
throw new IllegalArgumentException("Unknown distribution input mode.");
}
use of com.yahoo.bullet.record.BulletRecordProvider in project bullet-core by yahoo.
the class ExplodeFunctor method explodeMap.
private List<BulletRecord> explodeMap(BulletRecord record, BulletRecordProvider provider) {
TypedObject typedObject = getField(record);
if (!typedObject.isMap() || typedObject.size() == 0) {
return Collections.emptyList();
}
Map<String, Serializable> map = (Map<String, Serializable>) typedObject.getValue();
return map.entrySet().stream().map(entry -> getRecord(entry, provider)).collect(Collectors.toList());
}
use of com.yahoo.bullet.record.BulletRecordProvider in project bullet-core by yahoo.
the class ExplodeFunctor method explodeList.
private List<BulletRecord> explodeList(BulletRecord record, BulletRecordProvider provider) {
TypedObject typedObject = getField(record);
if (!typedObject.isList() || typedObject.size() == 0) {
return Collections.emptyList();
}
List<Serializable> list = (List<Serializable>) typedObject.getValue();
return list.stream().map(object -> getRecord(object, provider)).collect(Collectors.toList());
}
Aggregations