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());
}
}
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());
}
}
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());
}
}
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;
}
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;
}
Aggregations