All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.sketches.pig.tuple.ArrayOfDoublesSketchToNumberOfRetainedEntries Maven / Gradle / Ivy

/*
 * Copyright 2017, Yahoo! Inc.
 * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
 */

package com.yahoo.sketches.pig.tuple;

import java.io.IOException;

import org.apache.pig.EvalFunc;
import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.Tuple;

import com.yahoo.memory.Memory;
import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
import com.yahoo.sketches.tuple.ArrayOfDoublesSketches;

/**
 * This is a User Defined Function (UDF) for obtaining the number of retained entries
 * from an ArrayOfDoublesSketch.
 *
 * 

The result is an integer value. * * @author Alexander Saydakov */ public class ArrayOfDoublesSketchToNumberOfRetainedEntries extends EvalFunc { @Override public Integer exec(final Tuple input) throws IOException { if ((input == null) || (input.size() == 0)) { return null; } final DataByteArray dba = (DataByteArray) input.get(0); final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketches.wrapSketch(Memory.wrap(dba.get())); return sketch.getRetainedEntries(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy