Search in sources :

Example 1 with OptionalCompactionInfoStruct

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());
}
Also used : DatabaseBuilder(org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder) Table(org.apache.hadoop.hive.metastore.api.Table) GetLatestCommittedCompactionInfoRequest(org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoRequest) Database(org.apache.hadoop.hive.metastore.api.Database) CompactionInfoStruct(org.apache.hadoop.hive.metastore.api.CompactionInfoStruct) OptionalCompactionInfoStruct(org.apache.hadoop.hive.metastore.api.OptionalCompactionInfoStruct) FindNextCompactRequest(org.apache.hadoop.hive.metastore.api.FindNextCompactRequest) OptionalCompactionInfoStruct(org.apache.hadoop.hive.metastore.api.OptionalCompactionInfoStruct) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder) GetLatestCommittedCompactionInfoResponse(org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoResponse) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

Example 2 with OptionalCompactionInfoStruct

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;
}
Also used : CompactionInfoStruct(org.apache.hadoop.hive.metastore.api.CompactionInfoStruct) OptionalCompactionInfoStruct(org.apache.hadoop.hive.metastore.api.OptionalCompactionInfoStruct) OptionalCompactionInfoStruct(org.apache.hadoop.hive.metastore.api.OptionalCompactionInfoStruct)

Aggregations

CompactionInfoStruct (org.apache.hadoop.hive.metastore.api.CompactionInfoStruct)2 OptionalCompactionInfoStruct (org.apache.hadoop.hive.metastore.api.OptionalCompactionInfoStruct)2 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)1 Database (org.apache.hadoop.hive.metastore.api.Database)1 FindNextCompactRequest (org.apache.hadoop.hive.metastore.api.FindNextCompactRequest)1 GetLatestCommittedCompactionInfoRequest (org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoRequest)1 GetLatestCommittedCompactionInfoResponse (org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoResponse)1 Table (org.apache.hadoop.hive.metastore.api.Table)1 DatabaseBuilder (org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder)1 TableBuilder (org.apache.hadoop.hive.metastore.client.builder.TableBuilder)1 Test (org.junit.Test)1