Search in sources :

Example 1 with GetPartitionsByNamesRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest in project hive by apache.

the class TestHiveMetaStoreClientApiArgumentsChecker method testGetPartitionsByNames2.

@Test
public void testGetPartitionsByNames2() throws HiveException {
    GetPartitionsByNamesRequest req = new GetPartitionsByNamesRequest();
    req.setDb_name(DB_NAME);
    req.setTbl_name(TABLE_NAME);
    hive.getPartitionsByNames(DB_NAME, TABLE_NAME, null, t);
}
Also used : GetPartitionsByNamesRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest) Test(org.junit.Test)

Example 2 with GetPartitionsByNamesRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest in project hive by apache.

the class TestHiveMetaStoreClientApiArgumentsChecker method testGetPartitionsByNames1.

@Test
public void testGetPartitionsByNames1() throws HiveException {
    GetPartitionsByNamesRequest req = new GetPartitionsByNamesRequest();
    req.setDb_name(DB_NAME);
    req.setTbl_name(TABLE_NAME);
    hive.getPartitionsByNames(req, t);
}
Also used : GetPartitionsByNamesRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest) Test(org.junit.Test)

Example 3 with GetPartitionsByNamesRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest in project hive by apache.

the class TestHiveMetaStoreClientApiArgumentsChecker method testGetPartitionsByNames3.

@Test
public void testGetPartitionsByNames3() throws HiveException {
    GetPartitionsByNamesRequest req = new GetPartitionsByNamesRequest();
    req.setDb_name(DB_NAME);
    req.setTbl_name(TABLE_NAME);
    hive.getPartitionsByNames(t, new ArrayList<>(), true);
}
Also used : GetPartitionsByNamesRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest) Test(org.junit.Test)

Example 4 with GetPartitionsByNamesRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest in project hive by apache.

the class SessionHiveMetaStoreClient method getPartitionsByNamesInternal.

@Override
protected GetPartitionsByNamesResult getPartitionsByNamesInternal(GetPartitionsByNamesRequest rqst) throws TException {
    Map<Object, Object> queryCache = getQueryCache();
    if (queryCache != null) {
        MapWrapper cache = new MapWrapper(queryCache);
        // 1) Retrieve from the cache those ids present, gather the rest
        Pair<List<Partition>, List<String>> p = getPartitionsByNamesCache(cache, rqst, null);
        List<String> partitionsMissing = p.getRight();
        List<Partition> partitions = p.getLeft();
        // 2) If they were all present in the cache, return
        if (partitionsMissing.isEmpty()) {
            return new GetPartitionsByNamesResult(partitions);
        }
        // 3) If they were not, gather the remaining
        GetPartitionsByNamesRequest newRqst = new GetPartitionsByNamesRequest(rqst);
        newRqst.setNames(partitionsMissing);
        GetPartitionsByNamesResult r = super.getPartitionsByNamesInternal(newRqst);
        // 4) Populate the cache
        List<Partition> newPartitions = loadPartitionsByNamesCache(cache, r, rqst, null);
        // 5) Sort result (in case there is any assumption) and return
        return computePartitionsByNamesFinal(rqst, partitions, newPartitions);
    }
    return super.getPartitionsByNamesInternal(rqst);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) GetPartitionsByNamesRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest) ArrayList(java.util.ArrayList) ValidTxnWriteIdList(org.apache.hadoop.hive.common.ValidTxnWriteIdList) ValidTxnList(org.apache.hadoop.hive.common.ValidTxnList) ValidWriteIdList(org.apache.hadoop.hive.common.ValidWriteIdList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) GetPartitionsByNamesResult(org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesResult)

Example 5 with GetPartitionsByNamesRequest

use of org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest in project hive by apache.

the class HiveMetaStoreClientWithLocalCache method getPartitionsByNamesInternal.

@Override
protected GetPartitionsByNamesResult getPartitionsByNamesInternal(GetPartitionsByNamesRequest rqst) throws TException {
    if (isCacheEnabledAndInitialized()) {
        String dbName = parseDbName(rqst.getDb_name(), conf)[1];
        TableWatermark watermark = new TableWatermark(rqst.getValidWriteIdList(), getTable(dbName, rqst.getTbl_name()).getId());
        if (watermark.isValid()) {
            CacheWrapper cache = new CacheWrapper(mscLocalCache);
            // 1) Retrieve from the cache those ids present, gather the rest
            Pair<List<Partition>, List<String>> p = getPartitionsByNamesCache(cache, rqst, watermark);
            List<String> partitionsMissing = p.getRight();
            List<Partition> partitions = p.getLeft();
            // 2) If they were all present in the cache, return
            if (partitionsMissing.isEmpty()) {
                return new GetPartitionsByNamesResult(partitions);
            }
            // 3) If they were not, gather the remaining
            GetPartitionsByNamesRequest newRqst = new GetPartitionsByNamesRequest(rqst);
            newRqst.setNames(partitionsMissing);
            GetPartitionsByNamesResult r = super.getPartitionsByNamesInternal(newRqst);
            // 4) Populate the cache
            List<Partition> newPartitions = loadPartitionsByNamesCache(cache, r, rqst, watermark);
            // 5) Sort result (in case there is any assumption) and return
            GetPartitionsByNamesResult result = computePartitionsByNamesFinal(rqst, partitions, newPartitions);
            if (LOG.isDebugEnabled() && recordStats) {
                LOG.debug(cacheObjName + ": " + mscLocalCache.stats().toString());
            }
            return result;
        }
    }
    return super.getPartitionsByNamesInternal(rqst);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) GetPartitionsByNamesRequest(org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest) List(java.util.List) ArrayList(java.util.ArrayList) GetPartitionsByNamesResult(org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesResult)

Aggregations

GetPartitionsByNamesRequest (org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest)7 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 JDODataStoreException (javax.jdo.JDODataStoreException)2 ValidWriteIdList (org.apache.hadoop.hive.common.ValidWriteIdList)2 HiveMetaException (org.apache.hadoop.hive.metastore.HiveMetaException)2 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)2 GetPartitionsByNamesResult (org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesResult)2 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)2 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)2 Partition (org.apache.hadoop.hive.metastore.api.Partition)2 LockException (org.apache.hadoop.hive.ql.lockmgr.LockException)2 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)2 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)2