本文整理了Java中org.apache.hadoop.hive.ql.metadata.Hive.getIndex()
方法的一些代码示例,展示了Hive.getIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hive.getIndex()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.metadata.Hive
类名称:Hive
方法名:getIndex
暂无
代码示例来源:origin: apache/drill
public Index getIndex(String baseTableName, String indexName) throws HiveException {
String[] names = Utilities.getDbTableName(baseTableName);
return this.getIndex(names[0], names[1], indexName);
}
代码示例来源:origin: apache/drill
Index idx = db.getIndex(baseTableName, indexName);
代码示例来源:origin: apache/drill
old_index = getIndex(tableName, indexName);
} catch (Exception e) {
代码示例来源:origin: apache/drill
private List<Task<?>> getIndexBuilderMapRed(String[] names, String indexName,
HashMap<String, String> partSpec) throws SemanticException {
try {
Index index = db.getIndex(names[0], names[1], indexName);
Table indexTbl = null;
String indexTableName = index.getIndexTableName();
if (indexTableName != null) {
indexTbl = getTable(Utilities.getDbTableName(index.getDbName(), indexTableName));
}
Table baseTbl = getTable(new String[] {index.getDbName(), index.getOrigTableName()});
String handlerCls = index.getIndexHandlerClass();
HiveIndexHandler handler = HiveUtils.getIndexHandler(conf, handlerCls);
List<Partition> indexTblPartitions = null;
List<Partition> baseTblPartitions = null;
if (indexTbl != null) {
indexTblPartitions = new ArrayList<Partition>();
baseTblPartitions = preparePartitions(baseTbl, partSpec,
indexTbl, db, indexTblPartitions);
}
List<Task<?>> ret = handler.generateIndexBuildTaskList(baseTbl,
index, indexTblPartitions, baseTblPartitions, indexTbl, getInputs(), getOutputs());
return ret;
} catch (Exception e) {
throw new SemanticException(e);
}
}
代码示例来源:origin: apache/drill
private void analyzeDropIndex(ASTNode ast) throws SemanticException {
String indexName = unescapeIdentifier(ast.getChild(0).getText());
String tableName = getUnescapedName((ASTNode) ast.getChild(1));
boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null);
// we want to signal an error if the index doesn't exist and we're
// configured not to ignore this
boolean throwException =
!ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT);
Table tbl = getTable(tableName, false);
if (throwException && tbl == null) {
throw new SemanticException(ErrorMsg.INVALID_TABLE.getMsg(tableName));
}
try {
Index idx = db.getIndex(tableName, indexName);
} catch (HiveException e) {
if (!(e.getCause() instanceof NoSuchObjectException)) {
throw new SemanticException(ErrorMsg.CANNOT_DROP_INDEX.getMsg("dropping index"), e);
}
if (throwException) {
throw new SemanticException(ErrorMsg.INVALID_INDEX.getMsg(indexName));
}
}
if (tbl != null) {
inputs.add(new ReadEntity(tbl));
}
DropIndexDesc dropIdxDesc = new DropIndexDesc(indexName, tableName, throwException);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
dropIdxDesc), conf));
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
public Index getIndex(String baseTableName, String indexName) throws HiveException {
String[] names = Utilities.getDbTableName(baseTableName);
return this.getIndex(names[0], names[1], indexName);
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
public Index getIndex(String qualifiedIndexName) throws HiveException {
String[] names = getQualifiedNames(qualifiedIndexName);
switch (names.length) {
case 3:
return getIndex(names[0], names[1], names[2]);
case 2:
return getIndex(getCurrentDatabase(), names[0], names[1]);
default:
throw new HiveException("Invalid index name:" + qualifiedIndexName);
}
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
public Index getIndex(String baseTableName, String indexName) throws HiveException {
Table t = newTable(baseTableName);
return this.getIndex(t.getDbName(), t.getTableName(), indexName);
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
private int alterIndex(Hive db, AlterIndexDesc alterIndex) throws HiveException {
String baseTableName = alterIndex.getBaseTableName();
String indexName = alterIndex.getIndexName();
Index idx = db.getIndex(baseTableName, indexName);
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
Index old_index = null;
try {
old_index = getIndex(dbName, tableName, indexName);
} catch (Exception e) {
代码示例来源:origin: com.facebook.presto.hive/hive-apache
old_index = getIndex(tableName, indexName);
} catch (Exception e) {
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
private int alterIndex(Hive db, AlterIndexDesc alterIndex) throws HiveException {
String dbName = alterIndex.getDbName();
String baseTableName = alterIndex.getBaseTableName();
String indexName = alterIndex.getIndexName();
Index idx = db.getIndex(dbName, baseTableName, indexName);
if (alterIndex.getOp() == AlterIndexDesc.AlterIndexTypes.ADDPROPS) {
idx.getParameters().putAll(alterIndex.getProps());
} else {
console.printError("Unsupported Alter commnad");
return 1;
}
// set last modified by properties
if (!updateModifiedParameters(idx.getParameters(), conf)) {
return 1;
}
try {
db.alterIndex(dbName, baseTableName, indexName, idx);
} catch (InvalidOperationException e) {
console.printError("Invalid alter operation: " + e.getMessage());
LOG.info("alter index: " + stringifyException(e));
return 1;
} catch (HiveException e) {
console.printError("Invalid alter operation: " + e.getMessage());
return 1;
}
return 0;
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
private List<Task<?>> getIndexBuilderMapRed(String baseTableName, String indexName,
HashMap<String, String> partSpec) throws SemanticException {
try {
String dbName = db.getCurrentDatabase();
Index index = db.getIndex(dbName, baseTableName, indexName);
Table indexTbl = db.getTable(dbName, index.getIndexTableName());
String baseTblName = index.getOrigTableName();
Table baseTbl = db.getTable(dbName, baseTblName);
String handlerCls = index.getIndexHandlerClass();
HiveIndexHandler handler = HiveUtils.getIndexHandler(conf, handlerCls);
List<Partition> indexTblPartitions = null;
List<Partition> baseTblPartitions = null;
if(indexTbl != null) {
indexTblPartitions = new ArrayList<Partition>();
baseTblPartitions = preparePartitions(baseTbl, partSpec,
indexTbl, db, indexTblPartitions);
}
List<Task<?>> ret = handler.generateIndexBuildTaskList(baseTbl,
index, indexTblPartitions, baseTblPartitions, indexTbl, getInputs(), getOutputs());
return ret;
} catch (Exception e) {
throw new SemanticException(e);
}
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
private void analyzeDropIndex(ASTNode ast) throws SemanticException {
String indexName = unescapeIdentifier(ast.getChild(0).getText());
String tableName = getUnescapedName((ASTNode)ast.getChild(1));
boolean ifExists = (ast.getFirstChildWithType(TOK_IFEXISTS) != null);
// we want to signal an error if the index doesn't exist and we're
// configured not to ignore this
boolean throwException =
!ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT);
if (throwException) {
try {
Index idx = db.getIndex(tableName, indexName);
} catch (HiveException e) {
throw new SemanticException(ErrorMsg.INVALID_INDEX.getMsg(indexName));
}
}
DropIndexDesc dropIdxDesc = new DropIndexDesc(indexName, tableName);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
dropIdxDesc), conf));
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
private List<Task<?>> getIndexBuilderMapRed(String[] names, String indexName,
HashMap<String, String> partSpec) throws SemanticException {
try {
Index index = db.getIndex(names[0], names[1], indexName);
Table indexTbl = null;
String indexTableName = index.getIndexTableName();
if (indexTableName != null) {
indexTbl = getTable(Utilities.getDbTableName(index.getDbName(), indexTableName));
}
Table baseTbl = getTable(new String[] {index.getDbName(), index.getOrigTableName()});
String handlerCls = index.getIndexHandlerClass();
HiveIndexHandler handler = HiveUtils.getIndexHandler(conf, handlerCls);
List<Partition> indexTblPartitions = null;
List<Partition> baseTblPartitions = null;
if (indexTbl != null) {
indexTblPartitions = new ArrayList<Partition>();
baseTblPartitions = preparePartitions(baseTbl, partSpec,
indexTbl, db, indexTblPartitions);
}
List<Task<?>> ret = handler.generateIndexBuildTaskList(baseTbl,
index, indexTblPartitions, baseTblPartitions, indexTbl, getInputs(), getOutputs());
return ret;
} catch (Exception e) {
throw new SemanticException(e);
}
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
private void analyzeDropIndex(ASTNode ast) throws SemanticException {
String indexName = unescapeIdentifier(ast.getChild(0).getText());
String tableName = getUnescapedName((ASTNode) ast.getChild(1));
boolean ifExists = (ast.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null);
// we want to signal an error if the index doesn't exist and we're
// configured not to ignore this
boolean throwException =
!ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT);
Table tbl = getTable(tableName, false);
if (throwException && tbl == null) {
throw new SemanticException(ErrorMsg.INVALID_TABLE.getMsg(tableName));
}
try {
Index idx = db.getIndex(tableName, indexName);
} catch (HiveException e) {
if (!(e.getCause() instanceof NoSuchObjectException)) {
throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg("dropping index"), e);
}
if (throwException) {
throw new SemanticException(ErrorMsg.INVALID_INDEX.getMsg(indexName));
}
}
if (tbl != null) {
inputs.add(new ReadEntity(tbl));
}
DropIndexDesc dropIdxDesc = new DropIndexDesc(indexName, tableName, throwException);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
dropIdxDesc), conf));
}
内容来源于网络,如有侵权,请联系作者删除!