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();
}
}
}
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();
}
}
}
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());
}
Aggregations