本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils类的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveObjectInspectorUtils类的具体用法?Java PrimitiveObjectInspectorUtils怎么用?Java PrimitiveObjectInspectorUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrimitiveObjectInspectorUtils类属于org.apache.hadoop.hive.serde2.objectinspector.primitive包,在下文中一共展示了PrimitiveObjectInspectorUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkArgGroups
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入依赖的package包/类
public static void checkArgGroups(ObjectInspector[] arguments, int i,
PrimitiveCategory[] inputTypes, PrimitiveGrouping... grps)
throws UDFArgumentTypeException {
PrimitiveCategory inputType = ((PrimitiveObjectInspector) arguments[i]).getPrimitiveCategory();
for (PrimitiveGrouping grp : grps) {
if (PrimitiveObjectInspectorUtils.getPrimitiveGrouping(inputType) == grp) {
inputTypes[i] = inputType;
return;
}
}
// build error message
StringBuilder sb = new StringBuilder();
sb.append("_FUNC_ only takes ");
sb.append(grps[0]);
for (int j = 1; j < grps.length; j++) {
sb.append(", ");
sb.append(grps[j]);
}
sb.append(" types as ");
sb.append(getArgOrder(i));
sb.append(" argument, got ");
sb.append(inputType);
throw new UDFArgumentTypeException(i, sb.toString());
}
示例2: process
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入依赖的package包/类
@Override
public void process(@Nonnull Object[] args) throws HiveException {
if (args[0] == null) {
return;
}
// TODO: Need to support dense inputs
final List<?> features = (List<?>) featureListOI.getList(args[0]);
final String[] fv = new String[features.size()];
for (int i = 0; i < features.size(); i++) {
fv[i] = (String) featureElemOI.getPrimitiveJavaObject(features.get(i));
}
double target = PrimitiveObjectInspectorUtils.getDouble(args[1], this.targetOI);
checkTargetValue(target);
final LabeledPoint point = XGBoostUtils.parseFeatures(target, fv);
if (point != null) {
this.featuresList.add(point);
}
}
示例3: 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);
}
示例4: 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;
}
示例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 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;
}
示例6: 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;
}
示例7: evaluate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入依赖的package包/类
@Override
public Text 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);
result.set(toMapURL(lat, lon, zoom, type));
return result;
}
示例8: 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;
}
示例9: 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);
}
示例10: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入依赖的package包/类
@Override
public void iterate(@SuppressWarnings("deprecation") AggregationBuffer agg,
Object[] parameters) throws HiveException {
MRRAggregationBuffer myAggr = (MRRAggregationBuffer) 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);
}
示例11: 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);
}
示例12: 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);
}
示例13: 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);
}
示例14: iterate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; //导入依赖的package包/类
@Override
public void iterate(@SuppressWarnings("deprecation") AggregationBuffer agg,
Object[] parameters) throws HiveException {
RecallAggregationBuffer myAggr = (RecallAggregationBuffer) 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);
}
示例15: 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;
}