本文整理汇总了Java中cascading.tuple.Fields.getComparators方法的典型用法代码示例。如果您正苦于以下问题:Java Fields.getComparators方法的具体用法?Java Fields.getComparators怎么用?Java Fields.getComparators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cascading.tuple.Fields
的用法示例。
在下文中一共展示了Fields.getComparators方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TupleTypeInfo
import cascading.tuple.Fields; //导入方法依赖的package包/类
public TupleTypeInfo(Fields schema) {
super(Tuple.class);
this.schema = schema;
this.fieldIndexes = new HashMap<String, Integer>();
if(schema.isDefined()) {
this.length = schema.size();
this.fieldTypes = new LinkedHashMap<String, FieldTypeInfo>(this.length);
Comparator[] comps = schema.getComparators();
Class[] typeClasses = schema.getTypesClasses();
for(int i=0; i<length; i++) {
String fieldName = getFieldName(i);
FieldTypeInfo fieldType = getFieldTypeInfo(i, typeClasses, comps);
this.fieldTypes.put(fieldName, fieldType);
this.fieldIndexes.put(fieldName, i);
}
}
else {
if(schema.isUnknown()) {
this.length = -1;
this.fieldTypes = new LinkedHashMap<String, FieldTypeInfo>(16);
this.fieldTypes.put("0", new FieldTypeInfo());
this.fieldIndexes.put("0", 0);
}
else {
throw new IllegalArgumentException("Unsupported Fields: "+schema);
}
}
}
示例2: registerKeyFields
import cascading.tuple.Fields; //导入方法依赖的package包/类
public String[] registerKeyFields(Fields keyFields) {
int[] keyPos;
if(keyFields.isAll()) {
keyPos = new int[this.schema.size()];
for(int i=0; i<keyPos.length; i++) {
keyPos[i] = i;
}
}
else {
keyPos = this.schema.getPos(keyFields);
}
String[] serdePos = new String[keyPos.length];
Comparator[] keyComps = keyFields.getComparators();
Class[] keyTypes = keyFields.getTypesClasses();
for(int j=0; j<keyPos.length; j++) {
String fieldName = getFieldName(keyPos[j]);
if(!this.fieldIndexes.containsKey(fieldName)) {
this.fieldIndexes.put(fieldName, keyPos[j]);
}
FieldTypeInfo fieldType = this.fieldTypes.get(fieldName);
if(fieldType == null) {
fieldType = new FieldTypeInfo();
this.fieldTypes.put(fieldName, fieldType);
}
// set serde position
serdePos[j] = fieldName;
if(keyTypes != null && keyTypes.length > j && keyTypes[j] != null) {
// set key type
fieldType.setFieldType(keyTypes[j]);
}
if(keyComps != null && keyComps.length > j && keyComps[j] != null) {
// set custom key comparator
fieldType.setCustomComparator(keyComps[j]);
}
}
return serdePos;
}