Search in sources :

Example 16 with JournalMetadata

use of com.questdb.store.factory.configuration.JournalMetadata in project questdb by bluestreak01.

the class DDLTests method testCreateIndexedSymbol.

@Test
public void testCreateIndexedSymbol() throws Exception {
    exec("create table x (a INT index buckets 25, b BYTE, t DATE, x SYMBOL index) timestamp(t) partition by MONTH");
    // validate journal
    try (Journal r = getFactory().reader("x")) {
        Assert.assertNotNull(r);
        JournalMetadata m = r.getMetadata();
        Assert.assertEquals(4, m.getColumnCount());
        Assert.assertEquals(ColumnType.INT, m.getColumn("a").getType());
        Assert.assertTrue(m.getColumn("a").isIndexed());
        // bucket is ceilPow2(value) - 1
        Assert.assertEquals(31, m.getColumn("a").getBucketCount());
        Assert.assertEquals(ColumnType.BYTE, m.getColumn("b").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("t").getType());
        Assert.assertEquals(ColumnType.SYMBOL, m.getColumn("x").getType());
        Assert.assertTrue(m.getColumn("x").isIndexed());
        Assert.assertEquals(2, m.getTimestampIndex());
        Assert.assertEquals(PartitionBy.MONTH, m.getPartitionBy());
    }
}
Also used : JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata) Journal(com.questdb.store.Journal) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 17 with JournalMetadata

use of com.questdb.store.factory.configuration.JournalMetadata in project questdb by bluestreak01.

the class DDLTests method testCreateIndexWithSuffix.

@Test
public void testCreateIndexWithSuffix() throws Exception {
    exec("create table x (a INT, b BYTE, t DATE, x SYMBOL), index(a buckets 25), index(x) timestamp(t) partition by YEAR record hint 100");
    // validate journal
    try (Journal r = getFactory().reader("x")) {
        Assert.assertNotNull(r);
        JournalMetadata m = r.getMetadata();
        Assert.assertEquals(4, m.getColumnCount());
        Assert.assertEquals(ColumnType.INT, m.getColumn("a").getType());
        Assert.assertTrue(m.getColumn("a").isIndexed());
        // bucket is ceilPow2(value) - 1
        Assert.assertEquals(31, m.getColumn("a").getBucketCount());
        Assert.assertEquals(ColumnType.BYTE, m.getColumn("b").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("t").getType());
        Assert.assertEquals(ColumnType.SYMBOL, m.getColumn("x").getType());
        Assert.assertTrue(m.getColumn("x").isIndexed());
        Assert.assertEquals(2, m.getTimestampIndex());
        Assert.assertEquals(PartitionBy.YEAR, m.getPartitionBy());
    }
}
Also used : JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata) Journal(com.questdb.store.Journal) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 18 with JournalMetadata

use of com.questdb.store.factory.configuration.JournalMetadata in project questdb by bluestreak01.

the class DDLTests method testCreateAllFieldTypes.

@Test
public void testCreateAllFieldTypes() throws Exception {
    exec("create table x (a INT, b BYTE, c SHORT, d LONG, e FLOAT, f DOUBLE, g DATE, h BINARY, t DATE, x SYMBOL, z STRING, y BOOLEAN) timestamp(t) partition by MONTH record hint 100");
    // validate journal
    try (Journal r = getFactory().reader("x")) {
        Assert.assertNotNull(r);
        JournalMetadata m = r.getMetadata();
        Assert.assertEquals(12, m.getColumnCount());
        Assert.assertEquals(ColumnType.INT, m.getColumn("a").getType());
        Assert.assertEquals(ColumnType.BYTE, m.getColumn("b").getType());
        Assert.assertEquals(ColumnType.SHORT, m.getColumn("c").getType());
        Assert.assertEquals(ColumnType.LONG, m.getColumn("d").getType());
        Assert.assertEquals(ColumnType.FLOAT, m.getColumn("e").getType());
        Assert.assertEquals(ColumnType.DOUBLE, m.getColumn("f").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("g").getType());
        Assert.assertEquals(ColumnType.BINARY, m.getColumn("h").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("t").getType());
        Assert.assertEquals(ColumnType.SYMBOL, m.getColumn("x").getType());
        Assert.assertEquals(ColumnType.STRING, m.getColumn("z").getType());
        Assert.assertEquals(ColumnType.BOOLEAN, m.getColumn("y").getType());
        Assert.assertEquals(8, m.getTimestampIndex());
        Assert.assertEquals(PartitionBy.MONTH, m.getPartitionBy());
    }
}
Also used : JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata) Journal(com.questdb.store.Journal) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 19 with JournalMetadata

