Search in sources :

Example 1 with MPartitionEvent

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

the class ObjectStore method markPartitionForEvent.

@Override
public Table markPartitionForEvent(String dbName, String tblName, Map<String, String> partName, PartitionEventType evtType) throws MetaException, UnknownTableException, InvalidPartitionException, UnknownPartitionException {
    LOG.debug("Begin executing markPartitionForEvent");
    boolean success = false;
    Table tbl = null;
    try {
        openTransaction();
        // Make sure dbName and tblName are valid.
        tbl = getTable(dbName, tblName);
        if (null == tbl) {
            throw new UnknownTableException("Table: " + tblName + " is not found.");
        }
        pm.makePersistent(new MPartitionEvent(dbName, tblName, getPartitionStr(tbl, partName), evtType.getValue()));
        success = commitTransaction();
        LOG.debug("Done executing markPartitionForEvent");
    } finally {
        if (!success) {
            rollbackTransaction();
        }
    }
    return tbl;
}
Also used : UnknownTableException(org.apache.hadoop.hive.metastore.api.UnknownTableException) Table(org.apache.hadoop.hive.metastore.api.Table) MVersionTable(org.apache.hadoop.hive.metastore.model.MVersionTable) MTable(org.apache.hadoop.hive.metastore.model.MTable) MPartitionEvent(org.apache.hadoop.hive.metastore.model.MPartitionEvent)

Example 2 with MPartitionEvent

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

the class ObjectStore method isPartitionMarkedForEvent.

@Override
public boolean isPartitionMarkedForEvent(String dbName, String tblName, Map<String, String> partName, PartitionEventType evtType) throws UnknownTableException, MetaException, InvalidPartitionException, UnknownPartitionException {
    boolean success = false;
    Query query = null;
    try {
        LOG.debug("Begin Executing isPartitionMarkedForEvent");
        openTransaction();
        query = pm.newQuery(MPartitionEvent.class, "dbName == t1 && tblName == t2 && partName == t3 && eventType == t4");
        query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3, int t4");
        // Make sure dbName and tblName are valid.
        Table tbl = getTable(dbName, tblName);
        if (null == tbl) {
            throw new UnknownTableException("Table: " + tblName + " is not found.");
        }
        Collection<MPartitionEvent> partEvents = (Collection<MPartitionEvent>) query.executeWithArray(dbName, tblName, getPartitionStr(tbl, partName), evtType.getValue());
        pm.retrieveAll(partEvents);
        success = commitTransaction();
        LOG.debug("Done executing isPartitionMarkedForEvent");
        return (partEvents != null && !partEvents.isEmpty()) ? true : false;
    } finally {
        if (!success) {
            rollbackTransaction();
        }
        if (query != null) {
            query.closeAll();
        }
    }
}
Also used : UnknownTableException(org.apache.hadoop.hive.metastore.api.UnknownTableException) Table(org.apache.hadoop.hive.metastore.api.Table) MVersionTable(org.apache.hadoop.hive.metastore.model.MVersionTable) MTable(org.apache.hadoop.hive.metastore.model.MTable) Query(javax.jdo.Query) MPartitionEvent(org.apache.hadoop.hive.metastore.model.MPartitionEvent) Collection(java.util.Collection)

Aggregations

Table (org.apache.hadoop.hive.metastore.api.Table)2 UnknownTableException (org.apache.hadoop.hive.metastore.api.UnknownTableException)2 MPartitionEvent (org.apache.hadoop.hive.metastore.model.MPartitionEvent)2 MTable (org.apache.hadoop.hive.metastore.model.MTable)2 MVersionTable (org.apache.hadoop.hive.metastore.model.MVersionTable)2 Collection (java.util.Collection)1 Query (javax.jdo.Query)1