Search in sources :

Example 1 with TimestampFormatCompiler

use of io.questdb.std.datetime.microtime.TimestampFormatCompiler in project questdb by bluestreak01.

the class TableWriterTest method verifyTimestampPartitions.

void verifyTimestampPartitions(MemoryARW vmem) {
    int i;
    TimestampFormatCompiler compiler = new TimestampFormatCompiler();
    DateFormat fmt = compiler.compile("yyyy-MM-dd");
    DateLocale enGb = DateLocaleFactory.INSTANCE.getLocale("en-gb");
    try (Path vp = new Path()) {
        for (i = 0; i < 10000; i++) {
            vp.of(root).concat(PRODUCT).slash();
            fmt.format(vmem.getLong(i * 8L), enGb, "UTC", vp);
            if (!FF.exists(vp.$())) {
                Assert.fail();
            }
        }
    }
}
Also used : DateLocale(io.questdb.std.datetime.DateLocale) Path(io.questdb.std.str.Path) TimestampFormatCompiler(io.questdb.std.datetime.microtime.TimestampFormatCompiler) DateFormat(io.questdb.std.datetime.DateFormat)

Example 2 with TimestampFormatCompiler

use of io.questdb.std.datetime.microtime.TimestampFormatCompiler in project questdb by bluestreak01.

the class PropServerConfiguration method getTimestampFormat.

private DateFormat getTimestampFormat(Properties properties, @Nullable Map<String, String> env) {
    final String pattern = overrideWithEnv(properties, env, "cairo.sql.backup.dir.datetime.format");
    TimestampFormatCompiler compiler = new TimestampFormatCompiler();
    // noinspection ReplaceNullCheck
    if (null != pattern) {
        return compiler.compile(pattern);
    }
    return compiler.compile("yyyy-MM-dd");
}
Also used : TimestampFormatCompiler(io.questdb.std.datetime.microtime.TimestampFormatCompiler)

Example 3 with TimestampFormatCompiler

use of io.questdb.std.datetime.microtime.TimestampFormatCompiler 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());
}
Also used : FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) FilesFacade(io.questdb.std.FilesFacade) TimestampFormatCompiler(io.questdb.std.datetime.microtime.TimestampFormatCompiler) DateFormat(io.questdb.std.datetime.DateFormat) BindVariableServiceImpl(io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl) File(java.io.File)

Aggregations

TimestampFormatCompiler (io.questdb.std.datetime.microtime.TimestampFormatCompiler)3 DateFormat (io.questdb.std.datetime.DateFormat)2 BindVariableServiceImpl (io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)1 FilesFacade (io.questdb.std.FilesFacade)1 FilesFacadeImpl (io.questdb.std.FilesFacadeImpl)1 DateLocale (io.questdb.std.datetime.DateLocale)1 Path (io.questdb.std.str.Path)1 File (java.io.File)1