Search in sources :

Example 1 with TempFolder

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

the class TestHetuLocalFileSystemClient method prepare.

@BeforeClass
public void prepare() throws IOException {
    tFolder = new TempFolder();
    tFolder.create();
    nonExistingPath = Paths.get(tFolder.getRoot().getAbsolutePath(), "/path/to/a/non/existing/file");
    fs = new HetuLocalFileSystemClient(new LocalConfig(new Properties()), tFolder.getRoot().toPath());
}
Also used : TempFolder(io.hetu.core.common.filesystem.TempFolder) Properties(java.util.Properties) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with TempFolder

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

the class TestHeuristicIndexFilter method setup.

@BeforeClass
public void setup() throws IOException {
    try (TempFolder folder = new TempFolder()) {
        folder.create();
        File testFile = folder.newFile();
        bloomIndex1 = new BloomIndex();
        bloomIndex1.setExpectedNumOfEntries(2);
        bloomIndex1.addValues(Collections.singletonList(new Pair<>("testColumn", ImmutableList.of("a", "b"))));
        try (FileOutputStream fo = new FileOutputStream(testFile)) {
            bloomIndex1.serialize(fo);
        }
        try (FileInputStream fi = new FileInputStream(testFile)) {
            bloomIndex1.deserialize(fi);
        }
        bloomIndex2 = new BloomIndex();
        bloomIndex2.setExpectedNumOfEntries(2);
        bloomIndex2.addValues(Collections.singletonList(new Pair<>("testColumn", ImmutableList.of("c", "d"))));
        try (FileOutputStream fo = new FileOutputStream(testFile)) {
            bloomIndex2.serialize(fo);
        }
        try (FileInputStream fi = new FileInputStream(testFile)) {
            bloomIndex2.deserialize(fi);
        }
        minMaxIndex1 = new MinMaxIndex();
        minMaxIndex1.addValues(Collections.singletonList(new Pair<>("testColumn", ImmutableList.of(1L, 5L, 10L))));
        minMaxIndex2 = new MinMaxIndex();
        minMaxIndex2.addValues(Collections.singletonList(new Pair<>("testColumn", ImmutableList.of(50L, 80L, 100L))));
    }
}
Also used : BloomIndex(io.hetu.core.plugin.heuristicindex.index.bloom.BloomIndex) MinMaxIndex(io.hetu.core.plugin.heuristicindex.index.minmax.MinMaxIndex) TempFolder(io.hetu.core.common.filesystem.TempFolder) FileOutputStream(java.io.FileOutputStream) File(java.io.File) FileInputStream(java.io.FileInputStream) Pair(io.prestosql.spi.heuristicindex.Pair) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with TempFolder

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

the class TestIndexServiceUtils method testLoadProperties.

@Test
public void testLoadProperties() throws IOException {
    Properties props = new Properties();
    props.setProperty("connector.name", "hive-hadoop2");
    try (TempFolder folder = new TempFolder()) {
        folder.create();
        File temp = folder.newFile();
        try (OutputStream os = new FileOutputStream(temp)) {
            props.store(os, "test");
        }
        Properties properties = IndexServiceUtils.loadProperties(temp);
        assertEquals("hive-hadoop2", properties.getProperty("connector.name"));
    }
}
Also used : TempFolder(io.hetu.core.common.filesystem.TempFolder) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with TempFolder

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

the class TestIndexServiceUtils method testIsFileExisting.

@Test
public void testIsFileExisting() throws IOException {
    try (TempFolder folder = new TempFolder()) {
        folder.create();
        File tmpFile = folder.newFile();
        assertTrue(tmpFile.delete());
        assertThrows(IllegalArgumentException.class, () -> IndexServiceUtils.isFileExisting(tmpFile));
    }
}
Also used : TempFolder(io.hetu.core.common.filesystem.TempFolder) File(java.io.File) Test(org.testng.annotations.Test)

Example 5 with TempFolder

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

the class TestBitmapIndex method testBitmapBetweenForDataTypes.

@Test(dataProvider = "bitmapBetweenForDataTypes")
public void testBitmapBetweenForDataTypes(List<Object> columnValues, Type type, Object matchVal1, Object matchVal2, List<Object> matchedList) throws IOException {
    System.out.println("Testing for " + columnValues + " for type " + type.getDisplayName() + " from " + matchVal1.toString() + " to " + matchVal2.toString());
    try (TempFolder folder = new TempFolder();
        BitmapIndex bitmapIndexWrite = new BitmapIndex();
        BitmapIndex bitmapIndexRead = new BitmapIndex()) {
        folder.create();
        File file = folder.newFile();
        String columnName = "column";
        bitmapIndexWrite.setExpectedNumOfEntries(columnValues.size());
        bitmapIndexWrite.addValues(Collections.singletonList(new Pair<>(columnName, columnValues)));
        try (FileOutputStream os = new FileOutputStream(file);
            FileInputStream is = new FileInputStream(file)) {
            bitmapIndexWrite.serialize(os);
            bitmapIndexRead.deserialize(is);
        }
        assertEquals(iteratorToList(bitmapIndexRead.lookUp(Domain.create(ValueSet.ofRanges(Range.range(type, matchVal1, true, matchVal2, true)), false))), matchedList);
    }
}
Also used : TempFolder(io.hetu.core.common.filesystem.TempFolder) FileOutputStream(java.io.FileOutputStream) File(java.io.File) FileInputStream(java.io.FileInputStream) Pair(io.prestosql.spi.heuristicindex.Pair) Test(org.testng.annotations.Test)

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