Package com.inadco.hbl.math.pig

Source Code of com.inadco.hbl.math.pig.ExpAvgNew

package com.inadco.hbl.math.pig;

import java.io.IOException;
import java.lang.reflect.Type;

import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.Tuple;

import com.inadco.hbl.math.aggregators.IrregularSamplingSummarizer;

/**
* Creates are requested summarizer with given parameters and empty state.
*
* @author dmitriy
*
*/
public class ExpAvgNew extends EvalFunc<DataByteArray> {

    private final DataByteArray m_result;

    public ExpAvgNew(String initStr) throws IOException {
        super();
        IrregularSamplingSummarizer sum = PigSummarizerHelper.createSummarizer(initStr, false);
        DataOutputBuffer dob = new DataOutputBuffer();
        PigSummarizerHelper.ser2bytes(sum, dob);
        m_result = new DataByteArray(dob.getData(), 0, dob.getLength());

    }

    @Override
    public DataByteArray exec(Tuple input) throws IOException {
        return m_result;
    }

    @Override
    public Type getReturnType() {
        return DataByteArray.class;
    }

}
TOP

Related Classes of com.inadco.hbl.math.pig.ExpAvgNew

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.