use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testSearchByStringIdInUnindexed.
@Test
public void testSearchByStringIdInUnindexed() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
int n = 4 * 1024;
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 < 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();
}
final String expected = "VEGPIGSVMYWRTXV\t0.000015968965\t675.997558593750\n" + "VEGPIGSVMYWRTXV\t86.369699478149\t0.000017492367\n" + "JKEQQKQWPJVCFKV\t-141.875000000000\t2.248494863510\n" + "JKEQQKQWPJVCFKV\t-311.641113281250\t-398.023437500000\n" + "VEGPIGSVMYWRTXV\t3.659749031067\t0.000001526956\n" + "VEGPIGSVMYWRTXV\t-87.500000000000\t-778.964843750000\n" + "JKEQQKQWPJVCFKV\t0.000000000841\t0.000000048359\n" + "JKEQQKQWPJVCFKV\t4.028919816017\t576.000000000000\n" + "VEGPIGSVMYWRTXV\t896.000000000000\t0.000000293617\n" + "VEGPIGSVMYWRTXV\t-1024.000000000000\t0.000001939648\n" + "VEGPIGSVMYWRTXV\t0.000019246366\t-1024.000000000000\n" + "VEGPIGSVMYWRTXV\t410.933593750000\t0.000000039558\n" + "JKEQQKQWPJVCFKV\t0.057562204078\t0.052935207263\n" + "VEGPIGSVMYWRTXV\t0.000000001681\t0.000000007821\n" + "VEGPIGSVMYWRTXV\t-1024.000000000000\t-921.363525390625\n" + "JKEQQKQWPJVCFKV\t0.000003027280\t43.346537590027\n" + "VEGPIGSVMYWRTXV\t0.000000009230\t99.335662841797\n" + "JKEQQKQWPJVCFKV\t266.000000000000\t0.000033699243\n" + "VEGPIGSVMYWRTXV\t5.966133117676\t0.000019340443\n" + "VEGPIGSVMYWRTXV\t0.000001273319\t0.000020025251\n" + "JKEQQKQWPJVCFKV\t0.007589547429\t0.016206960194\n" + "JKEQQKQWPJVCFKV\t-256.000000000000\t213.664222717285\n" + "VEGPIGSVMYWRTXV\t5.901823043823\t0.226934209466\n" + "VEGPIGSVMYWRTXV\t0.000033694661\t0.036246776581\n" + "JKEQQKQWPJVCFKV\t22.610988616943\t0.000000000000\n" + "VEGPIGSVMYWRTXV\t0.000000600285\t896.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000030440875\t0.000000002590\n" + "VEGPIGSVMYWRTXV\t-612.819580078125\t-768.000000000000\n" + "VEGPIGSVMYWRTXV\t652.960937500000\t-163.895019531250\n" + "JKEQQKQWPJVCFKV\t0.000001019223\t0.000861373846\n" + "VEGPIGSVMYWRTXV\t0.000000237054\t855.149673461914\n" + "JKEQQKQWPJVCFKV\t384.625000000000\t-762.664184570313\n" + "VEGPIGSVMYWRTXV\t0.000000003865\t269.064453125000\n" + "VEGPIGSVMYWRTXV\t1.651362478733\t640.000000000000\n" + "JKEQQKQWPJVCFKV\t0.772825062275\t701.435363769531\n" + "JKEQQKQWPJVCFKV\t191.932769775391\t0.000013081920\n" + "JKEQQKQWPJVCFKV\t416.812500000000\t0.000000003177\n" + "JKEQQKQWPJVCFKV\t0.000003838093\t810.968750000000\n" + "VEGPIGSVMYWRTXV\t0.042331939563\t368.000000000000\n" + "VEGPIGSVMYWRTXV\t0.038675817661\t-69.960937500000\n" + "VEGPIGSVMYWRTXV\t0.154417395592\t0.000000005908\n" + "JKEQQKQWPJVCFKV\t0.041989765130\t728.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000000000000\t-89.843750000000\n" + "VEGPIGSVMYWRTXV\t-224.000000000000\t247.625000000000\n";
assertThat(expected, "select id, x,y from tab where id in ('JKEQQKQWPJVCFKV', 'VEGPIGSVMYWRTXV')");
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testSearchByStringIdInUnindexed2.
@Test
public void testSearchByStringIdInUnindexed2() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
int n = 4 * 1024;
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 < 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();
}
final String expected = "JKEQQKQWPJVCFKV\t-141.875000000000\t2.248494863510\n" + "JKEQQKQWPJVCFKV\t-311.641113281250\t-398.023437500000\n" + "JKEQQKQWPJVCFKV\t0.000000000841\t0.000000048359\n" + "JKEQQKQWPJVCFKV\t4.028919816017\t576.000000000000\n" + "JKEQQKQWPJVCFKV\t0.057562204078\t0.052935207263\n" + "JKEQQKQWPJVCFKV\t0.000003027280\t43.346537590027\n" + "JKEQQKQWPJVCFKV\t266.000000000000\t0.000033699243\n" + "JKEQQKQWPJVCFKV\t0.007589547429\t0.016206960194\n" + "JKEQQKQWPJVCFKV\t-256.000000000000\t213.664222717285\n" + "JKEQQKQWPJVCFKV\t22.610988616943\t0.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000030440875\t0.000000002590\n" + "JKEQQKQWPJVCFKV\t0.000001019223\t0.000861373846\n" + "JKEQQKQWPJVCFKV\t384.625000000000\t-762.664184570313\n" + "JKEQQKQWPJVCFKV\t0.772825062275\t701.435363769531\n" + "JKEQQKQWPJVCFKV\t191.932769775391\t0.000013081920\n" + "JKEQQKQWPJVCFKV\t416.812500000000\t0.000000003177\n" + "JKEQQKQWPJVCFKV\t0.000003838093\t810.968750000000\n" + "JKEQQKQWPJVCFKV\t0.041989765130\t728.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000000000000\t-89.843750000000\n";
assertThat(expected, "select id, x,y from tab where id in ('JKEQQKQWPJVCFKV')");
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method createTabWithNaNs20.
private void createTabWithNaNs20(JournalStructure struct) throws JournalException, NumericException {
try (JournalWriter w = getFactory().writer(struct)) {
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());
if (rnd.nextPositiveInt() % 10 == 0) {
ew.putNull(2);
} else {
ew.putDouble(2, rnd.nextDouble());
}
if (rnd.nextPositiveInt() % 10 == 0) {
ew.putNull(3);
} else {
ew.putLong(3, rnd.nextLong() % 500);
}
if (rnd.nextPositiveInt() % 10 == 0) {
ew.putNull(4);
} else {
ew.putInt(4, rnd.nextInt() % 500);
}
ew.putDate(5, t += (60 * 60 * 1000));
ew.append();
}
w.commit();
}
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testUnindexedIntNaN.
@Test
public void testUnindexedIntNaN() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$int("id").$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
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.putInt(0, rnd.nextInt());
}
ew.putDouble(1, rnd.nextDouble());
ew.putDouble(2, rnd.nextDouble());
ew.putDate(3, t += 10);
ew.append();
}
w.commit();
}
final String expected = "NaN\t768.000000000000\t-408.000000000000\n" + "NaN\t256.000000000000\t-455.750000000000\n" + "NaN\t525.287368774414\t-470.171875000000\n" + "NaN\t512.000000000000\t-425.962463378906\n" + "NaN\t553.796875000000\t-620.062500000000\n" + "NaN\t512.000000000000\t-958.144531250000\n" + "NaN\t304.062500000000\t-1024.000000000000\n" + "NaN\t600.000000000000\t-934.000000000000\n" + "NaN\t475.619140625000\t-431.078125000000\n" + "NaN\t864.000000000000\t-480.723571777344\n" + "NaN\t512.000000000000\t-585.500000000000\n" + "NaN\t183.876594543457\t-512.000000000000\n" + "NaN\t204.021038055420\t-453.903320312500\n" + "NaN\t272.363739013672\t-1024.000000000000\n" + "NaN\t973.989135742188\t-444.000000000000\n" + "NaN\t768.000000000000\t-1024.000000000000\n" + "NaN\t290.253906250000\t-960.000000000000\n" + "NaN\t263.580390930176\t-960.000000000000\n" + "NaN\t756.500000000000\t-1024.000000000000\n" + "NaN\t461.884765625000\t-921.996948242188\n" + "NaN\t512.000000000000\t-536.000000000000\n" + "NaN\t213.152450561523\t-811.783691406250\n" + "NaN\t121.591918945313\t-874.921630859375\n" + "NaN\t920.625000000000\t-512.000000000000\n";
assertThat(expected, "select id, x, y from tab where id = NaN and x > 120 and y < -400");
}
use of com.questdb.store.JournalWriter in project questdb by bluestreak01.
the class SingleJournalQueryTest method testAtoI.
@Test
public void testAtoI() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("intC").$())) {
StringSink sink = new StringSink();
Rnd rnd = new Rnd();
for (int i = 0; i < 30; i++) {
sink.clear();
Numbers.append(sink, rnd.nextInt());
CharSequence cs = rnd.nextChars(4);
JournalEntryWriter ew = w.entryWriter();
ew.putStr(0, rnd.nextBoolean() ? cs : sink);
ew.append();
}
w.commit();
final String expected = "-1148479920\t-1148479920\n" + "1326447242\t1326447242\n" + "-1436881714\t-1436881714\n" + "-409854405\t-409854405\n" + "1125579207\t1125579207\n" + "-1844391305\t-1844391305\n" + "-1125169127\t-1125169127\n" + "-2119387831\t-2119387831\n" + "-422941535\t-422941535\n" + "-2132716300\t-2132716300\n" + "-483853667\t-483853667\n" + "NaN\tQQUL\n" + "-1418341054\t-1418341054\n" + "936627841\t936627841\n" + "NaN\tFBVT\n" + "-1515787781\t-1515787781\n" + "-1538602195\t-1538602195\n" + "-10505757\t-10505757\n" + "NaN\tICWE\n" + "1876812930\t1876812930\n" + "NaN\tOTSE\n" + "-916132123\t-916132123\n" + "NaN\tLYXW\n" + "NaN\tYLSU\n" + "-1768335227\t-1768335227\n" + "-876466531\t-876466531\n" + "NaN\tQBZX\n" + "NaN\tVIKJ\n" + "-2088317486\t-2088317486\n" + "614536941\t614536941\n";
assertThat(expected, "select atoi(intC), intC from tab");
assertThat("-1.14847992E9\t-1148479920\n" + "1.326447242E9\t1326447242\n" + "-1.436881714E9\t-1436881714\n" + "-4.09854405E8\t-409854405\n" + "1.125579207E9\t1125579207\n" + "-1.844391305E9\t-1844391305\n" + "-1.125169127E9\t-1125169127\n" + "-2.119387831E9\t-2119387831\n" + "-4.22941535E8\t-422941535\n" + "-2.1327163E9\t-2132716300\n" + "-4.83853667E8\t-483853667\n" + "NaN\tQQUL\n" + "-1.418341054E9\t-1418341054\n" + "9.36627841E8\t936627841\n" + "NaN\tFBVT\n" + "-1.515787781E9\t-1515787781\n" + "-1.538602195E9\t-1538602195\n" + "-1.0505757E7\t-10505757\n" + "NaN\tICWE\n" + "1.87681293E9\t1876812930\n" + "NaN\tOTSE\n" + "-9.16132123E8\t-916132123\n" + "NaN\tLYXW\n" + "NaN\tYLSU\n" + "-1.768335227E9\t-1768335227\n" + "-8.76466531E8\t-876466531\n" + "NaN\tQBZX\n" + "NaN\tVIKJ\n" + "-2.088317486E9\t-2088317486\n" + "6.14536941E8\t614536941\n", "select atod(intC), intC from tab");
}
}
Aggregations