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