use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testJournalRefresh.
@Test
public void testJournalRefresh() throws Exception {
createTabWithNaNs();
assertThat("10000\n", "select count() from tab");
try (JournalWriter w = getFactory().writer("tab")) {
w.setSequentialAccess(true);
appendNaNs(w, DateFormatUtils.parseDateTime("2015-10-12T00:00:00.000Z"));
}
assertThat("20000\n", "select count() from tab");
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method createTabNoNaNs.
private void createTabNoNaNs() throws JournalException, NumericException {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$long("z").$int("w").$ts())) {
Rnd rnd = new Rnd();
int n = 128;
ObjHashSet<String> names = getNames(rnd, n);
int mask = n - 1;
long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
for (int i = 0; i < 10000; i++) {
JournalEntryWriter ew = w.entryWriter();
ew.putStr(0, names.get(rnd.nextInt() & mask));
ew.putDouble(1, rnd.nextDouble());
ew.putDouble(2, rnd.nextDouble());
ew.putLong(3, rnd.nextLong());
ew.putInt(4, rnd.nextInt());
ew.putDate(5, t += 10);
ew.append();
}
w.commit();
}
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testSearchIndexedStrNull.
@Test
public void testSearchIndexedStrNull() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").index().buckets(128).$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
ObjHashSet<String> names = new ObjHashSet<>();
for (int i = 0; i < 128; i++) {
names.add(rnd.nextString(15));
}
int mask = 127;
long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
for (int i = 0; i < 10000; i++) {
JournalEntryWriter ew = w.entryWriter();
if ((rnd.nextPositiveInt() % 10) == 0) {
ew.putNull(0);
} else {
ew.putStr(0, names.get(rnd.nextInt() & mask));
}
ew.putDouble(1, rnd.nextDouble());
ew.putDouble(2, rnd.nextDouble());
ew.putDate(3, t += 10);
ew.append();
}
w.commit();
}
assertNullSearch();
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testSearchIndexedSymNull.
@Test
public void testSearchIndexedSymNull() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$sym("id").index().buckets(128).$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
ObjHashSet<String> names = getNames(rnd, 128);
int mask = 127;
long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
for (int i = 0; i < 10000; i++) {
JournalEntryWriter ew = w.entryWriter();
if ((rnd.nextPositiveInt() % 10) == 0) {
ew.putNull(0);
} else {
ew.putSym(0, names.get(rnd.nextInt() & mask));
}
ew.putDouble(1, rnd.nextDouble());
ew.putDouble(2, rnd.nextDouble());
ew.putDate(3, t += 10);
ew.append();
}
w.commit();
}
assertNullSearch();
}
use of com.questdb.store.JournalWriter 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());
}
}
Aggregations