Tabnine Logo
FieldAccessPostAggregator.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.druid.query.aggregation.post.FieldAccessPostAggregator
constructor

Best Java code snippets using org.apache.druid.query.aggregation.post.FieldAccessPostAggregator.<init> (Showing top 20 results out of 315)

origin: apache/incubator-druid

@Test
public void testSketchSetPostAggregatorSerde() throws Exception
{
 assertPostAggregatorSerde(
   new OldSketchSetPostAggregator(
     "name",
     "INTERSECT",
     null,
     Lists.newArrayList(
       new FieldAccessPostAggregator("name1", "fieldName1"),
       new FieldAccessPostAggregator("name2", "fieldName2")
     )
   )
 );
}
origin: apache/incubator-druid

@Test
public void testSketchEstimatePostAggregatorSerde() throws Exception
{
 assertPostAggregatorSerde(
   new OldSketchEstimatePostAggregator(
     "name",
     new FieldAccessPostAggregator("name", "fieldName")
   )
 );
}
origin: apache/incubator-druid

@Test
public void testNullPostAggregatorNames()
{
 AggregatorFactory agg1 = new DoubleSumAggregatorFactory("agg1", "value");
 AggregatorFactory agg2 = new DoubleSumAggregatorFactory("agg2", "count");
 PostAggregator postAgg1 = new ArithmeticPostAggregator(
   null,
   "*",
   Lists.newArrayList(new FieldAccessPostAggregator(null, "agg1"), new FieldAccessPostAggregator(null, "agg2"))
 );
 PostAggregator postAgg2 = new ArithmeticPostAggregator(
   "postAgg",
   "/",
   Lists.newArrayList(new FieldAccessPostAggregator(null, "agg1"), new FieldAccessPostAggregator(null, "agg2"))
 );
 Assert.assertEquals(
   new Pair<>(Lists.newArrayList(agg1, agg2), Collections.singletonList(postAgg2)),
   AggregatorUtil.condensedAggregators(
     Lists.newArrayList(agg1, agg2),
     Lists.newArrayList(postAgg1, postAgg2),
     "postAgg"
   )
 );
}
origin: apache/incubator-druid

@Test
public void testCasing()
{
 AggregatorFactory agg1 = new DoubleSumAggregatorFactory("Agg1", "value");
 AggregatorFactory agg2 = new DoubleSumAggregatorFactory("Agg2", "count");
 PostAggregator postAgg1 = new ArithmeticPostAggregator(
   null,
   "*",
   Lists.newArrayList(new FieldAccessPostAggregator(null, "Agg1"), new FieldAccessPostAggregator(null, "Agg2"))
 );
 PostAggregator postAgg2 = new ArithmeticPostAggregator(
   "postAgg",
   "/",
   Lists.newArrayList(new FieldAccessPostAggregator(null, "Agg1"), new FieldAccessPostAggregator(null, "Agg2"))
 );
 Assert.assertEquals(
   new Pair<>(Lists.newArrayList(agg1, agg2), Collections.singletonList(postAgg2)),
   AggregatorUtil.condensedAggregators(
     Lists.newArrayList(agg1, agg2),
     Lists.newArrayList(postAgg1, postAgg2),
     "postAgg"
   )
 );
}
origin: apache/incubator-druid

@Test
public void testSketchSetPostAggregatorSerde() throws Exception
{
 assertPostAggregatorSerde(
   new SketchSetPostAggregator(
     "name",
     "INTERSECT",
     null,
     Lists.newArrayList(
       new FieldAccessPostAggregator("name1", "fieldName1"),
       new FieldAccessPostAggregator("name2", "fieldName2")
     )
   )
 );
 
 assertPostAggregatorSerde(
   new SketchSetPostAggregator(
     "name",
     "INTERSECT",
     null,
     Lists.newArrayList(
       new FieldAccessPostAggregator("name1", "fieldName1"),
       new SketchConstantPostAggregator("name2", "AgMDAAAazJMCAAAAAACAPzz9j7pWTMdROWGf15uY1nI=")
     )
   )
 );
}
origin: apache/incubator-druid

@Test
public void testVerifyAggregations()
{
 List<AggregatorFactory> aggFactories = Arrays.asList(
   new CountAggregatorFactory("count"),
   new DoubleSumAggregatorFactory("idx", "index"),
   new DoubleSumAggregatorFactory("rev", "revenue")
 );
 List<PostAggregator> postAggs = Collections.singletonList(
   new ArithmeticPostAggregator(
     "addStuff",
     "+",
     Arrays.asList(
       new FieldAccessPostAggregator("idx", "idx"),
       new FieldAccessPostAggregator("count", "count")
     )
   )
 );
 boolean exceptionOccured = false;
 try {
  Queries.prepareAggregations(ImmutableList.of(), aggFactories, postAggs);
 }
 catch (IllegalArgumentException e) {
  exceptionOccured = true;
 }
 Assert.assertFalse(exceptionOccured);
}
origin: apache/incubator-druid

