use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class TableMetadataCursorFactoryTest method testMetadataQueryMissingMetaFile.
@Test
public void testMetadataQueryMissingMetaFile() throws Exception {
try (TableModel tm1 = new TableModel(configuration, "table1", PartitionBy.DAY)) {
tm1.col("abc", ColumnType.STRING);
tm1.timestamp("ts1");
createPopulateTable(tm1, 0, "2020-01-01", 0);
}
try (TableModel tm1 = new TableModel(configuration, "table2", PartitionBy.NONE)) {
tm1.timestamp("ts2");
createPopulateTable(tm1, 0, "2020-01-01", 0);
}
engine.releaseAllWriters();
engine.releaseAllReaders();
FilesFacade filesFacade = configuration.getFilesFacade();
try (Path path = new Path()) {
path.concat(configuration.getRoot()).concat("table1").concat(META_FILE_NAME).$();
filesFacade.remove(path);
}
assertSql("tables", "id\tname\tdesignatedTimestamp\tpartitionBy\tmaxUncommittedRows\tcommitLag\n" + "2\ttable2\tts2\tNONE\t1000\t0\n");
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class O3CopyJob method copyIdleQuick.
static void copyIdleQuick(AtomicInteger columnCounter, long timestampMergeIndexAddr, long srcDataFixFd, long srcDataFixAddr, long srcDataFixSize, long srcDataVarFd, long srcDataVarAddr, long srcDataVarSize, long srcTimestampFd, long srcTimestampAddr, long srcTimestampSize, long dstFixFd, long dstFixAddr, long dstFixSize, long dstVarFd, long dstVarAddr, long dstVarSize, long dstKFd, long dstVFd, TableWriter tableWriter) {
try {
final FilesFacade ff = tableWriter.getFilesFacade();
O3Utils.unmapAndClose(ff, srcDataFixFd, srcDataFixAddr, srcDataFixSize);
O3Utils.unmapAndClose(ff, srcDataVarFd, srcDataVarAddr, srcDataVarSize);
O3Utils.unmapAndClose(ff, dstFixFd, dstFixAddr, dstFixSize);
O3Utils.unmapAndClose(ff, dstVarFd, dstVarAddr, dstVarSize);
O3Utils.close(ff, dstKFd);
O3Utils.close(ff, dstVFd);
} finally {
closeColumnIdle(columnCounter, timestampMergeIndexAddr, srcTimestampFd, srcTimestampAddr, srcTimestampSize, tableWriter);
}
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SqlCompilerTest method testCreateTableFail.
@Test
public void testCreateTableFail() throws Exception {
FilesFacade ff = new FilesFacadeImpl() {
// this count is very deliberately coincidental with
int count = 8;
// number of rows we are appending
@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;
}
};
assertFailure(ff, "create table x as (select cast(x as int) c, abs(rnd_int() % 650) a from long_sequence(5000000))", "Could not create table. See log for details");
}
use of io.questdb.std.FilesFacade in project questdb by bluestreak01.
the class TableBackupTest method setup.
@Before
public void setup() throws IOException {
path = new Path();
finalBackupPath = new Path();
mkdirsErrno = -1;
renameErrno = -1;
FilesFacade ff = new FilesFacadeImpl() {
private int nextErrno = -1;
@Override
public int errno() {
if (nextErrno != -1) {
int errno = nextErrno;
nextErrno = -1;
return errno;
}
return super.errno();
}
@Override
public int mkdirs(LPSZ path, int mode) {
if (mkdirsErrno != -1 && --mkdirsErrnoCountDown < 1) {
nextErrno = mkdirsErrno;
mkdirsErrno = -1;
mkdirsErrnoCountDown = 0;
return -1;
}
return super.mkdirs(path, mode);
}
@Override
public boolean rename(LPSZ from, LPSZ to) {
if (renameErrno != -1) {
nextErrno = renameErrno;
renameErrno = -1;
return false;
}
return super.rename(from, to);
}
};
CharSequence root = temp.newFolder(String.format("dbRoot%c%s", Files.SEPARATOR, PropServerConfiguration.DB_DIRECTORY)).getAbsolutePath();
backupRoot = temp.newFolder("dbBackupRoot").getAbsolutePath();
mainConfiguration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
@Override
public CharSequence getBackupRoot() {
return backupRoot;
}
@Override
public DateFormat getBackupDirTimestampFormat() {
return new TimestampFormatCompiler().compile("ddMMMyyyy");
}
};
mainEngine = new CairoEngine(mainConfiguration);
mainCompiler = new SqlCompiler(mainEngine);
mainSqlExecutionContext = new SqlExecutionContextImpl(mainEngine, 1).with(AllowAllCairoSecurityContext.INSTANCE, new BindVariableServiceImpl(mainConfiguration), null, -1, null);
// dummy configuration
File confRoot = new File(PropServerConfiguration.confRoot(root));
Assert.assertTrue(confRoot.mkdirs());
Assert.assertTrue(new File(confRoot, "server.conf").createNewFile());
Assert.assertTrue(new File(confRoot, "mime.types").createNewFile());
Assert.assertTrue(new File(confRoot, "log-file.conf").createNewFile());
Assert.assertTrue(new File(confRoot, "date.formats").createNewFile());
}
Aggregations