in src/org/apache/pig/backend/hadoop/HDataType.java [131:249]
public static PigNullableWritable getWritableComparableTypes(Object o, byte keyType) throws ExecException{
byte newKeyType = keyType;
if (o==null)
newKeyType = DataType.NULL;
switch (newKeyType) {
case DataType.BAG:
return new NullableBag((DataBag)o);
case DataType.BOOLEAN:
return new NullableBooleanWritable((Boolean)o);
case DataType.BYTEARRAY:
return new NullableBytesWritable(o);
case DataType.CHARARRAY:
return new NullableText((String)o);
case DataType.DOUBLE:
return new NullableDoubleWritable((Double)o);
case DataType.FLOAT:
return new NullableFloatWritable((Float)o);
case DataType.INTEGER:
return new NullableIntWritable((Integer)o);
case DataType.LONG:
return new NullableLongWritable((Long)o);
case DataType.BIGINTEGER:
return new NullableBigIntegerWritable((BigInteger)o);
case DataType.BIGDECIMAL:
return new NullableBigDecimalWritable((BigDecimal)o);
case DataType.DATETIME:
return new NullableDateTimeWritable((DateTime)o);
case DataType.TUPLE:
return new NullableTuple((Tuple)o);
case DataType.MAP: {
int errCode = 1068;
String msg = "Using Map as key not supported.";
throw new ExecException(msg, errCode, PigException.INPUT);
}
case DataType.NULL:
switch (keyType) {
case DataType.BAG:
NullableBag nbag = new NullableBag();
nbag.setNull(true);
return nbag;
case DataType.BOOLEAN:
NullableBooleanWritable nboolWrit = new NullableBooleanWritable();
nboolWrit.setNull(true);
return nboolWrit;
case DataType.BYTEARRAY:
NullableBytesWritable nBytesWrit = new NullableBytesWritable();
nBytesWrit.setNull(true);
return nBytesWrit;
case DataType.CHARARRAY:
NullableText nStringWrit = new NullableText();
nStringWrit.setNull(true);
return nStringWrit;
case DataType.DOUBLE:
NullableDoubleWritable nDoubleWrit = new NullableDoubleWritable();
nDoubleWrit.setNull(true);
return nDoubleWrit;
case DataType.FLOAT:
NullableFloatWritable nFloatWrit = new NullableFloatWritable();
nFloatWrit.setNull(true);
return nFloatWrit;
case DataType.INTEGER:
NullableIntWritable nIntWrit = new NullableIntWritable();
nIntWrit.setNull(true);
return nIntWrit;
case DataType.BIGINTEGER:
NullableBigIntegerWritable nBigIntWrit = new NullableBigIntegerWritable();
nBigIntWrit.setNull(true);
return nBigIntWrit;
case DataType.BIGDECIMAL:
NullableBigDecimalWritable nBigDecWrit = new NullableBigDecimalWritable();
nBigDecWrit.setNull(true);
return nBigDecWrit;
case DataType.LONG:
NullableLongWritable nLongWrit = new NullableLongWritable();
nLongWrit.setNull(true);
return nLongWrit;
case DataType.DATETIME:
NullableDateTimeWritable nDateTimeWrit = new NullableDateTimeWritable();
nDateTimeWrit.setNull(true);
return nDateTimeWrit;
case DataType.TUPLE:
NullableTuple ntuple = new NullableTuple();
ntuple.setNull(true);
return ntuple;
case DataType.MAP: {
int errCode = 1068;
String msg = "Using Map as key not supported.";
throw new ExecException(msg, errCode, PigException.INPUT);
}
}
break;
default:
if (typeToName == null) typeToName = DataType.genTypeToNameMap();
int errCode = 2044;
String msg = "The type "
+ typeToName.get(keyType)
+ " cannot be collected as a Key type";
throw new ExecException(msg, errCode, PigException.BUG);
}
// should never come here
return null;
}