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());
}
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))));
}
}
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"));
}
}
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));
}
}
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);
}
}
Aggregations