*
* @param typeInfo
* @return
*/
public static BinarySortableSerDe createBinarySerde(TypeInfo typeInfo){
BinarySortableSerDe serde = new BinarySortableSerDe();
StringBuffer nameSb = new StringBuffer();
StringBuffer typeSb = new StringBuffer();
StructTypeInfo sti = (StructTypeInfo) typeInfo;
for (String name : sti.getAllStructFieldNames()) {
nameSb.append(name);
nameSb.append(',');
}
for (TypeInfo info : sti.getAllStructFieldTypeInfos()) {
typeSb.append(info.toString());
typeSb.append(',');
}
Properties tbl = new Properties();
String names = nameSb.length() > 0 ? nameSb.substring(0,
nameSb.length() - 1) : "";
String types = typeSb.length() > 0 ? typeSb.substring(0,
typeSb.length() - 1) : "";
tbl.setProperty(serdeConstants.LIST_COLUMNS, names);
tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, types);
try {
serde.initialize(null, tbl);
} catch (SerDeException e) {
throw new CrunchRuntimeException("Unable to initialize binary serde");
}
return serde;