use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SqlCompilerTest method testCreateAsSelectIOError2.
@Test
public void testCreateAsSelectIOError2() throws Exception {
String sql = "create table y as (" + "select rnd_symbol(4,4,4,2) a from long_sequence(10000)" + "), cast(a as STRING)";
final FilesFacade ff = new FilesFacadeImpl() {
int mapCount = 0;
@Override
public long getMapPageSize() {
return getPageSize();
}
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
// and then fails to close txMem
if (mapCount++ > 2) {
return -1;
}
return super.mmap(fd, len, offset, flags, memoryTag);
}
};
assertFailure(ff, sql, "Could not create table. See log for details");
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SqlCompilerTest method testCreateAsSelectIOError.
@Test
public void testCreateAsSelectIOError() throws Exception {
String sql = "create table y as (" + "select rnd_symbol(4,4,4,2) a from long_sequence(10000)" + "), cast(a as STRING)";
final FilesFacade ff = new FilesFacadeImpl() {
int mapCount = 0;
@Override
public long getMapPageSize() {
return getPageSize();
}
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
if (mapCount++ > 5) {
return -1;
}
return super.mmap(fd, len, offset, flags, memoryTag);
}
};
assertFailure(ff, sql, "Could not create table. See log for details");
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SampleByTest method testSampleFillLinearConstructorFail.
@Test
public void testSampleFillLinearConstructorFail() throws Exception {
assertMemoryLeak(() -> {
compiler.compile("create table x as " + "(" + "select" + " rnd_double(0)*100 a," + " rnd_symbol(5,4,4,1) b," + " timestamp_sequence(172800000000, 3600000000) k" + " from" + " long_sequence(20000000)" + ") timestamp(k) partition by NONE", sqlExecutionContext);
FilesFacade ff = new FilesFacadeImpl() {
int count = 4;
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
if (count-- > 0) {
return super.mmap(fd, len, offset, flags, memoryTag);
}
return -1;
}
};
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
};
try (CairoEngine engine = new CairoEngine(configuration)) {
try (SqlCompiler compiler = new SqlCompiler(engine)) {
try {
compiler.compile("select b, sum(a), k from x sample by 3h fill(linear)", sqlExecutionContext);
Assert.fail();
} catch (SqlException e) {
Assert.assertTrue(Chars.contains(e.getMessage(), "could not mmap"));
}
Assert.assertEquals(0, engine.getBusyReaderCount());
Assert.assertEquals(0, engine.getBusyWriterCount());
}
}
});
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SampleByTest method testSampleFillLinearFail.
@Test
public void testSampleFillLinearFail() throws Exception {
assertMemoryLeak(() -> {
compiler.compile("create table x as " + "(" + "select" + " rnd_double(0)*100 a," + " rnd_symbol(5,4,4,1) b," + " timestamp_sequence(172800000000, 3600000000) k" + " from" + " long_sequence(20000000)" + ") timestamp(k) partition by NONE", sqlExecutionContext);
FilesFacade ff = new FilesFacadeImpl() {
int count = 10;
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
if (count-- > 0) {
return super.mmap(fd, len, offset, flags, memoryTag);
}
return -1;
}
};
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
};
try (CairoEngine engine = new CairoEngine(configuration)) {
try (SqlCompiler compiler = new SqlCompiler(engine)) {
try {
try (RecordCursorFactory factory = compiler.compile("select b, sum(a), k from x sample by 3h fill(linear)", sqlExecutionContext).getRecordCursorFactory()) {
// with mmap count = 5 we should get failure in cursor
factory.getCursor(sqlExecutionContext);
}
Assert.fail();
} catch (CairoException e) {
Assert.assertTrue(Chars.contains(e.getMessage(), "could not mmap"));
}
Assert.assertEquals(0, engine.getBusyReaderCount());
Assert.assertEquals(0, engine.getBusyWriterCount());
}
}
});
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SampleByTest method testGroupByFail.
@Test
public void testGroupByFail() throws Exception {
assertMemoryLeak(() -> {
compiler.compile("create table x as " + "(" + "select" + " x," + " rnd_double(0) d," + " rnd_symbol('XY','ZP', null, 'UU') c" + " from" + " long_sequence(1000000)" + ")", sqlExecutionContext);
engine.clear();
final FilesFacade ff = new FilesFacadeImpl() {
int count = 10;
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
if (count-- > 0) {
return super.mmap(fd, len, offset, flags, memoryTag);
}
return -1;
}
};
final CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
};
try (CairoEngine engine = new CairoEngine(configuration)) {
try (SqlCompiler compiler = new SqlCompiler(engine)) {
try {
try (RecordCursorFactory factory = compiler.compile("select c, sum_t(d) from x", sqlExecutionContext).getRecordCursorFactory()) {
factory.getCursor(sqlExecutionContext);
}
Assert.fail();
} catch (CairoException e) {
TestUtils.assertContains(e.getFlyweightMessage(), "could not mmap");
}
Assert.assertEquals(0, engine.getBusyReaderCount());
Assert.assertEquals(0, engine.getBusyWriterCount());
}
engine.clear();
}
});
}
Aggregations