Search in sources :

Example 1 with ConnectorVacuumTableHandle

use of io.prestosql.spi.connector.ConnectorVacuumTableHandle in project hetu-core by openlookeng.

the class TestBackgroundHiveSplitLoader method testFullAcidTableVacuumWithOpenTxns.

@Test
public void testFullAcidTableVacuumWithOpenTxns() throws Exception {
    java.nio.file.Path tablePath = Files.createTempDirectory("TestBackgroundHiveSplitLoader");
    Table table = table(tablePath.toString(), ImmutableList.of(), Optional.empty(), ImmutableMap.of("transactional", "true"));
    List<String> filePaths = ImmutableList.of(tablePath + "/delta_0000001_0000001_0000/_orc_acid_version", tablePath + "/delta_0000001_0000001_0000/bucket_00000", tablePath + "/delta_0000002_0000002_0000/_orc_acid_version", tablePath + "/delta_0000002_0000002_0000/bucket_00000", tablePath + "/delta_0000003_0000003_0000/_orc_acid_version", tablePath + "/delta_0000003_0000003_0000/bucket_00000");
    try {
        for (String path : filePaths) {
            File file = new File(path);
            assertTrue(file.getParentFile().exists() || file.getParentFile().mkdirs(), "Failed creating directory " + file.getParentFile());
            createOrcAcidFile(file);
        }
        // ValidWriteIdsList is of format <currentTxn>$<schema>.<table>:<highWatermark>:<minOpenWriteId>::<AbortedTxns>
        // This writeId list has high watermark transaction=3
        ValidReaderWriteIdList validWriteIdsList = new ValidReaderWriteIdList(format("4$%s.%s:1:2::", table.getDatabaseName(), table.getTableName()));
        ImmutableMap<String, Object> queryInfo = ImmutableMap.of("FULL", false, "vacuumHandle", new ConnectorVacuumTableHandle() {
        });
        BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader(createTestHdfsEnvironment(new HiveConfig()), TupleDomain.all(), Optional.empty(), table, Optional.empty(), Optional.of(validWriteIdsList), Optional.of(QueryType.VACUUM), queryInfo);
        HiveSplitSource hiveSplitSource = hiveSplitSource(backgroundHiveSplitLoader);
        backgroundHiveSplitLoader.start(hiveSplitSource);
        List<HiveSplit> splits = drainSplits(hiveSplitSource);
        assertEquals(1, splits.size());
    } finally {
        MoreFiles.deleteRecursively(tablePath, ALLOW_INSECURE);
    }
}
Also used : Table(io.prestosql.plugin.hive.metastore.Table) ConnectorVacuumTableHandle(io.prestosql.spi.connector.ConnectorVacuumTableHandle) ValidReaderWriteIdList(org.apache.hadoop.hive.common.ValidReaderWriteIdList) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with ConnectorVacuumTableHandle

use of io.prestosql.spi.connector.ConnectorVacuumTableHandle in project hetu-core by openlookeng.

the class MetadataManager method beginVacuum.

@Override
public VacuumTableHandle beginVacuum(Session session, TableHandle tableHandle, boolean full, boolean merge, Optional<String> partition) {
    CatalogName catalogName = tableHandle.getCatalogName();
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
    ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
    ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogName);
    ConnectorVacuumTableHandle vacuumTableHandle = metadata.beginVacuum(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), full, merge, partition);
    return new VacuumTableHandle(tableHandle.getCatalogName(), transactionHandle, vacuumTableHandle);
}
Also used : ConnectorVacuumTableHandle(io.prestosql.spi.connector.ConnectorVacuumTableHandle) ConnectorTransactionHandle(io.prestosql.spi.connector.ConnectorTransactionHandle) CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) ConnectorVacuumTableHandle(io.prestosql.spi.connector.ConnectorVacuumTableHandle)

Aggregations

ConnectorVacuumTableHandle (io.prestosql.spi.connector.ConnectorVacuumTableHandle)2 Table (io.prestosql.plugin.hive.metastore.Table)1 CatalogName (io.prestosql.spi.connector.CatalogName)1 ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)1 ConnectorTransactionHandle (io.prestosql.spi.connector.ConnectorTransactionHandle)1 File (java.io.File)1 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)1 Test (org.testng.annotations.Test)1