Examples of AggregationFunction


Examples of com.facebook.presto.operator.aggregation.AggregationFunction

    }

    @SuppressWarnings("rawtypes")
    private static Aggregator createAggregator(AggregationFunctionDefinition functionDefinition, Step step, int expectedGroups)
    {
        AggregationFunction function = functionDefinition.getFunction();
        if (function instanceof VariableWidthAggregationFunction) {
            return new VariableWidthAggregator((VariableWidthAggregationFunction) functionDefinition.getFunction(), functionDefinition.getInputs(), step, expectedGroups);
        }
        else {
            Input input = null;
View Full Code Here

Examples of com.facebook.presto.operator.aggregation.AggregationFunction

        private final int intermediateChannel;

        private Aggregator(AggregationFunctionDefinition functionDefinition, Step step)
        {
            AggregationFunction function = functionDefinition.getFunction();

            if (step != Step.FINAL) {
                int[] argumentChannels = new int[functionDefinition.getInputs().size()];
                for (int i = 0; i < argumentChannels.length; i++) {
                    argumentChannels[i] = functionDefinition.getInputs().get(i).getChannel();
                }
                intermediateChannel = -1;
                aggregation = function.createAggregation(
                        functionDefinition.getMask().transform(Input.channelGetter()),
                        functionDefinition.getSampleWeight().transform(Input.channelGetter()),
                        functionDefinition.getConfidence(),
                        argumentChannels);
            }
            else {
                checkArgument(functionDefinition.getInputs().size() == 1, "Expected a single input for an intermediate aggregation");
                intermediateChannel = functionDefinition.getInputs().get(0).getChannel();
                aggregation = function.createIntermediateAggregation(functionDefinition.getConfidence());
            }
            this.step = step;
        }
View Full Code Here

Examples of com.facebook.presto.operator.aggregation.AggregationFunction

        private final int intermediateChannel;

        private Aggregator(AggregationFunctionDefinition functionDefinition, Step step)
        {
            AggregationFunction function = functionDefinition.getFunction();

            if (step == Step.FINAL) {
                checkArgument(functionDefinition.getInputs().size() == 1, "Expected a single input for an intermediate aggregation");
                intermediateChannel = functionDefinition.getInputs().get(0).getChannel();
                aggregation = function.createGroupedIntermediateAggregation(functionDefinition.getConfidence());
            }
            else {
                int[] argumentChannels = new int[functionDefinition.getInputs().size()];
                for (int i = 0; i < argumentChannels.length; i++) {
                    argumentChannels[i] = functionDefinition.getInputs().get(i).getChannel();
                }
                intermediateChannel = -1;
                aggregation = function.createGroupedAggregation(
                        functionDefinition.getMask().transform(Input.channelGetter()),
                        functionDefinition.getSampleWeight().transform(Input.channelGetter()),
                        functionDefinition.getConfidence(),
                        argumentChannels);
            }
View Full Code Here

Examples of io.crate.operation.aggregation.AggregationFunction

    @Test
    public void testDistributedMergeTask() throws Exception {
        ClusterService clusterService = cluster().getInstance(ClusterService.class);
        Functions functions = cluster().getInstance(Functions.class);
        AggregationFunction countAggregation =
                (AggregationFunction)functions.get(new FunctionIdent(CountAggregation.NAME, ImmutableList.<DataType>of()));

        TransportMergeNodeAction transportMergeNodeAction = cluster().getInstance(TransportMergeNodeAction.class);

        Set<String> nodes = new HashSet<>();
        for (DiscoveryNode discoveryNode : clusterService.state().nodes()) {
            nodes.add(discoveryNode.getId());
        }

        // select count(*), user ... group by user
        MergeNode mergeNode = new MergeNode("merge1", 2);
        mergeNode.contextId(UUID.randomUUID());
        mergeNode.executionNodes(nodes);
        mergeNode.inputTypes(Arrays.<DataType>asList(DataTypes.UNDEFINED, DataTypes.STRING));

        GroupProjection groupProjection = new GroupProjection();
        groupProjection.keys(Arrays.<DataTypeSymbol>asList(new InputColumn(1, DataTypes.STRING)));
        groupProjection.values(Arrays.asList(
                new Aggregation(
                        countAggregation.info(),
                        ImmutableList.<Symbol>of(new InputColumn(0)),
                        Aggregation.Step.PARTIAL,
                        Aggregation.Step.FINAL
                )
        ));
View Full Code Here

Examples of io.crate.operation.aggregation.AggregationFunction

    }

    @Test
    public void testLongSerialization() throws Exception {
        FunctionIdent fi = new FunctionIdent("collect_set", ImmutableList.<DataType>of(DataTypes.LONG));
        AggregationFunction impl = (AggregationFunction) functions.get(fi);
        AggregationState state = impl.newState();

        BytesStreamOutput streamOutput = new BytesStreamOutput();
        state.writeTo(streamOutput);

        AggregationState newState = impl.newState();
        newState.readFrom(new BytesStreamInput(streamOutput.bytes()));
        assertEquals(state.value(), newState.value());
    }
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.function.AggregationFunction

        continue;
      }

      try
      {
        final AggregationFunction o = (AggregationFunction) aggType.newInstance();
        final String group = (String) element.getAttribute
            (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_GROUP);
        if (group != null)
        {
          o.setGroup(group);
        }
        else
        {
          final Group g = findGroup(element);
          if (g != null)
          {
            if (g.getName() == null)
            {
              g.setName("::wizard:group:" + g.getClass().getName() + ':' + System.identityHashCode(g));
            }

            o.setGroup(g.getName());
          }
        }

        final String fieldName = (String) element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD);
        if (o instanceof FieldAggregationFunction)
        {
          final FieldAggregationFunction fo = (FieldAggregationFunction) o;
          fo.setField(fieldName);
        }

        final Object labelFor =
            element.getAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR);
        if (labelFor == null)
        {
          element.setAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, fieldName);
        }

        final String name = AutoGeneratorUtility.generateUniqueExpressionName
            (schema, "::wizard:aggregation:{0}",
                (String[]) generatedExpressionNames.toArray(new String[generatedExpressionNames.size()]));
        o.setName(name);
        generatedExpressionNames.add(name);

        element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, name);
        // finally clean up
        element.setAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE, null);
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.function.AggregationFunction

    if (dummy instanceof AggregationFunction == false)
    {
      return null;
    }

    AggregationFunction function = (AggregationFunction) dummy;

    final MasterReport report = new MasterReport();
    report.setPageDefinition(new SimplePageDefinition(PageSize.A3, PageFormat.LANDSCAPE, new Insets(0, 0, 0, 0)));
    report.setDataFactory(new TableDataFactory("query", tableModel));
    report.setQuery("query");
    final ContextAwareDataSchemaModel dataSchemaModel = new DesignTimeDataSchemaModel(report);

    final CrosstabBuilder builder = new CrosstabBuilder(dataSchemaModel);
    builder.addRowDimension(ROW_DIMENSION_A);
    builder.addRowDimension(ROW_DIMENSION_B);
    builder.addColumnDimension(COLUMN_DIMENSION_A);
    builder.addColumnDimension(COLUMN_DIMENSION_B);
    builder.addDetails(VALUE, function.getClass());
    report.setRootGroup(builder.create());
    return report;
  }
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.function.AggregationFunction

  protected void processAggregateElement(final ReportElement element,
                                         final Class<AggregationFunction> aggType)
      throws InstantiationException, IllegalAccessException, ReportProcessingException
  {
    final AggregationFunction o = aggType.newInstance();

    if (configureCrosstabAggregation(element, o) == false)
    {
      configureRelationalAggreation(element, o);
    }

    final String fieldName = (String) element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD);
    if (o instanceof FieldAggregationFunction)
    {
      final FieldAggregationFunction fo = (FieldAggregationFunction) o;
      fo.setField(fieldName);
    }

    final Object labelFor =
        element.getAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR);
    if (labelFor == null)
    {
      element.setAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, fieldName);
    }

    final String name = AutoGeneratorUtility.generateUniqueExpressionName
        (schema, "::wizard:aggregation:{0}",
            generatedExpressionNames.toArray(new String[generatedExpressionNames.size()]));
    o.setName(name);
    generatedExpressionNames.add(name);

    element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, name);
    // finally clean up
    element.setAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE, null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.