fix last merge from master not being forward-compatible

This commit is contained in:
Xavier Léauté 2014-08-30 22:45:36 -07:00
parent 508e982190
commit 75134335de
3 changed files with 78 additions and 71 deletions

View File

@ -33,6 +33,8 @@ import org.joda.time.Interval;
import org.joda.time.Period;
import java.util.Arrays;
import java.util.Map;
/**
* TimewarpOperator is an example post-processing operator that maps current time
@ -79,7 +81,7 @@ public class TimewarpOperator<T> implements PostProcessingOperator<T>
return new QueryRunner<T>()
{
@Override
public Sequence<T> run(final Query<T> query)
public Sequence<T> run(final Query<T> query, final Map<String, Object> context)
{
final long offset = computeOffset(now);
@ -90,7 +92,8 @@ public class TimewarpOperator<T> implements PostProcessingOperator<T>
);
return Sequences.map(
baseRunner.run(
query.withQuerySegmentSpec(new MultipleIntervalSegmentSpec(Arrays.asList(modifiedInterval)))
query.withQuerySegmentSpec(new MultipleIntervalSegmentSpec(Arrays.asList(modifiedInterval))),
context
),
new Function<T, T>()
{

View File

@ -35,9 +35,13 @@ import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.Map;
public class TimewarpOperatorTest
{
public static final ImmutableMap<String, Object> CONTEXT = ImmutableMap.of();
TimewarpOperator<Result<TimeseriesResultValue>> testOperator = new TimewarpOperator<>(
new Interval(new DateTime("2014-01-01"), new DateTime("2014-01-15")),
new Period("P1W"),
@ -75,7 +79,7 @@ public class TimewarpOperatorTest
new QueryRunner<Result<TimeseriesResultValue>>()
{
@Override
public Sequence<Result<TimeseriesResultValue>> run(Query<Result<TimeseriesResultValue>> query)
public Sequence<Result<TimeseriesResultValue>> run(Query<Result<TimeseriesResultValue>> query, Map<String, Object> context)
{
return Sequences.simple(
ImmutableList.of(
@ -120,7 +124,7 @@ public class TimewarpOperatorTest
new TimeseriesResultValue(ImmutableMap.<String, Object>of("metric", 5))
)
),
Sequences.toList(queryRunner.run(query), Lists.<Result<TimeseriesResultValue>>newArrayList())
Sequences.toList(queryRunner.run(query, CONTEXT), Lists.<Result<TimeseriesResultValue>>newArrayList())
);
@ -134,7 +138,7 @@ public class TimewarpOperatorTest
new QueryRunner<Result<TimeBoundaryResultValue>>()
{
@Override
public Sequence<Result<TimeBoundaryResultValue>> run(Query<Result<TimeBoundaryResultValue>> query)
public Sequence<Result<TimeBoundaryResultValue>> run(Query<Result<TimeBoundaryResultValue>> query, Map<String, Object> context)
{
return Sequences.simple(
ImmutableList.of(
@ -161,7 +165,7 @@ public class TimewarpOperatorTest
new TimeBoundaryResultValue(ImmutableMap.<String, Object>of("maxTime", new DateTime("2014-08-02")))
)
),
Sequences.toList(timeBoundaryRunner.run(timeBoundaryQuery), Lists.<Result<TimeBoundaryResultValue>>newArrayList())
Sequences.toList(timeBoundaryRunner.run(timeBoundaryQuery, CONTEXT), Lists.<Result<TimeBoundaryResultValue>>newArrayList())
);
}

View File

@ -54,7 +54,7 @@ import org.junit.runners.Parameterized;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
@ -62,6 +62,9 @@ import java.util.List;
@RunWith(Parameterized.class)
public class TimeseriesQueryRunnerTest
{
public static final Map<String, Object> CONTEXT = ImmutableMap.of();
@Parameterized.Parameters
public static Collection<?> constructorFeeder() throws IOException
{
@ -103,10 +106,9 @@ public class TimeseriesQueryRunnerTest
DateTime expectedEarliest = new DateTime("2011-01-12");
DateTime expectedLast = new DateTime("2011-04-15");
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
@ -170,9 +172,8 @@ public class TimeseriesQueryRunnerTest
DateTime expectedEarliest = new DateTime("2011-01-12");
DateTime expectedLast = new DateTime("2011-04-15");
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
Result<TimeseriesResultValue> result = results.iterator().next();
@ -217,9 +218,9 @@ public class TimeseriesQueryRunnerTest
DateTime expectedEarliest = new DateTime("2011-01-12");
DateTime expectedLast = new DateTime("2011-04-15");
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
@ -283,9 +284,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
@ -330,9 +331,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
@ -372,9 +373,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results1 = Sequences.toList(
runner.run(query1, context),
runner.run(query1, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults1, results1);
@ -411,7 +412,7 @@ public class TimeseriesQueryRunnerTest
);
Iterable<Result<TimeseriesResultValue>> results2 = Sequences.toList(
runner.run(query2, context),
runner.run(query2, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults2, results2);
@ -462,9 +463,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results1 = Sequences.toList(
runner.run(query1, context),
runner.run(query1, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults1, results1);
@ -532,7 +533,7 @@ public class TimeseriesQueryRunnerTest
);
Iterable<Result<TimeseriesResultValue>> results1 = Sequences.toList(
runner.run(query1),
runner.run(query1, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults1, results1);
@ -579,7 +580,7 @@ public class TimeseriesQueryRunnerTest
);
Iterable<Result<TimeseriesResultValue>> results1 = Sequences.toList(
runner.run(query1),
runner.run(query1, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults1, results1);
@ -619,9 +620,8 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results1 = Sequences.toList(
runner.run(query1, context),
runner.run(query1, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults1, results1);
@ -659,7 +659,7 @@ public class TimeseriesQueryRunnerTest
);
Iterable<Result<TimeseriesResultValue>> results2 = Sequences.toList(
runner.run(query2, context),
runner.run(query2, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults2, results2);
@ -692,9 +692,9 @@ public class TimeseriesQueryRunnerTest
.build();
List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList();
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -742,9 +742,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -792,9 +792,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -842,9 +842,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -892,9 +892,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -942,9 +942,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1000,9 +1000,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1058,9 +1058,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1116,9 +1116,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1172,9 +1172,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1234,9 +1234,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1278,9 +1278,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1322,9 +1322,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1380,9 +1380,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, results);
@ -1420,9 +1420,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> actualResults = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, actualResults);
@ -1461,9 +1461,9 @@ public class TimeseriesQueryRunnerTest
)
)
);
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> actualResults = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, actualResults);
@ -1480,7 +1480,7 @@ public class TimeseriesQueryRunnerTest
.aggregators(QueryRunnerTestHelper.commonAggregators)
.postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant))
.build();
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> expectedResults = Sequences.toList(
runner.run(
Druids.newTimeseriesQueryBuilder()
@ -1490,12 +1490,12 @@ public class TimeseriesQueryRunnerTest
.aggregators(QueryRunnerTestHelper.commonAggregators)
.postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant))
.build(),
context
CONTEXT
),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
Iterable<Result<TimeseriesResultValue>> actualResults = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, actualResults);
@ -1512,7 +1512,7 @@ public class TimeseriesQueryRunnerTest
.aggregators(QueryRunnerTestHelper.commonAggregators)
.postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant))
.build();
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> expectedResults = Sequences.toList(
runner.run(
Druids.newTimeseriesQueryBuilder()
@ -1523,12 +1523,12 @@ public class TimeseriesQueryRunnerTest
.aggregators(QueryRunnerTestHelper.commonAggregators)
.postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant))
.build(),
context
CONTEXT
),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
Iterable<Result<TimeseriesResultValue>> actualResults = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, actualResults);
@ -1574,7 +1574,7 @@ public class TimeseriesQueryRunnerTest
)
)
.build();
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> expectedResults = Sequences.toList(
runner.run(
Druids.newTimeseriesQueryBuilder()
@ -1585,12 +1585,12 @@ public class TimeseriesQueryRunnerTest
.aggregators(QueryRunnerTestHelper.commonAggregators)
.postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant))
.build(),
context
CONTEXT
),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
Iterable<Result<TimeseriesResultValue>> actualResults = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, actualResults);
@ -1638,7 +1638,7 @@ public class TimeseriesQueryRunnerTest
)
)
.build();
HashMap<String,Object> context = new HashMap<String, Object>();
Iterable<Result<TimeseriesResultValue>> expectedResults = Sequences.toList(
runner.run(
Druids.newTimeseriesQueryBuilder()
@ -1649,12 +1649,12 @@ public class TimeseriesQueryRunnerTest
.aggregators(QueryRunnerTestHelper.commonAggregators)
.postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant))
.build(),
context
CONTEXT
),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
Iterable<Result<TimeseriesResultValue>> actualResults = Sequences.toList(
runner.run(query, context),
runner.run(query, CONTEXT),
Lists.<Result<TimeseriesResultValue>>newArrayList()
);
TestHelper.assertExpectedResults(expectedResults, actualResults);