use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class BinarySearchTest method testFindForwardTwoValues.
@Test
public void testFindForwardTwoValues() {
try (Path path = new Path()) {
path.of(root).concat("binsearch.d").$();
try (MemoryMA appendMem = Vm.getSmallCMARWInstance(FilesFacadeImpl.INSTANCE, path, MemoryTag.MMAP_DEFAULT)) {
appendMem.putLong(1);
appendMem.putLong(3);
try (MemoryMR mem = Vm.getMRInstance(FilesFacadeImpl.INSTANCE, path, 400 * Long.BYTES, MemoryTag.MMAP_DEFAULT)) {
Assert.assertEquals(0, BinarySearch.find(mem, 2, 0, 1, BinarySearch.SCAN_DOWN));
}
}
}
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class TelemetryTest method testTelemetryDisabledByDefault.
@Test
public void testTelemetryDisabledByDefault() throws Exception {
TestUtils.assertMemoryLeak(() -> {
try (Path path = new Path()) {
Assert.assertEquals(TableUtils.TABLE_DOES_NOT_EXIST, TableUtils.exists(FF, path, root, "telemetry"));
Assert.assertEquals(TableUtils.TABLE_DOES_NOT_EXIST, TableUtils.exists(FF, path, root, "telemetry_config"));
}
});
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testCopyBigFile.
@Test
public void testCopyBigFile() throws Exception {
File temp = temporaryFolder.newFile();
// in MB
int fileSize = 2 * 1024 * 1024;
byte[] page = new byte[1024 * 64];
Rnd rnd = new Rnd();
for (int i = 0; i < page.length; i++) {
page[i] = rnd.nextByte();
}
try (FileOutputStream fos = new FileOutputStream(temp)) {
for (int i = 0; i < fileSize / page.length; i++) {
fos.write(page);
}
}
try (Path path = new Path().of(temp.getAbsolutePath()).$()) {
Assert.assertTrue(Files.exists(path));
try (Path copyPath = new Path().of(temp.getAbsolutePath()).put("-copy").$()) {
Files.copy(path, copyPath);
Assert.assertEquals(fileSize, Files.length(copyPath));
TestUtils.assertFileContentsEquals(path, copyPath);
}
}
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testFailsToAllocateWhenNotEnoughSpace.
@Test
public void testFailsToAllocateWhenNotEnoughSpace() throws Exception {
File temp = temporaryFolder.newFile();
TestUtils.writeStringToFile(temp, "abcde");
try (Path path = new Path().of(temp.getAbsolutePath()).$()) {
Assert.assertTrue(Files.exists(path));
long fd = Files.openRW(path);
Assert.assertEquals(5, Files.length(path));
try {
// 10TB
long tb10 = 1024L * 1024L * 1024L * 1024L * 10;
boolean success = Files.allocate(fd, tb10);
Assert.assertFalse("Allocation should fail on reasonable hard disk size", success);
} finally {
Files.close(fd);
}
}
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testRemove.
@Test
public void testRemove() throws Exception {
try (Path path = new Path().of(temporaryFolder.newFile().getAbsolutePath()).$()) {
Assert.assertTrue(Files.touch(path));
Assert.assertTrue(Files.exists(path));
Assert.assertTrue(Files.remove(path));
Assert.assertFalse(Files.exists(path));
}
}
Aggregations