本文整理汇总了Java中org.jpmml.evaluator.Evaluator.getDataField方法的典型用法代码示例。如果您正苦于以下问题:Java Evaluator.getDataField方法的具体用法?Java Evaluator.getDataField怎么用?Java Evaluator.getDataField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jpmml.evaluator.Evaluator
的用法示例。
在下文中一共展示了Evaluator.getDataField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareArguments
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
private Map<FieldName, ?> prepareArguments(Evaluator evaluator, double[] inputValues) {
Map<FieldName, Object> arguments = new LinkedHashMap<FieldName, Object>();
List<FieldName> activeFields = evaluator.getActiveFields();
// loop over and prepare each argument
int idx = 0;
for (FieldName activeField : activeFields) {
DataField dataField = evaluator.getDataField(activeField);
arguments.put(activeField, evaluator.prepare(activeField, inputValues[idx]));
idx++;
}
return arguments;
}
示例2: prepareArguments
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
public Map<FieldName, ?> prepareArguments(Evaluator evaluator, double[] inputValues) {
Map<FieldName, Object> arguments = new LinkedHashMap<FieldName, Object>();
List<FieldName> activeFields = evaluator.getActiveFields();
// loop over and prepare each argument
int idx = 0;
for (FieldName activeField : activeFields) {
DataField dataField = evaluator.getDataField(activeField);
arguments.put(activeField, evaluator.prepare(activeField, inputValues[idx]));
idx++;
}
return arguments;
}
示例3: initializeStruct
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
static
private ObjectInspector[] initializeStruct(Evaluator evaluator, ObjectInspector inspector) throws UDFArgumentException {
StructObjectInspector structInspector = (StructObjectInspector)inspector;
List<FieldName> activeFields = evaluator.getActiveFields();
for(FieldName activeField : activeFields){
DataField field = evaluator.getDataField(activeField);
StructField structField;
try {
structField = structInspector.getStructFieldRef(activeField.getValue());
} catch(Exception e){
throw new UDFArgumentTypeException(0, "Missing struct field \"" + activeField.getValue() + "\"");
}
ObjectInspector structFieldInspector = structField.getFieldObjectInspector();
ObjectInspector.Category structFieldCategory = structFieldInspector.getCategory();
switch(structFieldCategory){
case PRIMITIVE:
break;
default:
throw new UDFArgumentTypeException(0, "Struct field \"" + activeField.getValue() + "\": Expected " + ObjectInspector.Category.PRIMITIVE + " type, got " + structFieldCategory + " type");
}
DataType dataType = getDataType(structFieldInspector);
if(!isConvertible(dataType, field.getDataType())){
throw new UDFArgumentTypeException(0, "Struct field \"" + activeField.getValue() + "\": Cannot convert " + dataType + " to " + field.getDataType());
}
}
return new ObjectInspector[]{structInspector};
}
示例4: initializePrimitiveList
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
static
private ObjectInspector[] initializePrimitiveList(Evaluator evaluator, ObjectInspector[] inspectors) throws UDFArgumentException {
List<FieldName> activeFields = evaluator.getActiveFields();
if(inspectors.length != activeFields.size()){
throw new UDFArgumentLengthException("Expected " + activeFields.size() + " arguments, got " + inspectors.length + " arguments");
}
int i = 0;
for(FieldName activeField : activeFields){
DataField field = evaluator.getDataField(activeField);
ObjectInspector inspector = inspectors[i];
ObjectInspector.Category category = inspector.getCategory();
switch(category){
case PRIMITIVE:
break;
default:
throw new UDFArgumentTypeException(i, "Expected " + ObjectInspector.Category.PRIMITIVE + " type, got " + category + " type");
}
DataType dataType = getDataType(inspector);
if(!isConvertible(dataType, field.getDataType())){
throw new UDFArgumentTypeException(i, "Cannot convert " + dataType + " to " + field.getDataType());
}
i++;
}
return inspectors;
}
示例5: initializeSimpleResult
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
/**
* @see #initializeArguments(Class, ObjectInspector[])
*/
static
public PrimitiveObjectInspector initializeSimpleResult(Class<? extends GenericUDF> clazz) throws UDFArgumentException {
Evaluator evaluator = getEvaluator(clazz);
FieldName targetField = evaluator.getTargetField();
DataField field = evaluator.getDataField(targetField);
return toObjectInspector(field.getDataType());
}
示例6: getDataFields
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
static
private Fields getDataFields(Evaluator evaluator, List<FieldName> dataFields){
Fields result = new Fields();
for(FieldName dataField : dataFields){
DataField field = evaluator.getDataField(dataField);
result = result.append(createFields(dataField.getValue(), field));
}
return result;
}