Search in sources :

Example 21 with JournalMetadata

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

the class DDLTests method testCreateAsSelectIndexes.

@Test
public void testCreateAsSelectIndexes() 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), index (a), index(x), index(z)")) {
        JournalMetadata m = w.getMetadata();
        Assert.assertEquals(11, m.getColumnCount());
        Assert.assertEquals(ColumnType.INT, m.getColumn("a").getType());
        Assert.assertTrue(m.getColumn("a").isIndexed());
        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.assertTrue(m.getColumn("x").isIndexed());
        Assert.assertEquals(ColumnType.STRING, m.getColumn("z").getType());
        Assert.assertTrue(m.getColumn("z").isIndexed());
        Assert.assertEquals(8, m.getTimestampIndex());
        Assert.assertEquals(PartitionBy.NONE, 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 22 with JournalMetadata

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

the class DDLTests method testCreateAsSelect.

@Test
public void testCreateAsSelect() 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)")) {
        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.NONE, 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 23 with JournalMetadata

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

the class DDLTests method testCreateIndexedInt.

@Test
public void testCreateIndexedInt() throws Exception {
    exec("create table x (a INT index buckets 25, b BYTE, t DATE, x SYMBOL) 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(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.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 24 with JournalMetadata

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

the class CachingWriterFactory method checkAndReturn.

private JournalWriter checkAndReturn(long thread, Entry e, String name, JournalMetadata<?> metadata) throws JournalException {
    JournalMetadata wm = e.writer.getMetadata();
    if (metadata.isCompatible(wm, false)) {
        if (metadata.getModelClass() != null && wm.getModelClass() == null) {
            closeWriter(thread, e, FactoryEventListener.EV_CLOSE, FactoryEventListener.EV_CLOSE_EX, PoolConstants.CR_REOPEN);
            return createWriter(thread, name, e, metadata);
        } else {
            LOG.info().$("Writer '").$(name).$("' is assigned to thread ").$(thread).$();
            notifyListener(thread, name, FactoryEventListener.EV_GET);
            return e.writer;
        }
    }
    JournalMetadataException ex = new JournalMetadataException(wm, metadata);
    notifyListener(thread, name, FactoryEventListener.EV_INCOMPATIBLE);
    if (closed) {
        closeWriter(thread, e, FactoryEventListener.EV_CLOSE, FactoryEventListener.EV_CLOSE_EX, PoolConstants.CR_POOL_CLOSE);
    }
    e.owner = -1L;
    throw ex;
}
Also used : JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata)

Example 25 with JournalMetadata

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

the class Factory method getMetadata.

public JournalMetadata getMetadata(String name) throws JournalException {
    JournalMetadata metadata = metadataCache.get(name);
    if (metadata != null) {
        return metadata;
    }
    metadata = configuration.readMetadata(name);
    JournalMetadata other = metadataCache.putIfAbsent(name, metadata);
    if (other != null) {
        return other;
    }
    return metadata;
}
Also used : JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata)

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