Search in sources :

Example 1 with MType

use of org.apache.hadoop.hive.metastore.model.MType in project hive by apache.

the class ObjectStore method getType.

private Type getType(MType mtype) {
    List<FieldSchema> fields = new ArrayList<FieldSchema>();
    if (mtype.getFields() != null) {
        for (MFieldSchema field : mtype.getFields()) {
            fields.add(new FieldSchema(field.getName(), field.getType(), field.getComment()));
        }
    }
    Type ret = new Type();
    ret.setName(mtype.getName());
    ret.setType1(mtype.getType1());
    ret.setType2(mtype.getType2());
    ret.setFields(fields);
    return ret;
}
Also used : FileMetadataExprType(org.apache.hadoop.hive.metastore.api.FileMetadataExprType) ResourceType(org.apache.hadoop.hive.metastore.api.ResourceType) PrincipalType(org.apache.hadoop.hive.metastore.api.PrincipalType) Type(org.apache.hadoop.hive.metastore.api.Type) HiveObjectType(org.apache.hadoop.hive.metastore.api.HiveObjectType) FunctionType(org.apache.hadoop.hive.metastore.api.FunctionType) MType(org.apache.hadoop.hive.metastore.model.MType) PartitionEventType(org.apache.hadoop.hive.metastore.api.PartitionEventType) MFieldSchema(org.apache.hadoop.hive.metastore.model.MFieldSchema) MFieldSchema(org.apache.hadoop.hive.metastore.model.MFieldSchema) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) ArrayList(java.util.ArrayList)

Example 2 with MType

use of org.apache.hadoop.hive.metastore.model.MType in project hive by apache.

the class ObjectStore method createType.

@Override
public boolean createType(Type type) {
    boolean success = false;
    MType mtype = getMType(type);
    boolean commited = false;
    try {
        openTransaction();
        pm.makePersistent(mtype);
        commited = commitTransaction();
        success = true;
    } finally {
        if (!commited) {
            rollbackTransaction();
        }
    }
    return success;
}
Also used : MType(org.apache.hadoop.hive.metastore.model.MType)

Example 3 with MType

use of org.apache.hadoop.hive.metastore.model.MType in project hive by apache.

the class ObjectStore method getType.

@Override
public Type getType(String typeName) {
    Type type = null;
    boolean commited = false;
    Query query = null;
    try {
        openTransaction();
        query = pm.newQuery(MType.class, "name == typeName");
        query.declareParameters("java.lang.String typeName");
        query.setUnique(true);
        MType mtype = (MType) query.execute(typeName.trim());
        pm.retrieve(type);
        if (mtype != null) {
            type = getType(mtype);
        }
        commited = commitTransaction();
    } finally {
        if (!commited) {
            rollbackTransaction();
        }
        if (query != null) {
            query.closeAll();
        }
    }
    return type;
}
Also used : FileMetadataExprType(org.apache.hadoop.hive.metastore.api.FileMetadataExprType) ResourceType(org.apache.hadoop.hive.metastore.api.ResourceType) PrincipalType(org.apache.hadoop.hive.metastore.api.PrincipalType) Type(org.apache.hadoop.hive.metastore.api.Type) HiveObjectType(org.apache.hadoop.hive.metastore.api.HiveObjectType) FunctionType(org.apache.hadoop.hive.metastore.api.FunctionType) MType(org.apache.hadoop.hive.metastore.model.MType) PartitionEventType(org.apache.hadoop.hive.metastore.api.PartitionEventType) MType(org.apache.hadoop.hive.metastore.model.MType) Query(javax.jdo.Query)

Example 4 with MType

use of org.apache.hadoop.hive.metastore.model.MType in project hive by apache.

the class ObjectStore method dropType.

@Override
public boolean dropType(String typeName) {
    boolean success = false;
    Query query = null;
    try {
        openTransaction();
        query = pm.newQuery(MType.class, "name == typeName");
        query.declareParameters("java.lang.String typeName");
        query.setUnique(true);
        MType type = (MType) query.execute(typeName.trim());
        pm.retrieve(type);
        if (type != null) {
            pm.deletePersistent(type);
        }
        success = commitTransaction();
    } catch (JDOObjectNotFoundException e) {
        success = commitTransaction();
        LOG.debug("type not found " + typeName, e);
    } finally {
        if (!success) {
            rollbackTransaction();
        }
        if (query != null) {
            query.closeAll();
        }
    }
    return success;
}
Also used : MType(org.apache.hadoop.hive.metastore.model.MType) Query(javax.jdo.Query) JDOObjectNotFoundException(javax.jdo.JDOObjectNotFoundException)

Aggregations

MType (org.apache.hadoop.hive.metastore.model.MType)4 Query (javax.jdo.Query)2 FileMetadataExprType (org.apache.hadoop.hive.metastore.api.FileMetadataExprType)2 FunctionType (org.apache.hadoop.hive.metastore.api.FunctionType)2 HiveObjectType (org.apache.hadoop.hive.metastore.api.HiveObjectType)2 PartitionEventType (org.apache.hadoop.hive.metastore.api.PartitionEventType)2 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)2 ResourceType (org.apache.hadoop.hive.metastore.api.ResourceType)2 Type (org.apache.hadoop.hive.metastore.api.Type)2 ArrayList (java.util.ArrayList)1 JDOObjectNotFoundException (javax.jdo.JDOObjectNotFoundException)1 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)1 MFieldSchema (org.apache.hadoop.hive.metastore.model.MFieldSchema)1