use of com.questdb.store.JournalEntryWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testIntComparison.
@Test
public void testIntComparison() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$sym("id").index().buckets(128).$double("x").$double("y").$int("i1").$int("i2").$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();
ew.putSym(0, names.get(rnd.nextInt() & mask));
ew.putDouble(1, rnd.nextDouble());
ew.putDouble(2, rnd.nextDouble());
ew.putInt(3, rnd.nextInt() & 63);
ew.putInt(4, rnd.nextInt() & 63);
ew.putDate(5, t += 10);
ew.append();
}
w.commit();
}
final String expected1 = "XSPEPTTKIBWFCKD\t290.742401123047\t0.000001862155\t2\t1\n" + "XSPEPTTKIBWFCKD\t294.856933593750\t-539.875854492188\t55\t42\n" + "XSPEPTTKIBWFCKD\t422.000000000000\t0.000001386965\t58\t54\n";
assertThat(expected1, "select id,x,y,i1,i2 from tab where i1 >= i2 and x>=y and x>=i1 and id = 'XSPEPTTKIBWFCKD'");
final String expected2 = "XSPEPTTKIBWFCKD\t0.007556580706\t-444.759765625000\t14\t20\n" + "XSPEPTTKIBWFCKD\t0.002191273379\t-587.421875000000\t1\t33\n" + "XSPEPTTKIBWFCKD\t0.000000050401\t-873.569183349609\t34\t41\n" + "XSPEPTTKIBWFCKD\t0.000000002468\t-1009.435546875000\t7\t35\n" + "XSPEPTTKIBWFCKD\t0.000000134022\t0.000000010189\t38\t44\n" + "XSPEPTTKIBWFCKD\t0.053807163611\t0.000000005584\t18\t40\n" + "XSPEPTTKIBWFCKD\t307.605468750000\t0.000000032526\t5\t49\n" + "XSPEPTTKIBWFCKD\t588.000000000000\t0.000029410815\t42\t62\n" + "XSPEPTTKIBWFCKD\t102.474868774414\t-704.000000000000\t61\t63\n" + "XSPEPTTKIBWFCKD\t0.000166006441\t-400.250000000000\t23\t49\n" + "XSPEPTTKIBWFCKD\t0.006018321496\t0.000000163838\t21\t55\n" + "XSPEPTTKIBWFCKD\t82.432384490967\t0.000043923766\t36\t45\n" + "XSPEPTTKIBWFCKD\t256.000000000000\t-648.000000000000\t12\t46\n" + "XSPEPTTKIBWFCKD\t384.875000000000\t0.000049836333\t23\t46\n" + "XSPEPTTKIBWFCKD\t0.000000883287\t-844.890625000000\t4\t24\n" + "XSPEPTTKIBWFCKD\t0.103299163282\t0.000076360289\t16\t54\n" + "XSPEPTTKIBWFCKD\t0.003647925099\t0.000000019679\t15\t38\n" + "XSPEPTTKIBWFCKD\t0.000589750460\t0.000000023659\t4\t39\n";
assertThat(expected2, "select id,x,y,i1,i2 from tab where i1 < i2 and x>=y and y<i1 and id = 'XSPEPTTKIBWFCKD'");
}
use of com.questdb.store.JournalEntryWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method createTab.
private void createTab() throws JournalException, NumericException {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
ObjHashSet<String> names = getNames(rnd, 1024);
int mask = 1023;
long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
for (int i = 0; i < 100000; i++) {
JournalEntryWriter ew = w.entryWriter();
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();
}
}
use of com.questdb.store.JournalEntryWriter 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.JournalEntryWriter 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.JournalEntryWriter 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();
}
Aggregations