本文整理汇总了Java中org.apache.hadoop.hive.serde2.io.DoubleWritable.set方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleWritable.set方法的具体用法?Java DoubleWritable.set怎么用?Java DoubleWritable.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.serde2.io.DoubleWritable
的用法示例。
在下文中一共展示了DoubleWritable.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: terminate
import org.apache.hadoop.hive.serde2.io.DoubleWritable; //导入方法依赖的package包/类
@Override
public Object terminate(AggregationBuffer agg) throws HiveException {
StdAgg myagg = (StdAgg) agg;
if (myagg.count == 0) {
return null;
} else {
DoubleWritable result = getResult();
result.set(myagg.variance);
return result;
}
}
示例2: evaluate
import org.apache.hadoop.hive.serde2.io.DoubleWritable; //导入方法依赖的package包/类
@Override
public List<DoubleWritable> evaluate(DeferredObject[] dObj) throws HiveException {
final double[] features = HiveUtils.asDoubleArray(dObj[0].get(), featuresOI, featureOI);
final double[] importanceList = HiveUtils.asDoubleArray(dObj[1].get(), importanceListOI,
importanceElemOI);
Preconditions.checkNotNull(features, UDFArgumentException.class);
Preconditions.checkNotNull(importanceList, UDFArgumentException.class);
Preconditions.checkArgument(features.length == importanceList.length,
UDFArgumentException.class);
Preconditions.checkArgument(features.length >= _k, UDFArgumentException.class);
int[] topKIndices = _topKIndices;
if (topKIndices == null) {
final List<Map.Entry<Integer, Double>> list = new ArrayList<Map.Entry<Integer, Double>>();
for (int i = 0; i < importanceList.length; i++) {
list.add(new AbstractMap.SimpleEntry<Integer, Double>(i, importanceList[i]));
}
Collections.sort(list, new Comparator<Map.Entry<Integer, Double>>() {
@Override
public int compare(Map.Entry<Integer, Double> o1, Map.Entry<Integer, Double> o2) {
return o1.getValue() > o2.getValue() ? -1 : 1;
}
});
topKIndices = new int[_k];
for (int i = 0; i < topKIndices.length; i++) {
topKIndices[i] = list.get(i).getKey();
}
this._topKIndices = topKIndices;
}
final List<DoubleWritable> result = _result;
for (int i = 0; i < topKIndices.length; i++) {
int idx = topKIndices[i];
DoubleWritable d = result.get(i);
double f = features[idx];
d.set(f);
}
return result;
}