Search in sources :

Example 61 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class QuerierTest method make.

private static Querier make(Querier.Mode mode, String id, String query, Map<String, Object> configuration) {
    BulletConfig config = new BulletConfig();
    configuration.forEach(config::set);
    config.validate();
    return make(mode, id, query, config);
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig)

Example 62 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class QuerierTest method testAdditiveWindowsResetInPartitionMode.

@Test
public void testAdditiveWindowsResetInPartitionMode() {
    BulletConfig config = new BulletConfig();
    RunningQuery runningQuery = makeCountQueryWithAllWindow(config, 2000);
    Querier querier = new Querier(Querier.Mode.PARTITION, runningQuery, config);
    querier.initialize();
    Assert.assertFalse(querier.isClosed());
    Assert.assertTrue(querier.shouldBuffer());
    Assert.assertEquals(querier.getWindow().getClass(), AdditiveTumbling.class);
    IntStream.range(0, 10).forEach(i -> querier.consume(RecordBox.get().getRecord()));
    Assert.assertFalse(querier.isClosed());
    List<BulletRecord> result = querier.getResult().getRecords();
    Assert.assertEquals(result.size(), 1);
    BulletRecord record = result.get(0);
    Assert.assertEquals(record.get(GroupOperation.GroupOperationType.COUNT.getName()), 10L);
    IntStream.range(0, 10).forEach(i -> querier.consume(RecordBox.get().getRecord()));
    result = querier.getResult().getRecords();
    Assert.assertEquals(result.size(), 1);
    record = result.get(0);
    Assert.assertEquals(record.get(GroupOperation.GroupOperationType.COUNT.getName()), 20L);
    // This will reset
    querier.reset();
    IntStream.range(0, 5).forEach(i -> querier.consume(RecordBox.get().getRecord()));
    result = querier.getResult().getRecords();
    Assert.assertEquals(result.size(), 1);
    record = result.get(0);
    Assert.assertEquals(record.get(GroupOperation.GroupOperationType.COUNT.getName()), 5L);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 63 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class QuerierTest method testRateLimitDisabled.

@Test
public void testRateLimitDisabled() {
    BulletConfig config = new BulletConfig();
    config.set(BulletConfig.RATE_LIMIT_ENABLE, false);
    config.set(BulletConfig.RATE_LIMIT_TIME_INTERVAL, 1);
    config.set(BulletConfig.RATE_LIMIT_MAX_EMIT_COUNT, 1);
    config.validate();
    Querier querier = make(Querier.Mode.ALL, "", "{}", config);
    IntStream.range(0, 1000).forEach(i -> querier.getRecords());
    Assert.assertFalse(querier.isExceedingRateLimit());
    Assert.assertNull(querier.getRateLimitError());
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 64 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class QuerierTest method testExceptionWrapping.

@Test
public void testExceptionWrapping() {
    FailingScheme failingScheme = new FailingScheme(null, null, new BulletConfig());
    Querier querier = make(Querier.Mode.ALL, new Query());
    querier.setWindow(failingScheme);
    querier.consume(RecordBox.get().getRecord());
    querier.combine(new byte[0]);
    Assert.assertNull(querier.getData());
    Assert.assertNull(querier.getRecords());
    Meta meta = querier.getMetadata();
    Map<String, Object> actualMeta = meta.asMap();
    Assert.assertNotNull(actualMeta.get(Meta.ERROR_KEY));
    BulletError expected = BulletError.makeError("Getting metadata failure", Querier.TRY_AGAIN_LATER);
    Assert.assertEquals(actualMeta.get(Meta.ERROR_KEY), singletonList(expected));
    Clip actual = querier.getResult();
    Assert.assertNotNull(actual.getMeta());
    Assert.assertEquals(actual.getRecords().size(), 0);
    actualMeta = actual.getMeta().asMap();
    Assert.assertEquals(actualMeta.size(), 1);
    Assert.assertNotNull(actualMeta.get(Meta.ERROR_KEY));
    expected = BulletError.makeError("Getting result failure", Querier.TRY_AGAIN_LATER);
    Assert.assertEquals(actualMeta.get(Meta.ERROR_KEY), singletonList(expected));
    Assert.assertEquals(failingScheme.consumptionFailure, 1);
    Assert.assertEquals(failingScheme.combiningFailure, 1);
    Assert.assertEquals(failingScheme.serializingFailure, 1);
    Assert.assertEquals(failingScheme.aggregationFailure, 3);
}
Also used : Clip(com.yahoo.bullet.result.Clip) Meta(com.yahoo.bullet.result.Meta) QueryUtils.makeAggregationQuery(com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery) QueryUtils.makeProjectionFilterQuery(com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery) QueryUtils.makeRawFullQuery(com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery) Query(com.yahoo.bullet.parsing.Query) BulletError(com.yahoo.bullet.common.BulletError) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 65 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class QuerierTest method testRawQueriesWithNonReactiveWindowsAreErrors.

@Test
public void testRawQueriesWithNonReactiveWindowsAreErrors() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    query.setWindow(WindowUtils.makeWindow(Window.Unit.RECORD, 2));
    query.configure(config);
    Querier querier = new Querier(new RunningQuery("", query), config);
    Optional<List<BulletError>> errors = querier.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.NOT_ONE_RECORD_EMIT));
}
Also used : QueryUtils.makeAggregationQuery(com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery) QueryUtils.makeProjectionFilterQuery(com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery) QueryUtils.makeRawFullQuery(com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery) Query(com.yahoo.bullet.parsing.Query) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Booleans.asList(com.google.common.primitives.Booleans.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) 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