本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveObjectInspectorUtils.getFloat方法的具体用法?Java PrimitiveObjectInspectorUtils.getFloat怎么用?Java PrimitiveObjectInspectorUtils.getFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils
的用法示例。
在下文中一共展示了PrimitiveObjectInspectorUtils.getFloat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void process(Object[] args) throws HiveException {
if (is_mini_batch && accumulated == null) {
this.accumulated = new HashMap<Object, FloatAccumulator>(1024);
}
List<?> features = (List<?>) featureListOI.getList(args[0]);
FeatureValue[] featureVector = parseFeatures(features);
if (featureVector == null) {
return;
}
float target = PrimitiveObjectInspectorUtils.getFloat(args[1], targetOI);
checkTargetValue(target);
count++;
train(featureVector, target);
recordTrainSampleToTempFile(featureVector, target);
}
示例2: int2floatMap
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Nonnull
private static Int2FloatMap int2floatMap(@Nonnull final Map<?, ?> map,
@Nonnull final PrimitiveObjectInspector keyOI,
@Nonnull final PrimitiveObjectInspector valueOI) {
final Int2FloatMap result = new Int2FloatOpenHashMap(map.size());
result.defaultReturnValue(0.f);
for (Map.Entry<?, ?> entry : map.entrySet()) {
float v = PrimitiveObjectInspectorUtils.getFloat(entry.getValue(), valueOI);
if (v == 0.f) {
continue;
}
int k = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), keyOI);
result.put(k, v);
}
return result;
}
示例3: asFloatArray
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Nullable
public static float[] asFloatArray(@Nullable final Object argObj,
@Nonnull final ListObjectInspector listOI,
@Nonnull final PrimitiveObjectInspector elemOI, final boolean avoidNull)
throws UDFArgumentException {
if (argObj == null) {
return null;
}
final int length = listOI.getListLength(argObj);
final float[] ary = new float[length];
for (int i = 0; i < length; i++) {
Object o = listOI.getListElement(argObj, i);
if (o == null) {
if (avoidNull) {
continue;
}
throw new UDFArgumentException("Found null at index " + i);
}
ary[i] = PrimitiveObjectInspectorUtils.getFloat(o, elemOI);
}
return ary;
}
示例4: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void iterate(@SuppressWarnings("deprecation") AggregationBuffer agg,
Object[] parameters) throws HiveException {
PLSAPredictAggregationBuffer myAggr = (PLSAPredictAggregationBuffer) agg;
if (parameters[0] == null || parameters[1] == null || parameters[2] == null
|| parameters[3] == null) {
return;
}
String word = PrimitiveObjectInspectorUtils.getString(parameters[0], wordOI);
float value = PrimitiveObjectInspectorUtils.getFloat(parameters[1], valueOI);
int label = PrimitiveObjectInspectorUtils.getInt(parameters[2], labelOI);
float prob = PrimitiveObjectInspectorUtils.getFloat(parameters[3], probOI);
myAggr.iterate(word, value, label, prob);
}
示例5: process
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void process(Object[] args) throws HiveException {
if (is_mini_batch && accumulated == null) {
this.accumulated = new HashMap<Object, FloatAccumulator>(1024);
}
List<?> features = (List<?>) featureListOI.getList(args[0]);
FeatureValue[] featureVector = parseFeatures(features);
if (featureVector == null) {
return;
}
float target = PrimitiveObjectInspectorUtils.getFloat(args[1], targetOI);
checkTargetValue(target);
count++;
train(featureVector, target);
}
示例6: initializeState
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
private void initializeState(final UnionState state, final Object[] parameters) {
int sketchSize = DEFAULT_NOMINAL_ENTRIES;
if (nominalEntriesObjectInspector != null) {
sketchSize = PrimitiveObjectInspectorUtils.getInt(parameters[1], nominalEntriesObjectInspector);
}
float samplingProbability = UnionState.DEFAULT_SAMPLING_PROBABILITY;
if (samplingProbabilityObjectInspector != null) {
samplingProbability = PrimitiveObjectInspectorUtils.getFloat(parameters[2],
samplingProbabilityObjectInspector);
}
long seed = DEFAULT_UPDATE_SEED;
if (seedObjectInspector != null) {
seed = PrimitiveObjectInspectorUtils.getLong(parameters[3], seedObjectInspector);
}
state.init(sketchSize, samplingProbability, seed);
}
示例7: initializeState
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
private void initializeState(final SketchState<U, S> state, final Object[] data) {
int nominalNumEntries = DEFAULT_NOMINAL_ENTRIES;
if (nominalNumEntriesInspector_ != null) {
nominalNumEntries = PrimitiveObjectInspectorUtils.getInt(data[2], nominalNumEntriesInspector_);
}
float samplingProbability = DEFAULT_SAMPLING_PROBABILITY;
if (samplingProbabilityInspector_ != null) {
samplingProbability = PrimitiveObjectInspectorUtils.getFloat(data[3],
samplingProbabilityInspector_);
}
state.init(nominalNumEntries, samplingProbability, getSummaryFactoryForIterate(data));
}
示例8: initializeState
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
private void initializeState(final ArrayOfDoublesSketchState state, final Object[] data) {
int nominalNumEntries = DEFAULT_NOMINAL_ENTRIES;
if (nominalNumEntriesInspector_ != null) {
nominalNumEntries =
PrimitiveObjectInspectorUtils.getInt(data[numValues_ + 1], nominalNumEntriesInspector_);
}
float samplingProbability = DEFAULT_SAMPLING_PROBABILITY;
if (samplingProbabilityInspector_ != null) {
samplingProbability = PrimitiveObjectInspectorUtils.getFloat(data[numValues_ + 2],
samplingProbabilityInspector_);
}
state.init(nominalNumEntries, samplingProbability, numValues_);
}
示例9: getFloat
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
public static float getFloat(@Nullable Object o, @Nonnull PrimitiveObjectInspector oi) {
if (o == null) {
return 0.f;
}
return PrimitiveObjectInspectorUtils.getFloat(o, oi);
}
示例10: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public FloatWritable evaluate(DeferredObject[] arguments) throws HiveException {
float d = PrimitiveObjectInspectorUtils.getFloat(arguments[0].get(), distanceOI);
float sim = 1.f / (1.f + d);
return new FloatWritable(sim);
}