use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class CountDistinctTest method makeConfiguration.
public static BulletConfig makeConfiguration(int resizeFactor, float sampling, String family, String separator, int k) {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.COUNT_DISTINCT_AGGREGATION_SKETCH_ENTRIES, k);
config.set(BulletConfig.COUNT_DISTINCT_AGGREGATION_SKETCH_RESIZE_FACTOR, resizeFactor);
config.set(BulletConfig.COUNT_DISTINCT_AGGREGATION_SKETCH_FAMILY, family);
config.set(BulletConfig.COUNT_DISTINCT_AGGREGATION_SKETCH_SAMPLING, sampling);
config.set(BulletConfig.AGGREGATION_COMPOSITE_FIELD_SEPARATOR, separator);
return config;
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class DistributionTest method testInitialize.
@Test
public void testInitialize() {
Optional<List<BulletError>> optionalErrors;
List<BulletError> errors;
Aggregation aggregation = new Aggregation();
aggregation.setSize(20);
Distribution distribution = new Distribution(aggregation, new BulletConfig());
optionalErrors = distribution.initialize();
Assert.assertTrue(optionalErrors.isPresent());
errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 1);
Assert.assertEquals(errors.get(0), Distribution.REQUIRES_ONE_FIELD_ERROR);
aggregation.setFields(Collections.singletonMap("foo", "bar"));
distribution = new Distribution(aggregation, new BulletConfig());
optionalErrors = distribution.initialize();
Assert.assertTrue(optionalErrors.isPresent());
errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 1);
Assert.assertEquals(errors.get(0), Distribution.REQUIRES_TYPE_ERROR);
aggregation.setAttributes(Collections.singletonMap(Distribution.TYPE, "foo"));
distribution = new Distribution(aggregation, new BulletConfig());
optionalErrors = distribution.initialize();
Assert.assertTrue(optionalErrors.isPresent());
errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 1);
Assert.assertEquals(errors.get(0), Distribution.REQUIRES_TYPE_ERROR);
Map<String, Object> attributes = new HashMap<>();
attributes.put(Distribution.TYPE, Distribution.Type.CDF.getName());
attributes.put(Distribution.NUMBER_OF_POINTS, 10L);
aggregation.setAttributes(attributes);
distribution = new Distribution(aggregation, new BulletConfig());
Assert.assertFalse(distribution.initialize().isPresent());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class DistributionTest method testProvidedPointsInitialization.
@Test
public void testProvidedPointsInitialization() {
Aggregation aggregation = new Aggregation();
aggregation.setSize(20);
aggregation.setFields(Collections.singletonMap("foo", "bar"));
Distribution distribution = new Distribution(aggregation, new BulletConfig());
Optional<List<BulletError>> optionalErrors;
List<BulletError> errors;
aggregation.setAttributes(makeAttributes(Distribution.Type.QUANTILE, asList(0.4, 0.03, 0.99, 0.5, 14.0)));
optionalErrors = distribution.initialize();
Assert.assertTrue(optionalErrors.isPresent());
errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 2);
Assert.assertEquals(errors.get(0), Distribution.REQUIRES_POINTS_ERROR);
Assert.assertEquals(errors.get(1), Distribution.REQUIRES_POINTS_PROPER_RANGE);
aggregation.setAttributes(makeAttributes(Distribution.Type.QUANTILE, null));
optionalErrors = distribution.initialize();
Assert.assertTrue(optionalErrors.isPresent());
errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 2);
Assert.assertEquals(errors.get(0), Distribution.REQUIRES_POINTS_ERROR);
Assert.assertEquals(errors.get(1), Distribution.REQUIRES_POINTS_PROPER_RANGE);
aggregation.setAttributes(makeAttributes(Distribution.Type.QUANTILE, Collections.emptyList()));
optionalErrors = distribution.initialize();
Assert.assertTrue(optionalErrors.isPresent());
errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 2);
Assert.assertEquals(errors.get(0), Distribution.REQUIRES_POINTS_ERROR);
Assert.assertEquals(errors.get(1), Distribution.REQUIRES_POINTS_PROPER_RANGE);
aggregation.setAttributes(makeAttributes(Distribution.Type.QUANTILE, Collections.singletonList(2.0)));
optionalErrors = distribution.initialize();
Assert.assertTrue(optionalErrors.isPresent());
errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 2);
Assert.assertEquals(errors.get(0), Distribution.REQUIRES_POINTS_ERROR);
Assert.assertEquals(errors.get(1), Distribution.REQUIRES_POINTS_PROPER_RANGE);
aggregation.setAttributes(makeAttributes(Distribution.Type.QUANTILE, Collections.singletonList(1.0)));
optionalErrors = distribution.initialize();
Assert.assertFalse(distribution.initialize().isPresent());
aggregation.setAttributes(makeAttributes(Distribution.Type.QUANTILE, asList(0.4, 0.03, 0.99, 0.5, 0.35)));
optionalErrors = distribution.initialize();
Assert.assertFalse(optionalErrors.isPresent());
aggregation.setAttributes(makeAttributes(Distribution.Type.PMF, Collections.singletonList(0.4)));
optionalErrors = distribution.initialize();
Assert.assertFalse(optionalErrors.isPresent());
aggregation.setAttributes(makeAttributes(Distribution.Type.PMF, asList(0.4, 0.03, 0.99, 0.5, 14.0)));
optionalErrors = distribution.initialize();
Assert.assertFalse(optionalErrors.isPresent());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class DistributionTest method makeConfiguration.
public static BulletConfig makeConfiguration(int maxPoints, int k, int rounding) {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.DISTRIBUTION_AGGREGATION_SKETCH_ENTRIES, k);
config.set(BulletConfig.DISTRIBUTION_AGGREGATION_MAX_POINTS, maxPoints);
config.set(BulletConfig.DISTRIBUTION_AGGREGATION_GENERATED_POINTS_ROUNDING, rounding);
return config;
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class AggregationTest method testSize.
@Test
public void testSize() {
Aggregation aggregation = new Aggregation();
BulletConfig config = new BulletConfig();
aggregation.setSize(null);
aggregation.configure(config);
Assert.assertEquals((Object) aggregation.getSize(), BulletConfig.DEFAULT_AGGREGATION_SIZE);
aggregation.setSize(-10);
aggregation.configure(config);
Assert.assertEquals((Object) aggregation.getSize(), BulletConfig.DEFAULT_AGGREGATION_SIZE);
aggregation.setSize(0);
aggregation.configure(config);
Assert.assertEquals((Object) aggregation.getSize(), BulletConfig.DEFAULT_AGGREGATION_SIZE);
aggregation.setSize(1);
aggregation.configure(config);
Assert.assertEquals(aggregation.getSize(), (Integer) 1);
aggregation.setSize(BulletConfig.DEFAULT_AGGREGATION_SIZE);
aggregation.configure(config);
Assert.assertEquals((Object) aggregation.getSize(), BulletConfig.DEFAULT_AGGREGATION_SIZE);
aggregation.setSize(BulletConfig.DEFAULT_AGGREGATION_MAX_SIZE + 1);
aggregation.configure(config);
Assert.assertEquals((Object) aggregation.getSize(), BulletConfig.DEFAULT_AGGREGATION_MAX_SIZE);
}
Aggregations