Search in sources :

Example 6 with MIndex

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

the class ObjectStore method alterIndex.

@Override
public void alterIndex(String dbname, String baseTblName, String name, Index newIndex) throws InvalidObjectException, MetaException {
    boolean success = false;
    try {
        openTransaction();
        name = HiveStringUtils.normalizeIdentifier(name);
        baseTblName = HiveStringUtils.normalizeIdentifier(baseTblName);
        dbname = HiveStringUtils.normalizeIdentifier(dbname);
        MIndex newi = convertToMIndex(newIndex);
        if (newi == null) {
            throw new InvalidObjectException("new index is invalid");
        }
        MIndex oldi = getMIndex(dbname, baseTblName, name);
        if (oldi == null) {
            throw new MetaException("index " + name + " doesn't exist");
        }
        // For now only alter parameters are allowed
        oldi.setParameters(newi.getParameters());
        // commit the changes
        success = commitTransaction();
    } finally {
        if (!success) {
            rollbackTransaction();
        }
    }
}
Also used : MIndex(org.apache.hadoop.hive.metastore.model.MIndex) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 7 with MIndex

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

the class ObjectStore method getIndexes.

@Override
public List<Index> getIndexes(String dbName, String origTableName, int max) throws MetaException {
    boolean success = false;
    Query query = null;
    try {
        LOG.debug("Executing getIndexes");
        openTransaction();
        dbName = HiveStringUtils.normalizeIdentifier(dbName);
        origTableName = HiveStringUtils.normalizeIdentifier(origTableName);
        query = pm.newQuery(MIndex.class, "origTable.tableName == t1 && origTable.database.name == t2");
        query.declareParameters("java.lang.String t1, java.lang.String t2");
        List<MIndex> mIndexes = (List<MIndex>) query.execute(origTableName, dbName);
        pm.retrieveAll(mIndexes);
        List<Index> indexes = new ArrayList<Index>(mIndexes.size());
        for (MIndex mIdx : mIndexes) {
            indexes.add(this.convertToIndex(mIdx));
        }
        success = commitTransaction();
        LOG.debug("Done retrieving all objects for getIndexes");
        return indexes;
    } finally {
        if (!success) {
            rollbackTransaction();
        }
        if (query != null) {
            query.closeAll();
        }
    }
}
Also used : Query(javax.jdo.Query) MIndex(org.apache.hadoop.hive.metastore.model.MIndex) ArrayList(java.util.ArrayList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) MIndex(org.apache.hadoop.hive.metastore.model.MIndex) Index(org.apache.hadoop.hive.metastore.api.Index)

Example 8 with MIndex

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

the class ObjectStore method convertToIndex.

private Index convertToIndex(MIndex mIndex) throws MetaException {
    if (mIndex == null) {
        return null;
    }
    MTable origTable = mIndex.getOrigTable();
    MTable indexTable = mIndex.getIndexTable();
    return new Index(mIndex.getIndexName(), mIndex.getIndexHandlerClass(), origTable.getDatabase().getName(), origTable.getTableName(), mIndex.getCreateTime(), mIndex.getLastAccessTime(), indexTable.getTableName(), convertToStorageDescriptor(mIndex.getSd()), mIndex.getParameters(), mIndex.getDeferredRebuild());
}
Also used : MTable(org.apache.hadoop.hive.metastore.model.MTable) MIndex(org.apache.hadoop.hive.metastore.model.MIndex) Index(org.apache.hadoop.hive.metastore.api.Index)

Aggregations

MIndex (org.apache.hadoop.hive.metastore.model.MIndex)8 Index (org.apache.hadoop.hive.metastore.api.Index)3 MTable (org.apache.hadoop.hive.metastore.model.MTable)3 Query (javax.jdo.Query)2 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)1 MStorageDescriptor (org.apache.hadoop.hive.metastore.model.MStorageDescriptor)1 MStringList (org.apache.hadoop.hive.metastore.model.MStringList)1