phoenix5-hive/src/main/java/org/apache/phoenix/hive/objectinspector/PhoenixObjectInspectorFactory.java [39:146]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class PhoenixObjectInspectorFactory {

    private static final Logger LOG = LoggerFactory.getLogger(PhoenixObjectInspectorFactory.class);

    private PhoenixObjectInspectorFactory() {

    }

    public static LazySimpleStructObjectInspector createStructObjectInspector(TypeInfo type,
                                                                              LazySerDeParameters
                                                                                      serdeParams) {
        StructTypeInfo structTypeInfo = (StructTypeInfo) type;
        List<String> fieldNames = structTypeInfo.getAllStructFieldNames();
        List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos();
        List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>
                (fieldTypeInfos.size());

        for (int i = 0; i < fieldTypeInfos.size(); i++) {
            fieldObjectInspectors.add(createObjectInspector(fieldTypeInfos.get(i), serdeParams));
        }

        return LazyObjectInspectorFactory.getLazySimpleStructObjectInspector(
                fieldNames, fieldObjectInspectors, null,
                serdeParams.getSeparators()[1],
                serdeParams, ObjectInspectorOptions.JAVA);
    }

    public static ObjectInspector createObjectInspector(TypeInfo type, LazySerDeParameters
            serdeParams) {
        ObjectInspector oi = null;

        if (LOG.isDebugEnabled()) {
            LOG.debug("Type : " + type);
        }

        switch (type.getCategory()) {
            case PRIMITIVE:
                switch (((PrimitiveTypeInfo) type).getPrimitiveCategory()) {
                    case BOOLEAN:
                        oi = new PhoenixBooleanObjectInspector();
                        break;
                    case BYTE:
                        oi = new PhoenixByteObjectInspector();
                        break;
                    case SHORT:
                        oi = new PhoenixShortObjectInspector();
                        break;
                    case INT:
                        oi = new PhoenixIntObjectInspector();
                        break;
                    case LONG:
                        oi = new PhoenixLongObjectInspector();
                        break;
                    case FLOAT:
                        oi = new PhoenixFloatObjectInspector();
                        break;
                    case DOUBLE:
                        oi = new PhoenixDoubleObjectInspector();
                        break;
                    case VARCHAR:
                        // same string
                    case STRING:
                        oi = new PhoenixStringObjectInspector(serdeParams.isEscaped(),
                                serdeParams.getEscapeChar());
                        break;
                    case CHAR:
                        oi = new PhoenixCharObjectInspector((PrimitiveTypeInfo)type);
                        break;
                    case DATE:
                        oi = new PhoenixDateObjectInspector();
                        break;
                    case TIMESTAMP:
                        oi = new PhoenixTimestampObjectInspector();
                        break;
                    case DECIMAL:
                        oi = new PhoenixDecimalObjectInspector((PrimitiveTypeInfo) type);
                        break;
                    case BINARY:
                        oi = new PhoenixBinaryObjectInspector();
                        break;
                    default:
                        throw new RuntimeException("Hive internal error. not supported data type " +
                                ": " + type);
                }

                break;
            case LIST:
                if (LOG.isDebugEnabled()) {
                    LOG.debug("List type started");
                }

                ObjectInspector listElementObjectInspector = createObjectInspector((
                        (ListTypeInfo) type).getListElementTypeInfo(), serdeParams);

                if (LOG.isDebugEnabled()) {
                    LOG.debug("List type ended");
                }

                oi = new PhoenixListObjectInspector(listElementObjectInspector, serdeParams
                        .getSeparators()[0], serdeParams);

                break;
            default:
                throw new RuntimeException("Hive internal error. not supported data type : " +
                        type);
        }

        return oi;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



phoenix5-hive4/src/main/java/org/apache/phoenix/hive/objectinspector/PhoenixObjectInspectorFactory.java [39:146]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class PhoenixObjectInspectorFactory {

    private static final Logger LOG = LoggerFactory.getLogger(PhoenixObjectInspectorFactory.class);

    private PhoenixObjectInspectorFactory() {

    }

    public static LazySimpleStructObjectInspector createStructObjectInspector(TypeInfo type,
                                                                              LazySerDeParameters
                                                                                      serdeParams) {
        StructTypeInfo structTypeInfo = (StructTypeInfo) type;
        List<String> fieldNames = structTypeInfo.getAllStructFieldNames();
        List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos();
        List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>
                (fieldTypeInfos.size());

        for (int i = 0; i < fieldTypeInfos.size(); i++) {
            fieldObjectInspectors.add(createObjectInspector(fieldTypeInfos.get(i), serdeParams));
        }

        return LazyObjectInspectorFactory.getLazySimpleStructObjectInspector(
                fieldNames, fieldObjectInspectors, null,
                serdeParams.getSeparators()[1],
                serdeParams, ObjectInspectorOptions.JAVA);
    }

    public static ObjectInspector createObjectInspector(TypeInfo type, LazySerDeParameters
            serdeParams) {
        ObjectInspector oi = null;

        if (LOG.isDebugEnabled()) {
            LOG.debug("Type : " + type);
        }

        switch (type.getCategory()) {
            case PRIMITIVE:
                switch (((PrimitiveTypeInfo) type).getPrimitiveCategory()) {
                    case BOOLEAN:
                        oi = new PhoenixBooleanObjectInspector();
                        break;
                    case BYTE:
                        oi = new PhoenixByteObjectInspector();
                        break;
                    case SHORT:
                        oi = new PhoenixShortObjectInspector();
                        break;
                    case INT:
                        oi = new PhoenixIntObjectInspector();
                        break;
                    case LONG:
                        oi = new PhoenixLongObjectInspector();
                        break;
                    case FLOAT:
                        oi = new PhoenixFloatObjectInspector();
                        break;
                    case DOUBLE:
                        oi = new PhoenixDoubleObjectInspector();
                        break;
                    case VARCHAR:
                        // same string
                    case STRING:
                        oi = new PhoenixStringObjectInspector(serdeParams.isEscaped(),
                                serdeParams.getEscapeChar());
                        break;
                    case CHAR:
                        oi = new PhoenixCharObjectInspector((PrimitiveTypeInfo)type);
                        break;
                    case DATE:
                        oi = new PhoenixDateObjectInspector();
                        break;
                    case TIMESTAMP:
                        oi = new PhoenixTimestampObjectInspector();
                        break;
                    case DECIMAL:
                        oi = new PhoenixDecimalObjectInspector((PrimitiveTypeInfo) type);
                        break;
                    case BINARY:
                        oi = new PhoenixBinaryObjectInspector();
                        break;
                    default:
                        throw new RuntimeException("Hive internal error. not supported data type " +
                                ": " + type);
                }

                break;
            case LIST:
                if (LOG.isDebugEnabled()) {
                    LOG.debug("List type started");
                }

                ObjectInspector listElementObjectInspector = createObjectInspector((
                        (ListTypeInfo) type).getListElementTypeInfo(), serdeParams);

                if (LOG.isDebugEnabled()) {
                    LOG.debug("List type ended");
                }

                oi = new PhoenixListObjectInspector(listElementObjectInspector, serdeParams
                        .getSeparators()[0], serdeParams);

                break;
            default:
                throw new RuntimeException("Hive internal error. not supported data type : " +
                        type);
        }

        return oi;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



