Search in sources :

Example 1 with HetuFsMetastore

use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastore in project hetu-core by openlookeng.

the class TestHeuristicIndexClient method testDeleteSelectedColumnsHelper.

@Test
public void testDeleteSelectedColumnsHelper() throws IOException {
    String tableName = "catalog.schema.UT_test";
    try (TempFolder folder = new TempFolder()) {
        folder.create();
        File tableFolder = new File(folder.getRoot().getPath(), tableName);
        assertTrue(tableFolder.mkdir());
        File columnFolder = new File(tableFolder, "test_column");
        assertTrue(columnFolder.mkdirs());
        File indexTypeFolder = new File(columnFolder, "BLOOM");
        assertTrue(indexTypeFolder.mkdirs());
        assertTrue(new File(indexTypeFolder, "testIndex.index").createNewFile());
        HetuFileSystemClient fs = new HetuLocalFileSystemClient(new LocalConfig(new Properties()), folder.getRoot().toPath());
        HetuMetastore testMetaStore = new HetuFsMetastore(new HetuFsMetastoreConfig().setHetuFileSystemMetastorePath(folder.getRoot().getPath()), fs);
        HeuristicIndexClient client = new HeuristicIndexClient(fs, testMetaStore, folder.getRoot().toPath());
        client.addIndexRecord(new CreateIndexMetadata("idx1", tableName, "BLOOM", 0L, Collections.singletonList(new Pair<>("test_column", VARCHAR)), Collections.emptyList(), new Properties(), "user", CreateIndexMetadata.Level.UNDEFINED));
        client.deleteIndex("idx1", Collections.emptyList());
        assertFalse(indexTypeFolder.exists());
    }
}
Also used : CreateIndexMetadata(io.prestosql.spi.connector.CreateIndexMetadata) HetuFsMetastoreConfig(io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig) LocalConfig(io.hetu.core.filesystem.LocalConfig) Properties(java.util.Properties) HetuFsMetastore(io.hetu.core.metastore.hetufilesystem.HetuFsMetastore) HetuMetastore(io.prestosql.spi.metastore.HetuMetastore) HetuFileSystemClient(io.prestosql.spi.filesystem.HetuFileSystemClient) TempFolder(io.hetu.core.common.filesystem.TempFolder) File(java.io.File) HetuLocalFileSystemClient(io.hetu.core.filesystem.HetuLocalFileSystemClient) Test(org.testng.annotations.Test)

Example 2 with HetuFsMetastore

use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastore in project hetu-core by openlookeng.

the class TestIndexRecordManager method testDelete.

@Test
public void testDelete() 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);
        indexRecordManager.addIndexRecord("1", "testUser", "testCatalog.testSchema.testTable", new String[] { "testColumn" }, "minmax", 0L, Collections.emptyList(), Arrays.asList("cp=1"));
        indexRecordManager.addIndexRecord("2", "testUser", "testCatalog.testSchema.testTable", new String[] { "testColumn" }, "bloom", 0L, Collections.emptyList(), Arrays.asList("cp=1"));
        assertNotNull(indexRecordManager.lookUpIndexRecord("1"));
        assertEquals(indexRecordManager.getIndexRecords().size(), 2);
        // Delete 1
        indexRecordManager.deleteIndexRecord("1", Collections.emptyList());
        assertNull(indexRecordManager.lookUpIndexRecord("1"));
        assertNotNull(indexRecordManager.lookUpIndexRecord("2"));
        assertEquals(indexRecordManager.getIndexRecords().size(), 1);
        // Delete 1 again
        indexRecordManager.deleteIndexRecord("1", Collections.emptyList());
        assertNull(indexRecordManager.lookUpIndexRecord("1"));
        assertNotNull(indexRecordManager.lookUpIndexRecord("2"));
        assertEquals(indexRecordManager.getIndexRecords().size(), 1);
        // Delete 2
        indexRecordManager.deleteIndexRecord("2", Collections.emptyList());
        assertNull(indexRecordManager.lookUpIndexRecord("2"));
        assertEquals(indexRecordManager.getIndexRecords().size(), 0);
    }
}
Also used : HetuFsMetastoreConfig(io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig) TempFolder(io.hetu.core.common.filesystem.TempFolder) HetuFsMetastore(io.hetu.core.metastore.hetufilesystem.HetuFsMetastore) HetuMetastore(io.prestosql.spi.metastore.HetuMetastore) JdbcHetuMetastore(io.hetu.core.metastore.jdbc.JdbcHetuMetastore) Test(org.testng.annotations.Test)

Example 3 with HetuFsMetastore

use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastore 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 4 with HetuFsMetastore

use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastore 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)4 HetuFsMetastore (io.hetu.core.metastore.hetufilesystem.HetuFsMetastore)4 HetuFsMetastoreConfig (io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig)4 HetuMetastore (io.prestosql.spi.metastore.HetuMetastore)3 HetuLocalFileSystemClient (io.hetu.core.filesystem.HetuLocalFileSystemClient)2 LocalConfig (io.hetu.core.filesystem.LocalConfig)2 JdbcHetuMetastore (io.hetu.core.metastore.jdbc.JdbcHetuMetastore)2 Test (org.testng.annotations.Test)2 CreateIndexMetadata (io.prestosql.spi.connector.CreateIndexMetadata)1 HetuFileSystemClient (io.prestosql.spi.filesystem.HetuFileSystemClient)1 IndexRecord (io.prestosql.spi.heuristicindex.IndexRecord)1 TestingTypeManager (io.prestosql.spi.type.testing.TestingTypeManager)1 TestingNodeManager (io.prestosql.testing.TestingNodeManager)1 File (java.io.File)1 Properties (java.util.Properties)1 BeforeMethod (org.testng.annotations.BeforeMethod)1