Search in sources :

Example 6 with BulletConfig

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;
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig)

Example 7 with BulletConfig

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());
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) HashMap(java.util.HashMap) Arrays.asList(java.util.Arrays.asList) List(java.util.List) BulletError(com.yahoo.bullet.common.BulletError) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 8 with BulletConfig

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());
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) Arrays.asList(java.util.Arrays.asList) List(java.util.List) BulletError(com.yahoo.bullet.common.BulletError) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 9 with BulletConfig

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;
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig)

Example 10 with BulletConfig

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);
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Aggregations

BulletConfig (com.yahoo.bullet.common.BulletConfig)101 Test (org.testng.annotations.Test)87 Aggregation (com.yahoo.bullet.parsing.Aggregation)37 List (java.util.List)25 Query (com.yahoo.bullet.parsing.Query)20 QueryUtils.makeAggregationQuery (com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery)17 BulletError (com.yahoo.bullet.common.BulletError)16 BulletRecord (com.yahoo.bullet.record.BulletRecord)16 Arrays.asList (java.util.Arrays.asList)16 Clip (com.yahoo.bullet.result.Clip)14 Collections.singletonList (java.util.Collections.singletonList)12 QueryUtils.makeProjectionFilterQuery (com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery)11 QueryUtils.makeRawFullQuery (com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery)11 Map (java.util.Map)11 AggregationUtils.makeAttributes (com.yahoo.bullet.parsing.AggregationUtils.makeAttributes)10 Window (com.yahoo.bullet.parsing.Window)10 Concept (com.yahoo.bullet.result.Meta.Concept)10 RecordBox (com.yahoo.bullet.result.RecordBox)10 ArrayList (java.util.ArrayList)10 IntStream (java.util.stream.IntStream)10