@Test
public void testVerifyAggregationsMissingVal()
{
 List<AggregatorFactory> aggFactories = Arrays.asList(
   new CountAggregatorFactory("count"),
   new DoubleSumAggregatorFactory("idx", "index"),
   new DoubleSumAggregatorFactory("rev", "revenue")
 );
 List<PostAggregator> postAggs = Collections.singletonList(
   new ArithmeticPostAggregator(
     "addStuff",
     "+",
     Arrays.asList(
       new FieldAccessPostAggregator("idx", "idx2"),
       new FieldAccessPostAggregator("count", "count")
     )
   )
 );
 boolean exceptionOccured = false;
 try {
  Queries.prepareAggregations(ImmutableList.of(), aggFactories, postAggs);
 }
 catch (IllegalArgumentException e) {
  exceptionOccured = true;
 }
 Assert.assertTrue(exceptionOccured);
}
origin: apache/incubator-druid

@Test
public void testSketchEstimatePostAggregatorSerde() throws Exception
{
 assertPostAggregatorSerde(
   new SketchEstimatePostAggregator(
     "name",
     new FieldAccessPostAggregator("name", "fieldName"),
     null
   )
 );
 assertPostAggregatorSerde(
   new SketchEstimatePostAggregator(
     "name",
     new FieldAccessPostAggregator("name", "fieldName"),
     2
   )
 );
 
 assertPostAggregatorSerde(
   new SketchEstimatePostAggregator(
     "name",
     new SketchConstantPostAggregator("name", "AgMDAAAazJMCAAAAAACAPzz9j7pWTMdROWGf15uY1nI="),
     null
   )
 );
}
origin: apache/incubator-druid

@Test
public void testQuotient()
{
 ArithmeticPostAggregator agg = new ArithmeticPostAggregator(
   null,
   "quotient",
   ImmutableList.of(
     new FieldAccessPostAggregator("numerator", "value"),
     new ConstantPostAggregator("zero", 0)
   ),
   "numericFirst"
 );
 Assert.assertEquals(Double.NaN, agg.compute(ImmutableMap.of("value", 0)));
 Assert.assertEquals(Double.NaN, agg.compute(ImmutableMap.of("value", Double.NaN)));
 Assert.assertEquals(Double.POSITIVE_INFINITY, agg.compute(ImmutableMap.of("value", 1)));
 Assert.assertEquals(Double.NEGATIVE_INFINITY, agg.compute(ImmutableMap.of("value", -1)));
}
origin: apache/incubator-druid

@Test
public void testDiv()
{
 ArithmeticPostAggregator agg = new ArithmeticPostAggregator(
   null,
   "/",
   ImmutableList.of(
     new FieldAccessPostAggregator("numerator", "value"),
     new ConstantPostAggregator("denomiator", 0)
   )
 );
 Assert.assertEquals(0.0, agg.compute(ImmutableMap.of("value", 0)));
 Assert.assertEquals(0.0, agg.compute(ImmutableMap.of("value", Double.NaN)));
 Assert.assertEquals(0.0, agg.compute(ImmutableMap.of("value", 1)));
 Assert.assertEquals(0.0, agg.compute(ImmutableMap.of("value", -1)));
}
origin: apache/incubator-druid

 @Test
 public void testCompute()
 {
  final String aggName = "rows";
  FieldAccessPostAggregator fieldAccessPostAggregator;

  fieldAccessPostAggregator = new FieldAccessPostAggregator("To be, or not to be, that is the question:", "rows");
  CountAggregator agg = new CountAggregator();
  Map<String, Object> metricValues = new HashMap<String, Object>();
  metricValues.put(aggName, agg.get());
  Assert.assertEquals(new Long(0L), fieldAccessPostAggregator.compute(metricValues));

  agg.aggregate();
  agg.aggregate();
  agg.aggregate();
  metricValues.put(aggName, agg.get());
  Assert.assertEquals(new Long(3L), fieldAccessPostAggregator.compute(metricValues));
 }
}
origin: apache/incubator-druid

@Test
public void testCompute()
{
 final String aggName = "rows";
 LongGreatestPostAggregator greatestPostAggregator;
 CountAggregator agg = new CountAggregator();
 agg.aggregate();
 agg.aggregate();
 agg.aggregate();
 Map<String, Object> metricValues = new HashMap<String, Object>();
 metricValues.put(aggName, agg.get());
 List<PostAggregator> postAggregatorList =
   Lists.newArrayList(
     new ConstantPostAggregator(
       "roku", 6D
     ),
     new FieldAccessPostAggregator(
       "rows", aggName
     )
   );
 greatestPostAggregator = new LongGreatestPostAggregator("greatest", postAggregatorList);
 Assert.assertEquals(Long.valueOf(6), greatestPostAggregator.compute(metricValues));
}
origin: apache/incubator-druid

