本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveObjectInspectorUtils.getInt方法的具体用法?Java PrimitiveObjectInspectorUtils.getInt怎么用?Java PrimitiveObjectInspectorUtils.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils
的用法示例。
在下文中一共展示了PrimitiveObjectInspectorUtils.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public DoubleWritable evaluate(DeferredObject[] arguments) throws HiveException {
Object arg0 = arguments[0].get();
Object arg1 = arguments[1].get();
if (arg0 == null) {
return null;
}
if (arg1 == null) {
throw new UDFArgumentException("zoom level should not be null");
}
int y = PrimitiveObjectInspectorUtils.getInt(arg0, yOI);
int zoom = PrimitiveObjectInspectorUtils.getInt(arg1, zoomOI);
Preconditions.checkArgument(zoom >= 0, "Invalid zoom level", UDFArgumentException.class);
final double lat;
try {
lat = GeoSpatialUtils.tiley2lat(y, zoom);
} catch (IllegalArgumentException ex) {
throw new UDFArgumentException(ex);
}
result.set(lat);
return result;
}
示例2: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public IntWritable evaluate(DeferredObject[] arguments) throws HiveException {
Object arg0 = arguments[0].get();
Object arg1 = arguments[1].get();
if (arg0 == null) {
return null;
}
if (arg1 == null) {
throw new UDFArgumentException("zoom level should not be null");
}
double lat = PrimitiveObjectInspectorUtils.getDouble(arg0, latOI);
int zoom = PrimitiveObjectInspectorUtils.getInt(arg1, zoomOI);
Preconditions.checkArgument(zoom >= 0, "Invalid zoom level", UDFArgumentException.class);
final int y;
try {
y = GeoSpatialUtils.lat2tiley(lat, zoom);
} catch (IllegalArgumentException ex) {
throw new UDFArgumentException(ex);
}
result.set(y);
return result;
}
示例3: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public DoubleWritable evaluate(DeferredObject[] arguments) throws HiveException {
Object arg0 = arguments[0].get();
Object arg1 = arguments[1].get();
if (arg0 == null) {
return null;
}
if (arg1 == null) {
throw new UDFArgumentException("zoom level should not be null");
}
int x = PrimitiveObjectInspectorUtils.getInt(arg0, xOI);
int zoom = PrimitiveObjectInspectorUtils.getInt(arg1, zoomOI);
Preconditions.checkArgument(zoom >= 0, "Invalid zoom level", UDFArgumentException.class);
final double lon;
try {
lon = GeoSpatialUtils.tilex2lon(x, zoom);
} catch (IllegalArgumentException ex) {
throw new UDFArgumentException(ex);
}
result.set(lon);
return result;
}
示例4: addFeedback
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Nullable
private void addFeedback(final int userId, @Nonnull final Object arg)
throws UDFArgumentException {
final int size = itemListOI.getListLength(arg);
if (size == 0) {
return;
}
int maxItemId = feedback.getMaxItemId();
final IntArrayList posItems = new IntArrayList(size);
for (int i = 0; i < size; i++) {
Object elem = itemListOI.getListElement(arg, i);
if (elem == null) {
continue;
}
int index = PrimitiveObjectInspectorUtils.getInt(elem, itemElemOI);
validateIndex(index);
maxItemId = Math.max(index, maxItemId);
posItems.add(index);
}
feedback.addFeedback(userId, posItems);
feedback.setMaxItemId(maxItemId);
}
示例5: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public IntWritable evaluate(DeferredObject[] arguments) throws HiveException {
Object arg0 = arguments[0].get();
Object arg1 = arguments[1].get();
if (arg0 == null) {
return null;
}
if (arg1 == null) {
throw new UDFArgumentException("zoom level should not be null");
}
double lon = PrimitiveObjectInspectorUtils.getDouble(arg0, lonOI);
int zoom = PrimitiveObjectInspectorUtils.getInt(arg1, zoomOI);
Preconditions.checkArgument(zoom >= 0, "Invalid zoom level", UDFArgumentException.class);
final int x;
try {
x = GeoSpatialUtils.lon2tilex(lon, zoom);
} catch (IllegalArgumentException ex) {
throw new UDFArgumentException(ex);
}
result.set(x);
return result;
}
示例6: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void iterate(@SuppressWarnings("deprecation") AggregationBuffer agg,
Object[] parameters) throws HiveException {
HitRateAggregationBuffer myAggr = (HitRateAggregationBuffer) agg;
List<?> recommendList = recommendListOI.getList(parameters[0]);
if (recommendList == null) {
recommendList = Collections.emptyList();
}
List<?> truthList = truthListOI.getList(parameters[1]);
if (truthList == null) {
return;
}
int recommendSize = recommendList.size();
if (parameters.length == 3) {
recommendSize = PrimitiveObjectInspectorUtils.getInt(parameters[2], recommendSizeOI);
if (recommendSize < 0) {
throw new UDFArgumentException(
"The third argument `int recommendSize` must be in greather than or equals to 0: "
+ recommendSize);
}
}
myAggr.iterate(recommendList, truthList, recommendSize);
}
示例7: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
ClassificationAUCAggregationBuffer myAggr = (ClassificationAUCAggregationBuffer) agg;
if (parameters[0] == null) {
return;
}
if (parameters[1] == null) {
return;
}
double score = HiveUtils.getDouble(parameters[0], scoreOI);
if (score < 0.0d || score > 1.0d) {
throw new UDFArgumentException("score value MUST be in range [0,1]: " + score);
}
int label = PrimitiveObjectInspectorUtils.getInt(parameters[1], labelOI);
if (label == -1) {
label = 0;
} else if (label != 0 && label != 1) {
throw new UDFArgumentException("label MUST be 0/1 or -1/1: " + label);
}
myAggr.iterate(score, label);
}
示例8: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void iterate(@SuppressWarnings("deprecation") AggregationBuffer agg,
Object[] parameters) throws HiveException {
PrecisionAggregationBuffer myAggr = (PrecisionAggregationBuffer) agg;
List<?> recommendList = recommendListOI.getList(parameters[0]);
if (recommendList == null) {
recommendList = Collections.emptyList();
}
List<?> truthList = truthListOI.getList(parameters[1]);
if (truthList == null) {
return;
}
int recommendSize = recommendList.size();
if (parameters.length == 3) {
recommendSize = PrimitiveObjectInspectorUtils.getInt(parameters[2], recommendSizeOI);
if (recommendSize < 0) {
throw new UDFArgumentException(
"The third argument `int recommendSize` must be in greather than or equals to 0: "
+ recommendSize);
}
}
myAggr.iterate(recommendList, truthList, recommendSize);
}
示例9: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void iterate(@SuppressWarnings("deprecation") AggregationBuffer agg,
Object[] parameters) throws HiveException {
MAPAggregationBuffer myAggr = (MAPAggregationBuffer) agg;
List<?> recommendList = recommendListOI.getList(parameters[0]);
if (recommendList == null) {
recommendList = Collections.emptyList();
}
List<?> truthList = truthListOI.getList(parameters[1]);
if (truthList == null) {
return;
}
int recommendSize = recommendList.size();
if (parameters.length == 3) {
recommendSize = PrimitiveObjectInspectorUtils.getInt(parameters[2], recommendSizeOI);
if (recommendSize < 0) {
throw new UDFArgumentException(
"The third argument `int recommendSize` must be in greather than or equals to 0: "
+ recommendSize);
}
}
myAggr.iterate(recommendList, truthList, recommendSize);
}
示例10: kNNentries
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Nonnull
private static Int2ObjectMap<Int2FloatMap> kNNentries(@Nonnull final Object kNNiObj,
@Nonnull final MapObjectInspector knnItemsOI,
@Nonnull final PrimitiveObjectInspector knnItemsKeyOI,
@Nonnull final MapObjectInspector knnItemsValueOI,
@Nonnull final PrimitiveObjectInspector knnItemsValueKeyOI,
@Nonnull final PrimitiveObjectInspector knnItemsValueValueOI,
@Nullable Int2ObjectMap<Int2FloatMap> knnItems, @Nonnull final MutableInt nnzKNNi) {
if (knnItems == null) {
knnItems = new Int2ObjectOpenHashMap<>(1024);
} else {
knnItems.clear();
}
int numElementOfKNNItems = 0;
for (Map.Entry<?, ?> entry : knnItemsOI.getMap(kNNiObj).entrySet()) {
int user = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), knnItemsKeyOI);
Int2FloatMap ru = int2floatMap(knnItemsValueOI.getMap(entry.getValue()),
knnItemsValueKeyOI, knnItemsValueValueOI);
knnItems.put(user, ru);
numElementOfKNNItems += ru.size();
}
nnzKNNi.setValue(numElementOfKNNItems);
return knnItems;
}
示例11: 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;
}
示例12: 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;
}
int label = PrimitiveObjectInspectorUtils.getInt(args[1], labelOI);
checkLabelValue(label);
count++;
train(featureVector, label);
}
示例13: 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);
}
示例14: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public LongWritable evaluate(DeferredObject[] arguments) throws HiveException {
Object arg0 = arguments[0].get();
Object arg1 = arguments[1].get();
Object arg2 = arguments[2].get();
if (arg0 == null || arg1 == null) {
return null;
}
if (arg2 == null) {
throw new UDFArgumentException("zoom level is null");
}
double lat = PrimitiveObjectInspectorUtils.getDouble(arg0, latOI);
double lon = PrimitiveObjectInspectorUtils.getDouble(arg1, lonOI);
int zoom = PrimitiveObjectInspectorUtils.getInt(arg2, zoomOI);
Preconditions.checkArgument(zoom >= 0, "Invalid zoom level", UDFArgumentException.class);
final long tile;
try {
tile = GeoSpatialUtils.tile(lat, lon, zoom);
} catch (IllegalArgumentException ex) {
throw new UDFArgumentException(ex);
}
result.set(tile);
return result;
}
示例15: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
RfAggregationBufferV1 buf = (RfAggregationBufferV1) agg;
Preconditions.checkNotNull(parameters[0]);
int yhat = PrimitiveObjectInspectorUtils.getInt(parameters[0], yhatOI);
buf.iterate(yhat);
}