use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class O3CopyJob method updatePartition.
private static void updatePartition(long timestampMergeIndexAddr, long srcDataMax, long srcOooMax, long srcOooPartitionLo, long srcOooPartitionHi, long timestampMin, long timestampMax, long partitionTimestamp, long srcTimestampFd, long srcTimestampAddr, long srcTimestampSize, boolean partitionMutates, TableWriter tableWriter) {
final FilesFacade ff = tableWriter.getFilesFacade();
O3Utils.unmap(ff, srcTimestampAddr, srcTimestampSize);
try {
try {
O3Utils.close(ff, srcTimestampFd);
} finally {
notifyWriter(srcOooPartitionLo, srcOooPartitionHi, timestampMin, timestampMax, partitionTimestamp, srcOooMax, srcDataMax, partitionMutates, tableWriter);
}
} finally {
if (timestampMergeIndexAddr != 0) {
Vect.freeMergedIndex(timestampMergeIndexAddr);
}
tableWriter.o3CountDownDoneLatch();
}
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class AbstractCairoTest method assertMemoryLeak.
protected static void assertMemoryLeak(@Nullable FilesFacade ff, TestUtils.LeakProneCode code) throws Exception {
final FilesFacade ff2 = ff;
TestUtils.assertMemoryLeak(() -> {
AbstractCairoTest.ff = ff2;
try {
code.run();
engine.releaseInactive();
Assert.assertEquals(0, engine.getBusyWriterCount());
Assert.assertEquals(0, engine.getBusyReaderCount());
} finally {
engine.clear();
AbstractCairoTest.ff = null;
}
});
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SqlCodeGeneratorTest method testLatestByIOFailure.
@Test
public void testLatestByIOFailure() throws Exception {
assertMemoryLeak(() -> {
FilesFacade ff = new FilesFacadeImpl() {
@Override
public long openRO(LPSZ name) {
if (Chars.endsWith(name, "b.d")) {
return -1;
}
return super.openRO(name);
}
};
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
};
try (CairoEngine engine = new CairoEngine(configuration);
SqlCompiler compiler = new SqlCompiler(engine)) {
try {
compiler.compile(("create table x as " + "(" + "select rnd_double(0)*100 a, rnd_symbol(5,4,4,1) b, timestamp_sequence(0, 100000000000) k from" + " long_sequence(200)" + ") timestamp(k) partition by DAY"), sqlExecutionContext);
try (final RecordCursorFactory factory = compiler.compile("select * from x latest by b where b = 'PEHN' and a < 22", sqlExecutionContext).getRecordCursorFactory()) {
try {
assertCursor("a\tb\tk\n" + "5.942010834028\tPEHN\t1970-08-03T02:53:20.000000Z\n", factory, true, true, false);
Assert.fail();
} catch (CairoException e) {
TestUtils.assertContains(e.getFlyweightMessage(), "could not open");
}
}
Assert.assertEquals(0, engine.getBusyReaderCount());
Assert.assertEquals(0, engine.getBusyWriterCount());
} finally {
engine.clear();
}
}
});
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SqlCompilerTest method testInsertAsSelectTemporaryIOError.
@Test
public void testInsertAsSelectTemporaryIOError() throws Exception {
AtomicBoolean inError = new AtomicBoolean(true);
FilesFacade ff = new FilesFacadeImpl() {
int pageCount = 0;
@Override
public long getMapPageSize() {
return getPageSize();
}
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
if (inError.get() && pageCount++ == 13) {
return -1;
}
return super.mmap(fd, len, offset, flags, memoryTag);
}
};
assertInsertAsSelectIOError(inError, ff);
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SqlCompilerTest method testInsertAsSelectPersistentIOError.
@Test
public void testInsertAsSelectPersistentIOError() throws Exception {
AtomicBoolean inError = new AtomicBoolean(true);
FilesFacade ff = new FilesFacadeImpl() {
int pageCount = 0;
@Override
public long getMapPageSize() {
return getPageSize();
}
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
if (inError.get() && pageCount++ > 12) {
return -1;
}
return super.mmap(fd, len, offset, flags, memoryTag);
}
};
assertInsertAsSelectIOError(inError, ff);
}
Aggregations