use of com.questdb.store.factory.configuration.JournalMetadata in project questdb by bluestreak01.

the class DDLTests method testCreateAsSelectPartitioned.

@Test
public void testCreateAsSelectPartitioned() throws Exception {
    exec("create table y (a INT, b BYTE, c SHORT, d LONG, e FLOAT, f DOUBLE, g DATE, h BINARY, t DATE, x SYMBOL, z STRING) timestamp(t) partition by YEAR record hint 100");
    try (JournalWriter w = compiler.createWriter(getFactory(), "create table x as (y order by t) partition by MONTH record hint 100")) {
        JournalMetadata m = w.getMetadata();
        Assert.assertEquals(11, m.getColumnCount());
        Assert.assertEquals(ColumnType.INT, m.getColumn("a").getType());
        Assert.assertEquals(ColumnType.BYTE, m.getColumn("b").getType());
        Assert.assertEquals(ColumnType.SHORT, m.getColumn("c").getType());
        Assert.assertEquals(ColumnType.LONG, m.getColumn("d").getType());
        Assert.assertEquals(ColumnType.FLOAT, m.getColumn("e").getType());
        Assert.assertEquals(ColumnType.DOUBLE, m.getColumn("f").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("g").getType());
        Assert.assertEquals(ColumnType.BINARY, m.getColumn("h").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("t").getType());
        Assert.assertEquals(ColumnType.SYMBOL, m.getColumn("x").getType());
        Assert.assertEquals(ColumnType.STRING, m.getColumn("z").getType());
        Assert.assertEquals(8, m.getTimestampIndex());
        Assert.assertEquals(PartitionBy.MONTH, m.getPartitionBy());
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 20 with JournalMetadata

use of com.questdb.store.factory.configuration.JournalMetadata in project questdb by bluestreak01.

the class DDLTests method testCreateAsSelectPartitionBy.

@Test
public void testCreateAsSelectPartitionBy() throws Exception {
    exec("create table y (a INT, b BYTE, c SHORT, d LONG, e FLOAT, f DOUBLE, g DATE, h BINARY, t DATE, x SYMBOL, z STRING) timestamp(t) partition by YEAR record hint 100");
    try (JournalWriter w = compiler.createWriter(getFactory(), "create table x as (y order by t) partition by MONTH record hint 100")) {
        JournalMetadata m = w.getMetadata();
        Assert.assertEquals(11, m.getColumnCount());
        Assert.assertEquals(ColumnType.INT, m.getColumn("a").getType());
        Assert.assertEquals(ColumnType.BYTE, m.getColumn("b").getType());
        Assert.assertEquals(ColumnType.SHORT, m.getColumn("c").getType());
        Assert.assertEquals(ColumnType.LONG, m.getColumn("d").getType());
        Assert.assertEquals(ColumnType.FLOAT, m.getColumn("e").getType());
        Assert.assertEquals(ColumnType.DOUBLE, m.getColumn("f").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("g").getType());
        Assert.assertEquals(ColumnType.BINARY, m.getColumn("h").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("t").getType());
        Assert.assertEquals(ColumnType.SYMBOL, m.getColumn("x").getType());
        Assert.assertEquals(ColumnType.STRING, m.getColumn("z").getType());
        Assert.assertEquals(8, m.getTimestampIndex());
        Assert.assertEquals(PartitionBy.MONTH, m.getPartitionBy());
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Aggregations

JournalMetadata (com.questdb.store.factory.configuration.JournalMetadata)29 Test (org.junit.Test)22 AbstractTest (com.questdb.test.tools.AbstractTest)19 Journal (com.questdb.store.Journal)14 JournalWriter (com.questdb.store.JournalWriter)5 JournalException (com.questdb.std.ex.JournalException)3 File (java.io.File)3 FactoryFullException (com.questdb.ex.FactoryFullException)2 JournalLockedException (com.questdb.ex.JournalLockedException)2 RetryLockException (com.questdb.ex.RetryLockException)2 ImportedColumnMetadata (com.questdb.parser.ImportedColumnMetadata)2 RecordSource (com.questdb.ql.RecordSource)2 Rnd (com.questdb.std.Rnd)2 Path (com.questdb.std.str.Path)2 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 CyclicBarrier (java.util.concurrent.CyclicBarrier)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 RecordColumnMetadata (com.questdb.common.RecordColumnMetadata)1 IncompatibleJournalException (com.questdb.ex.IncompatibleJournalException)1