use of org.apache.hadoop.hive.metastore.api.OptionalCompactionInfoStruct in project hive by apache.
the class TestHiveMetaStoreTxns method testGetLatestCommittedCompactionInfo.
@Test
public void testGetLatestCommittedCompactionInfo() throws Exception {
final String dbName = "mydb";
final String tblName = "mytable";
Database db = new DatabaseBuilder().setName(dbName).build(conf);
db.unsetCatalogName();
client.createDatabase(db);
Table tbl = new TableBuilder().setDbName(dbName).setTableName(tblName).addCol("id", "int").addCol("name", "string").setType(TableType.MANAGED_TABLE.name()).build(conf);
client.createTable(tbl);
tbl = client.getTable(dbName, tblName);
client.compact2(tbl.getDbName(), tbl.getTableName(), null, CompactionType.MINOR, new HashMap<>());
FindNextCompactRequest compactRequest = new FindNextCompactRequest();
compactRequest.setWorkerId("myworker");
OptionalCompactionInfoStruct optionalCi = client.findNextCompact(compactRequest);
client.markCleaned(optionalCi.getCi());
GetLatestCommittedCompactionInfoRequest rqst = new GetLatestCommittedCompactionInfoRequest();
// Test invalid inputs
final String invalidTblName = "invalid";
rqst.setDbname(dbName);
Assert.assertThrows(MetaException.class, () -> client.getLatestCommittedCompactionInfo(rqst));
rqst.setTablename(invalidTblName);
GetLatestCommittedCompactionInfoResponse response = client.getLatestCommittedCompactionInfo(rqst);
Assert.assertNotNull(response);
Assert.assertEquals(0, response.getCompactionsSize());
// Test normal inputs
rqst.setTablename(tblName);
response = client.getLatestCommittedCompactionInfo(rqst);
Assert.assertNotNull(response);
Assert.assertEquals(1, response.getCompactionsSize());
CompactionInfoStruct lci = response.getCompactions().get(0);
Assert.assertEquals(1, lci.getId());
Assert.assertNull(lci.getPartitionname());
Assert.assertEquals(CompactionType.MINOR, lci.getType());
}
use of org.apache.hadoop.hive.metastore.api.OptionalCompactionInfoStruct in project hive by apache.
the class CompactionInfo method compactionInfoToOptionalStruct.
public static OptionalCompactionInfoStruct compactionInfoToOptionalStruct(CompactionInfo ci) {
CompactionInfoStruct cis = compactionInfoToStruct(ci);
OptionalCompactionInfoStruct ocis = new OptionalCompactionInfoStruct();
if (cis != null) {
ocis.setCi(cis);
}
return ocis;
}
Aggregations