use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig 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());
}
}
use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig 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);
}
}
use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig 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);
}
}
use of io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreConfig 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());
}
Aggregations