use of org.apache.hadoop.hive.metastore.api.GetPartitionsPsWithAuthResponse in project hive by apache.
the class TestHiveMetaStoreClient method listPartitionsWithAuthInfoRequest.
public GetPartitionsPsWithAuthResponse listPartitionsWithAuthInfoRequest(GetPartitionsPsWithAuthRequest req) throws MetaException, TException, NoSuchObjectException {
assertNotNull(req.getId());
assertNotNull(req.getValidWriteIdList());
GetPartitionsPsWithAuthResponse res = new GetPartitionsPsWithAuthResponse();
return res;
}
use of org.apache.hadoop.hive.metastore.api.GetPartitionsPsWithAuthResponse in project hive by apache.
the class SessionHiveMetaStoreClient method listPartitionsWithAuthInfoRequest.
@Override
public GetPartitionsPsWithAuthResponse listPartitionsWithAuthInfoRequest(GetPartitionsPsWithAuthRequest req) throws MetaException, TException, NoSuchObjectException {
org.apache.hadoop.hive.metastore.api.Table table = getTempTable(req.getDbName(), req.getTblName());
if (table == null) {
return super.listPartitionsWithAuthInfoRequest(req);
}
TempTable tt = getPartitionedTempTable(table);
List<Partition> partitions = tt.listPartitionsWithAuthInfo(req.getUserName(), req.getGroupNames());
GetPartitionsPsWithAuthResponse response = new GetPartitionsPsWithAuthResponse();
response.setPartitions(getPartitionsForMaxParts(req.getTblName(), partitions, req.getMaxParts()));
return response;
}
use of org.apache.hadoop.hive.metastore.api.GetPartitionsPsWithAuthResponse in project hive by apache.
the class SessionHiveMetaStoreClient method listPartitionsWithAuthInfoRequestInternal.
@Override
protected GetPartitionsPsWithAuthResponse listPartitionsWithAuthInfoRequestInternal(GetPartitionsPsWithAuthRequest req) throws TException {
Map<Object, Object> queryCache = getQueryCache();
if (queryCache != null) {
// Retrieve or populate cache
CacheKey cacheKey = new CacheKey(KeyType.LIST_PARTITIONS_AUTH_INFO_REQ, req);
GetPartitionsPsWithAuthResponse v = (GetPartitionsPsWithAuthResponse) queryCache.get(cacheKey);
if (v == null) {
v = super.listPartitionsWithAuthInfoRequestInternal(req);
queryCache.put(cacheKey, v);
} else {
LOG.debug("Query level HMS cache: method=listPartitionsWithAuthInfoRequestInternal, dbName={}, tblName={}, partVals={}", req.getDbName(), req.getTblName(), req.getPartVals());
}
return v;
}
return super.listPartitionsWithAuthInfoRequestInternal(req);
}
use of org.apache.hadoop.hive.metastore.api.GetPartitionsPsWithAuthResponse in project hive by apache.
the class Hive method getPartitions.
/**
* get all the partitions that the table has
*
* @param tbl
* object for which partition is needed
* @return list of partition objects
*/
public List<Partition> getPartitions(Table tbl) throws HiveException {
PerfLogger perfLogger = SessionState.getPerfLogger();
perfLogger.perfLogBegin(CLASS_NAME, PerfLogger.HIVE_GET_PARTITIONS);
try {
if (tbl.isPartitioned()) {
List<org.apache.hadoop.hive.metastore.api.Partition> tParts;
try {
GetPartitionsPsWithAuthRequest req = new GetPartitionsPsWithAuthRequest();
req.setTblName(tbl.getTableName());
req.setDbName(tbl.getDbName());
req.setUserName(getUserName());
req.setMaxParts((short) -1);
req.setGroupNames(getGroupNames());
if (AcidUtils.isTransactionalTable(tbl)) {
ValidWriteIdList validWriteIdList = getValidWriteIdList(tbl.getDbName(), tbl.getTableName());
req.setValidWriteIdList(validWriteIdList != null ? validWriteIdList.toString() : null);
req.setId(tbl.getTTable().getId());
}
GetPartitionsPsWithAuthResponse res = getMSC().listPartitionsWithAuthInfoRequest(req);
tParts = res.getPartitions();
} catch (Exception e) {
LOG.error("Failed getPartitions", e);
throw new HiveException(e);
}
List<Partition> parts = new ArrayList<>(tParts.size());
for (org.apache.hadoop.hive.metastore.api.Partition tpart : tParts) {
parts.add(new Partition(tbl, tpart));
}
return parts;
} else {
return Collections.singletonList(new Partition(tbl));
}
} finally {
perfLogger.perfLogEnd(CLASS_NAME, PerfLogger.HIVE_GET_PARTITIONS, "HS2-cache");
}
}
Aggregations