@Test
public void testCompute()
{
 final String aggName = "rows";
 LongLeastPostAggregator leastPostAggregator;
 CountAggregator agg = new CountAggregator();
 agg.aggregate();
 agg.aggregate();
 agg.aggregate();
 Map<String, Object> metricValues = new HashMap<String, Object>();
 metricValues.put(aggName, agg.get());
 List<PostAggregator> postAggregatorList =
   Lists.newArrayList(
     new ConstantPostAggregator(
       "roku", 6D
     ),
     new FieldAccessPostAggregator(
       "rows", aggName
     )
   );
 leastPostAggregator = new LongLeastPostAggregator("leastPostAggregator", postAggregatorList);
 Assert.assertEquals(Long.valueOf(3), leastPostAggregator.compute(metricValues));
}
origin: apache/incubator-druid

  "roku", 2D
),
new FieldAccessPostAggregator(
  "rows", aggName
origin: apache/incubator-druid

  "roku", 2D
),
new FieldAccessPostAggregator(
  "rows", aggName
origin: apache/incubator-druid

  "roku", 2D
),
new FieldAccessPostAggregator(
  "rows", aggName
origin: apache/incubator-druid

@Test
public void testCompute()
{
 final String aggName = "rows";
 DoubleLeastPostAggregator leastPostAggregator;
 CountAggregator agg = new CountAggregator();
 agg.aggregate();
 agg.aggregate();
 agg.aggregate();
 Map<String, Object> metricValues = new HashMap<String, Object>();
 metricValues.put(aggName, agg.get());
 List<PostAggregator> postAggregatorList =
   Lists.newArrayList(
     new ConstantPostAggregator(
       "roku", 6D
     ),
     new FieldAccessPostAggregator(
       "rows", aggName
     )
   );
 leastPostAggregator = new DoubleLeastPostAggregator("least", postAggregatorList);
 Assert.assertEquals(3.0, leastPostAggregator.compute(metricValues));
}
origin: apache/incubator-druid

@Test
public void testComparator()
{
 final String aggName = "rows";
 ArithmeticPostAggregator arithmeticPostAggregator;
 CountAggregator agg = new CountAggregator();
 Map<String, Object> metricValues = new HashMap<String, Object>();
 metricValues.put(aggName, agg.get());
 List<PostAggregator> postAggregatorList =
   Lists.newArrayList(
     new ConstantPostAggregator(
       "roku", 6D
     ),
     new FieldAccessPostAggregator(
       "rows", "rows"
     )
   );
 arithmeticPostAggregator = new ArithmeticPostAggregator("add", "+", postAggregatorList);
 Comparator comp = arithmeticPostAggregator.getComparator();
 Object before = arithmeticPostAggregator.compute(metricValues);
 agg.aggregate();
 agg.aggregate();
 agg.aggregate();
 metricValues.put(aggName, agg.get());
 Object after = arithmeticPostAggregator.compute(metricValues);
 Assert.assertEquals(-1, comp.compare(before, after));
 Assert.assertEquals(0, comp.compare(before, before));
 Assert.assertEquals(0, comp.compare(after, after));
 Assert.assertEquals(1, comp.compare(after, before));
}
origin: apache/incubator-druid

@Test
public void testCompute()
{
 final String aggName = "rows";
 DoubleGreatestPostAggregator greatestPostAggregator;
 CountAggregator agg = new CountAggregator();
 agg.aggregate();
 agg.aggregate();
 agg.aggregate();
 Map<String, Object> metricValues = new HashMap<String, Object>();
 metricValues.put(aggName, agg.get());
 List<PostAggregator> postAggregatorList =
   Lists.newArrayList(
     new ConstantPostAggregator(
       "roku", 6D
     ),
     new FieldAccessPostAggregator(
       "rows", aggName
     )
   );
 greatestPostAggregator = new DoubleGreatestPostAggregator("greatest", postAggregatorList);
 Assert.assertEquals(6.0, greatestPostAggregator.compute(metricValues));
}
origin: apache/incubator-druid

@Test
public void testQuerySerialization() throws IOException
{
 Query query = GroupByQuery
   .builder()
   .setDataSource(QueryRunnerTestHelper.dataSource)
   .setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird)
   .setDimensions(new DefaultDimensionSpec("quality", "alias"))
   .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, new LongSumAggregatorFactory("idx", "index"))
   .setGranularity(QueryRunnerTestHelper.dayGran)
   .setPostAggregatorSpecs(ImmutableList.of(new FieldAccessPostAggregator("x", "idx")))
   .setLimitSpec(
     new DefaultLimitSpec(
       ImmutableList.of(new OrderByColumnSpec(
         "alias",
         OrderByColumnSpec.Direction.ASCENDING,
         StringComparators.LEXICOGRAPHIC
       )),
       100
     )
   )
   .build();
 String json = jsonMapper.writeValueAsString(query);
 Query serdeQuery = jsonMapper.readValue(json, Query.class);
 Assert.assertEquals(query, serdeQuery);
}
org.apache.druid.query.aggregation.postFieldAccessPostAggregator<init>

Popular methods of FieldAccessPostAggregator

  • compute

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • getSystemService (Context)
  • startActivity (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now