Search in sources :

Example 26 with TempFolder

use of io.hetu.core.common.filesystem.TempFolder in project hetu-core by openlookeng.

the class TestIndexRecordManager method testIndexRecordAddLookUpHelper.

private void testIndexRecordAddLookUpHelper(String name, String user, String table, String[] columns, String indexType, List<String> indexProperties, List<String> partitions) throws IOException {
    try (TempFolder folder = new TempFolder()) {
        folder.create();
        HetuMetastore testMetaStore = new HetuFsMetastore(new HetuFsMetastoreConfig().setHetuFileSystemMetastorePath(folder.getRoot().getPath()), FILE_SYSTEM_CLIENT);
        IndexRecordManager indexRecordManager = new IndexRecordManager(testMetaStore);
        IndexRecord expected = new IndexRecord(name, user, table, columns, indexType, 0L, indexProperties, partitions);
        indexRecordManager.addIndexRecord(name, user, table, columns, indexType, 0L, indexProperties, partitions);
        IndexRecord actual1 = indexRecordManager.lookUpIndexRecord(name);
        assertNotNull(actual1);
        assertEquals(actual1, expected);
        IndexRecord actual2 = indexRecordManager.lookUpIndexRecord(table, columns, indexType);
        assertNotNull(actual2);
        assertEquals(actual2, expected);
    }
}
Also used : HetuFsMetastoreConfig(io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig) TempFolder(io.hetu.core.common.filesystem.TempFolder) HetuFsMetastore(io.hetu.core.metastore.hetufilesystem.HetuFsMetastore) IndexRecord(io.prestosql.spi.heuristicindex.IndexRecord) HetuMetastore(io.prestosql.spi.metastore.HetuMetastore) JdbcHetuMetastore(io.hetu.core.metastore.jdbc.JdbcHetuMetastore)

Example 27 with TempFolder

use of io.hetu.core.common.filesystem.TempFolder in project hetu-core by openlookeng.

the class MemoryQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(int nodes, Map<String, String> extraProperties, Map<String, String> memoryProperties, Boolean createTpchTables) throws Exception {
    Session session = testSessionBuilder().setCatalog(CATALOG).setSchema("default").build();
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, nodes, extraProperties);
    Runtime.getRuntime().addShutdownHook(new Thread(queryRunner::close));
    try {
        queryRunner.installPlugin(new HetuFileSystemClientPlugin());
        queryRunner.installPlugin(new HetuMetastorePlugin());
        TempFolder metastoreFolder = new TempFolder().create();
        Runtime.getRuntime().addShutdownHook(new Thread(metastoreFolder::close));
        Map<String, String> metastoreConfig = new HashMap<>();
        metastoreConfig.put("hetu.metastore.type", "hetufilesystem");
        metastoreConfig.put("hetu.metastore.hetufilesystem.profile-name", "default");
        metastoreConfig.put("hetu.metastore.hetufilesystem.path", metastoreFolder.newFolder("metastore").getAbsolutePath());
        queryRunner.getServers().forEach(server -> {
            try {
                server.loadMetastore(new HashMap<>(metastoreConfig));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        queryRunner.installPlugin(new MemoryPlugin());
        queryRunner.getServers().forEach(server -> {
            try {
                TempFolder folder = new TempFolder();
                folder.create();
                Runtime.getRuntime().addShutdownHook(new Thread(folder::close));
                // create memory catalog with custom memory properties
                server.createCatalog(CATALOG, "memory", createConfig(folder, memoryProperties));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of());
        queryRunner.installPlugin(new TpcdsPlugin());
        queryRunner.createCatalog("tpcds", "tpcds", ImmutableMap.of());
        if (createTpchTables) {
            copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, session, TpchTable.getTables());
        }
        return queryRunner;
    } catch (Exception e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : HetuFileSystemClientPlugin(io.hetu.core.filesystem.HetuFileSystemClientPlugin) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) HashMap(java.util.HashMap) TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin) IOException(java.io.IOException) HetuMetastorePlugin(io.hetu.core.metastore.HetuMetastorePlugin) TempFolder(io.hetu.core.common.filesystem.TempFolder) TpcdsPlugin(io.prestosql.plugin.tpcds.TpcdsPlugin) Session(io.prestosql.Session)

Example 28 with TempFolder

use of io.hetu.core.common.filesystem.TempFolder in project hetu-core by openlookeng.

the class TestMemoryMetadata method setUp.

@BeforeMethod
public void setUp() throws IOException {
    TempFolder tmp = new TempFolder().create();
    Runtime.getRuntime().addShutdownHook(new Thread(tmp::close));
    metadata = new MemoryMetadata(new TestingTypeManager(), new TestingNodeManager(), new HetuFsMetastore(new HetuFsMetastoreConfig().setHetuFileSystemMetastorePath(tmp.getRoot().getCanonicalPath()), new HetuLocalFileSystemClient(new LocalConfig(null), Paths.get(tmp.getRoot().getCanonicalPath()))), null, new MemoryConfig());
}
Also used : HetuFsMetastoreConfig(io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig) TempFolder(io.hetu.core.common.filesystem.TempFolder) TestingNodeManager(io.prestosql.testing.TestingNodeManager) LocalConfig(io.hetu.core.filesystem.LocalConfig) HetuFsMetastore(io.hetu.core.metastore.hetufilesystem.HetuFsMetastore) HetuLocalFileSystemClient(io.hetu.core.filesystem.HetuLocalFileSystemClient) TestingTypeManager(io.prestosql.spi.type.testing.TestingTypeManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

TempFolder (io.hetu.core.common.filesystem.TempFolder)28 File (java.io.File)18 Test (org.testng.annotations.Test)17 FileInputStream (java.io.FileInputStream)15 FileOutputStream (java.io.FileOutputStream)14 Pair (io.prestosql.spi.heuristicindex.Pair)12 HashMap (java.util.HashMap)5 HetuFileSystemClientPlugin (io.hetu.core.filesystem.HetuFileSystemClientPlugin)4 HetuMetastorePlugin (io.hetu.core.metastore.HetuMetastorePlugin)4 HetuFsMetastore (io.hetu.core.metastore.hetufilesystem.HetuFsMetastore)4 HetuFsMetastoreConfig (io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig)4 BeforeClass (org.testng.annotations.BeforeClass)4 HetuMetastore (io.prestosql.spi.metastore.HetuMetastore)3 InputStream (java.io.InputStream)3 Properties (java.util.Properties)3 HetuLocalFileSystemClient (io.hetu.core.filesystem.HetuLocalFileSystemClient)2 LocalConfig (io.hetu.core.filesystem.LocalConfig)2 JdbcHetuMetastore (io.hetu.core.metastore.jdbc.JdbcHetuMetastore)2 MemoryPlugin (io.prestosql.plugin.memory.MemoryPlugin)2 RowExpression (io.prestosql.spi.relation.RowExpression)2