arrowTypeToProtobuf
ArrowTypeHelper.java:316
org.apache.arrow.gandiva.expression.ArrowTypeHelper.arrowTypeToProtobuf
/**
* Converts an arrow type into a protobuf.
*
* @param arrowType Arrow type to be converted
* @return Protobuf representing the arrow type
*/
public static GandivaTypes.ExtGandivaType arrowTypeToProtobuf(ArrowType arrowType)
throws GandivaException {
GandivaTypes.ExtGandivaType.Builder builder = GandivaTypes.ExtGandivaType.newBuilder();
byte typeId = arrowType.getTypeID().getFlatbufID();
switch (typeId) {
case Type.NONE: { // 0
builder.setType(GandivaTypes.GandivaType.NONE);
break;
}
case Type.Null: { // 1
// TODO: Need to handle this later
break;
}
case Type.Int: { // 2
ArrowTypeHelper.initArrowTypeInt((ArrowType.Int) arrowType, builder);
break;
}
case Type.FloatingPoint: { // 3
ArrowTypeHelper.initArrowTypeFloat((ArrowType.FloatingPoint) arrowType, builder);
break;
}
case Type.Binary: { // 4
builder.setType(GandivaTypes.GandivaType.BINARY);
break;
}
case Type.Utf8: { // 5
builder.setType(GandivaTypes.GandivaType.UTF8);
break;
}
case Type.Bool: { // 6
builder.setType(GandivaTypes.GandivaType.BOOL);
break;
}
case Type.Decimal: { // 7
ArrowTypeHelper.initArrowTypeDecimal((ArrowType.Decimal) arrowType, builder);
break;
}
case Type.Date: { // 8
ArrowTypeHelper.initArrowTypeDate((ArrowType.Date) arrowType, builder);
break;
}
case Type.Time: { // 9
ArrowTypeHelper.initArrowTypeTime((ArrowType.Time) arrowType, builder);
break;
}
case Type.Timestamp: { // 10
ArrowTypeHelper.initArrowTypeTimestamp((ArrowType.Timestamp) arrowType, builder);
break;
}
case Type.Interval: { // 11
ArrowTypeHelper.initArrowTypeInterval((ArrowType.Interval) arrowType, builder);
break;
}
case Type.List: { // 12
break;
}
case Type.Struct_: { // 13
break;
}
case Type.Union: { // 14
break;
}
case Type.FixedSizeBinary: { // 15
break;
}
case Type.FixedSizeList: { // 16
break;
}
case Type.Map: { // 17
break;
}
default: {
break;
}
}
if (!builder.hasType()) {
// type has not been set
// throw an exception
throw new UnsupportedTypeException("Unsupported type " + arrowType.toString());
}
return builder.build();
}
|