Search in sources :

Example 6 with FilesFacade

use of com.questdb.std.FilesFacade in project questdb by bluestreak01.

the class TableReadFailTest method testMetaFileMissingConstructor.

@Test
public void testMetaFileMissingConstructor() throws Exception {
    FilesFacade ff = new FilesFacadeImpl() {

        @Override
        public boolean exists(LPSZ path) {
            return !Chars.endsWith(path, TableUtils.META_FILE_NAME) && super.exists(path);
        }
    };
    assertConstructorFail(ff);
}
Also used : FilesFacade(com.questdb.std.FilesFacade) LPSZ(com.questdb.std.str.LPSZ) FilesFacadeImpl(com.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 7 with FilesFacade

use of com.questdb.std.FilesFacade in project questdb by bluestreak01.

the class TableReadFailTest method testMetaFileCannotOpenConstructor.

@Test
public void testMetaFileCannotOpenConstructor() throws Exception {
    FilesFacade ff = new FilesFacadeImpl() {

        @Override
        public long openRO(LPSZ name) {
            if (Chars.endsWith(name, TableUtils.META_FILE_NAME)) {
                return -1;
            }
            return super.openRO(name);
        }
    };
    assertConstructorFail(ff);
}
Also used : FilesFacade(com.questdb.std.FilesFacade) LPSZ(com.questdb.std.str.LPSZ) FilesFacadeImpl(com.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 8 with FilesFacade

use of com.questdb.std.FilesFacade in project questdb by bluestreak01.

the class CairoTestUtils method create.

public static void create(TableModel model) {
    final Path path = model.getPath();
    final FilesFacade ff = model.getCairoCfg().getFilesFacade();
    path.of(model.getCairoCfg().getRoot()).concat(model.getName());
    final int rootLen = path.length();
    if (ff.mkdirs(path.put(Files.SEPARATOR).$(), model.getCairoCfg().getMkDirMode()) == -1) {
        throw CairoException.instance(ff.errno()).put("Cannot create dir: ").put(path);
    }
    try (AppendMemory mem = model.getMem()) {
        mem.of(ff, path.trimTo(rootLen).concat(META_FILE_NAME).$(), ff.getPageSize());
        int count = model.getColumnCount();
        mem.putInt(count);
        mem.putInt(model.getPartitionBy());
        mem.putInt(model.getTimestampIndex());
        mem.jumpTo(TableUtils.META_OFFSET_COLUMN_TYPES);
        for (int i = 0; i < count; i++) {
            mem.putByte((byte) model.getColumnType(i));
            mem.putBool(model.getIndexedFlag(i));
            mem.putInt(model.getIndexBlockCapacity(i));
            // reserved
            mem.skip(10);
        }
        for (int i = 0; i < count; i++) {
            mem.putStr(model.getColumnName(i));
        }
        // create symbol maps
        int symbolMapCount = 0;
        for (int i = 0; i < count; i++) {
            if (model.getColumnType(i) == ColumnType.SYMBOL) {
                SymbolMapWriter.createSymbolMapFiles(ff, mem, path.trimTo(rootLen), model.getColumnName(i), model.getSymbolCapacity(i), model.getSymbolCacheFlag(i));
                symbolMapCount++;
            }
        }
        mem.of(ff, path.trimTo(rootLen).concat(TXN_FILE_NAME).$(), ff.getPageSize());
        TableUtils.resetTxn(mem, symbolMapCount);
    }
}
Also used : Path(com.questdb.std.str.Path) FilesFacade(com.questdb.std.FilesFacade)

Aggregations

FilesFacade (com.questdb.std.FilesFacade)8 FilesFacadeImpl (com.questdb.std.FilesFacadeImpl)6 LPSZ (com.questdb.std.str.LPSZ)6 Test (org.junit.Test)6 CairoEngine (com.questdb.cairo.sql.CairoEngine)1 Path (com.questdb.std.str.Path)1