[ 
https://issues.apache.org/jira/browse/TAJO-921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14386178#comment-14386178
 ] 

ASF GitHub Bot commented on TAJO-921:
-------------------------------------

Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/427#discussion_r27366305
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/StdDev.java ---
    @@ -0,0 +1,94 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.tajo.engine.function.builtin;
    +
    +import org.apache.tajo.catalog.CatalogUtil;
    +import org.apache.tajo.catalog.Column;
    +import org.apache.tajo.common.TajoDataTypes.DataType;
    +import org.apache.tajo.common.TajoDataTypes.Type;
    +import org.apache.tajo.datum.Datum;
    +import org.apache.tajo.datum.NullDatum;
    +import org.apache.tajo.datum.ProtobufDatum;
    +import org.apache.tajo.plan.function.AggFunction;
    +import org.apache.tajo.plan.function.FunctionContext;
    +import org.apache.tajo.storage.Tuple;
    +
    +import static org.apache.tajo.InternalTypes.StdDevProto;
    +
    +public abstract class StdDev extends AggFunction<Datum> {
    +
    +  public StdDev(Column[] definedArgs) {
    +    super(definedArgs);
    +  }
    +
    +  public StdDevContext newContext() {
    +    return new StdDevContext();
    +  }
    +
    +  @Override
    +  public void eval(FunctionContext ctx, Tuple params) {
    +    StdDevContext StdDevCtx = (StdDevContext) ctx;
    +    Datum datum = params.get(0);
    +    if (datum.isNotNull()) {
    +      double delta = datum.asFloat8() - StdDevCtx.avg;
    +      StdDevCtx.count++;
    +      StdDevCtx.avg += delta/StdDevCtx.count;
    +      StdDevCtx.squareSumOfDiff += delta * (datum.asFloat8() - 
StdDevCtx.avg);
    --- End diff --
    
    ```datum.asFloat8() - StdDevCtx.avg``` can be replaced with ```delta```.


> Add STDDEV_SAMP and STDDEV_POP window functions
> -----------------------------------------------
>
>                 Key: TAJO-921
>                 URL: https://issues.apache.org/jira/browse/TAJO-921
>             Project: Tajo
>          Issue Type: Sub-task
>          Components: function/udf, physical operator
>            Reporter: Hyunsik Choi
>            Assignee: Keuntae Park
>             Fix For: 0.11.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to