use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.
the class NullAggregationTest method createTabWithNaNs2.
private static void createTabWithNaNs2() throws JournalException, NumericException {
try (JournalWriter w = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$long("z").$int("w").$str("a").$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());
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);
}
if (rnd.nextPositiveInt() % 10 == 0) {
ew.putNull(5);
} else {
ew.putStr(5, names.get(rnd.nextInt() & mask));
}
ew.putDate(6, t += (60 * 60 * 1000));
ew.append();
}
w.commit();
}
}
use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.
the class NullCountingTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
int recordCount = 10000;
int productCount = 200;
int employeeCount = 10;
try (JournalWriter orders = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("orders").$int("orderId").$int("customerId").$str("productId").$sym("employeeId").$ts("orderDate").$int("quantity").$double("price").$float("rate").$long("x").recordCountHint(recordCount).$())) {
Rnd rnd = new Rnd();
String[] employees = new String[employeeCount];
for (int i = 0; i < employees.length; i++) {
if (rnd.nextPositiveInt() % 10 == 0) {
employees[i] = null;
} else {
employees[i] = rnd.nextString(9);
}
}
String[] productId = new String[productCount];
for (int i = 0; i < productId.length; i++) {
if (rnd.nextPositiveInt() % 30 == 0) {
productId[i] = null;
} else {
productId[i] = rnd.nextString(9);
}
}
long timestamp = DateFormatUtils.parseDateTime("2014-05-04T10:30:00.000Z");
int tsIncrement = 10000;
int orderId = 0;
for (int i = 0; i < recordCount; i++) {
JournalEntryWriter w = orders.entryWriter();
w.putInt(0, ++orderId);
w.putInt(1, rnd.nextPositiveInt() % 500);
w.putStr(2, productId[rnd.nextPositiveInt() % productCount]);
w.putSym(3, employees[rnd.nextPositiveInt() % employeeCount]);
w.putDate(4, timestamp += tsIncrement);
w.putInt(5, rnd.nextPositiveInt() % 10 == 0 ? Numbers.INT_NaN : rnd.nextPositiveInt());
w.putDouble(6, rnd.nextPositiveInt() % 10 == 0 ? Double.NaN : rnd.nextDouble());
w.putFloat(7, rnd.nextPositiveInt() % 10 == 0 ? Float.NaN : rnd.nextFloat());
w.putLong(8, rnd.nextPositiveInt() % 10 == 0 ? Numbers.LONG_NaN : rnd.nextLong());
w.append();
}
orders.commit();
}
}
use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.
the class QueryDateTest method createTab.
private void createTab() throws JournalException, NumericException {
try (JournalWriter w = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$date("z").$date("w").$ts())) {
Rnd rnd = new Rnd();
long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
long time1 = DateFormatUtils.parseDateTime("2015-10-03T00:00:00.000Z");
for (int i = 0; i < 10000; i++) {
JournalEntryWriter ew = w.entryWriter();
ew.putStr(0, rnd.nextChars(15));
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.putDate(3, time1 + rnd.nextLong() % 5000000);
}
ew.putDate(5, t += 10);
ew.append();
}
w.commit();
}
}
use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.
the class SingleJournalQueryTest method testSearchByIntIdUnindexed.
@Test
public void testSearchByIntIdUnindexed() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$int("id").$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
int[] ids = new int[4096];
for (int i = 0; i < ids.length; i++) {
ids[i] = rnd.nextPositiveInt();
}
int mask = ids.length - 1;
long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
for (int i = 0; i < 100000; i++) {
JournalEntryWriter ew = w.entryWriter();
ew.putInt(0, ids[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 = "1148688404\t19.165769577026\t0.002435457427\t2015-03-12T00:00:10.150Z\n" + "1148688404\t0.000000444469\t2.694594800472\t2015-03-12T00:00:28.400Z\n" + "1148688404\t-640.000000000000\t-1024.000000000000\t2015-03-12T00:01:06.260Z\n" + "1148688404\t0.000000009509\t320.000000000000\t2015-03-12T00:01:26.010Z\n" + "1148688404\t0.000107977266\t362.467056274414\t2015-03-12T00:01:57.750Z\n" + "1148688404\t0.000000022366\t-451.815429687500\t2015-03-12T00:02:32.560Z\n" + "1148688404\t0.000003631694\t152.575393676758\t2015-03-12T00:02:35.210Z\n" + "1148688404\t-458.523437500000\t0.003299130592\t2015-03-12T00:03:09.590Z\n" + "1148688404\t-576.000000000000\t0.000000005352\t2015-03-12T00:03:15.080Z\n" + "1148688404\t0.000000010009\t0.000000336123\t2015-03-12T00:03:33.830Z\n" + "1148688404\t0.012756480370\t0.191264979541\t2015-03-12T00:03:56.200Z\n" + "1148688404\t-793.000000000000\t6.048339843750\t2015-03-12T00:04:01.350Z\n" + "1148688404\t0.000144788552\t10.723476886749\t2015-03-12T00:04:48.380Z\n" + "1148688404\t-467.990722656250\t5.262818336487\t2015-03-12T00:04:52.710Z\n" + "1148688404\t0.031378546730\t149.346038818359\t2015-03-12T00:05:01.020Z\n" + "1148688404\t0.000741893891\t-27.789062500000\t2015-03-12T00:05:19.110Z\n" + "1148688404\t0.000000032685\t0.000000002490\t2015-03-12T00:05:26.610Z\n" + "1148688404\t0.652305364609\t0.000000029041\t2015-03-12T00:06:56.860Z\n" + "1148688404\t-894.000000000000\t51.695074081421\t2015-03-12T00:08:46.620Z\n" + "1148688404\t695.000000000000\t0.145211979747\t2015-03-12T00:09:22.390Z\n" + "1148688404\t-334.488891601563\t0.000000393977\t2015-03-12T00:09:29.860Z\n" + "1148688404\t7.933303117752\t0.000516850792\t2015-03-12T00:10:13.730Z\n" + "1148688404\t435.498107910156\t1.287820875645\t2015-03-12T00:10:30.240Z\n" + "1148688404\t961.880340576172\t0.000168625862\t2015-03-12T00:10:41.190Z\n" + "1148688404\t-84.978515625000\t0.051617769524\t2015-03-12T00:10:46.200Z\n" + "1148688404\t0.000000544715\t0.000328194423\t2015-03-12T00:10:52.510Z\n" + "1148688404\t512.000000000000\t875.250000000000\t2015-03-12T00:11:46.390Z\n" + "1148688404\t0.000000010856\t0.028837248683\t2015-03-12T00:12:15.140Z\n" + "1148688404\t0.000027862162\t-896.000000000000\t2015-03-12T00:12:28.700Z\n" + "1148688404\t0.000000003071\t0.000025084717\t2015-03-12T00:12:36.370Z\n" + "1148688404\t0.000040687404\t0.007985642878\t2015-03-12T00:12:42.940Z\n" + "1148688404\t-961.937500000000\t-849.000000000000\t2015-03-12T00:12:49.940Z\n" + "1148688404\t0.000384466533\t87.682281494141\t2015-03-12T00:14:11.980Z\n" + "1148688404\t0.000000309420\t448.000000000000\t2015-03-12T00:15:38.730Z\n" + "1148688404\t29.022820472717\t-123.758422851563\t2015-03-12T00:16:30.770Z\n";
assertThat(expected, "select id, x, y, timestamp from tab where id = 1148688404");
}
use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.
the class SingleJournalQueryTest method testMultipleStrIdSearchUsingHeapMerge.
@Test
public void testMultipleStrIdSearchUsingHeapMerge() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").index().buckets(32).$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 < 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.putDate(3, t += 10);
ew.append();
}
w.commit();
}
final String expected = "UHUTMTRRNGCIPFZ\t0.000006506322\t-261.000000000000\t2015-03-12T00:00:00.220Z\n" + "FZICFOQEVPXJYQR\t0.000000166602\t367.625000000000\t2015-03-12T00:00:00.260Z\n" + "KJSMSSUQSRLTKVV\t0.000000000000\t696.000000000000\t2015-03-12T00:00:01.200Z\n" + "FZICFOQEVPXJYQR\t57.308933258057\t28.255742073059\t2015-03-12T00:00:09.750Z\n" + "UHUTMTRRNGCIPFZ\t0.000005319798\t-727.000000000000\t2015-03-12T00:00:10.060Z\n" + "KJSMSSUQSRLTKVV\t-512.000000000000\t12.906219482422\t2015-03-12T00:00:11.190Z\n" + "FZICFOQEVPXJYQR\t-432.500000000000\t0.013725134078\t2015-03-12T00:00:13.470Z\n" + "FZICFOQEVPXJYQR\t-247.761962890625\t768.000000000000\t2015-03-12T00:00:15.170Z\n" + "UHUTMTRRNGCIPFZ\t438.929687500000\t0.000031495110\t2015-03-12T00:00:18.300Z\n" + "FZICFOQEVPXJYQR\t264.789741516113\t0.033011944033\t2015-03-12T00:00:19.630Z\n" + "FZICFOQEVPXJYQR\t6.671853065491\t1.936547994614\t2015-03-12T00:00:20.620Z\n" + "KJSMSSUQSRLTKVV\t664.132812500000\t512.000000000000\t2015-03-12T00:00:25.960Z\n" + "UHUTMTRRNGCIPFZ\t864.000000000000\t-1024.000000000000\t2015-03-12T00:00:25.970Z\n" + "UHUTMTRRNGCIPFZ\t0.002082723950\t0.000000001586\t2015-03-12T00:00:26.760Z\n" + "KJSMSSUQSRLTKVV\t0.000000078358\t-1024.000000000000\t2015-03-12T00:00:27.350Z\n" + "UHUTMTRRNGCIPFZ\t-976.561523437500\t0.446909941733\t2015-03-12T00:00:29.530Z\n" + "KJSMSSUQSRLTKVV\t192.000000000000\t984.000000000000\t2015-03-12T00:00:30.260Z\n" + "UHUTMTRRNGCIPFZ\t0.001273257891\t1.239676237106\t2015-03-12T00:00:31.270Z\n" + "UHUTMTRRNGCIPFZ\t-287.234375000000\t236.000000000000\t2015-03-12T00:00:33.720Z\n" + "FZICFOQEVPXJYQR\t1.589631736279\t128.217994689941\t2015-03-12T00:00:34.580Z\n" + "UHUTMTRRNGCIPFZ\t32.605212211609\t0.000000182797\t2015-03-12T00:00:35.120Z\n" + "UHUTMTRRNGCIPFZ\t0.000029479873\t11.629675865173\t2015-03-12T00:00:35.710Z\n" + "UHUTMTRRNGCIPFZ\t269.668342590332\t0.000553555525\t2015-03-12T00:00:35.990Z\n" + "UHUTMTRRNGCIPFZ\t0.000461809614\t64.250000000000\t2015-03-12T00:00:37.140Z\n" + "FZICFOQEVPXJYQR\t-572.296875000000\t0.000020149632\t2015-03-12T00:00:37.190Z\n" + "UHUTMTRRNGCIPFZ\t512.000000000000\t49.569551467896\t2015-03-12T00:00:40.250Z\n" + "FZICFOQEVPXJYQR\t0.000005206652\t0.272554814816\t2015-03-12T00:00:49.770Z\n" + "FZICFOQEVPXJYQR\t0.001125814480\t0.105613868684\t2015-03-12T00:01:06.100Z\n" + "UHUTMTRRNGCIPFZ\t704.000000000000\t44.546960830688\t2015-03-12T00:01:06.420Z\n" + "UHUTMTRRNGCIPFZ\t258.500000000000\t0.263136833906\t2015-03-12T00:01:07.450Z\n" + "FZICFOQEVPXJYQR\t192.000000000000\t-380.804687500000\t2015-03-12T00:01:08.610Z\n" + "FZICFOQEVPXJYQR\t56.567952156067\t0.086345635355\t2015-03-12T00:01:13.980Z\n" + "KJSMSSUQSRLTKVV\t595.603515625000\t0.000000033307\t2015-03-12T00:01:15.060Z\n" + "UHUTMTRRNGCIPFZ\t0.000097790253\t0.000000006182\t2015-03-12T00:01:17.060Z\n" + "FZICFOQEVPXJYQR\t128.000000000000\t469.091918945313\t2015-03-12T00:01:19.730Z\n" + "FZICFOQEVPXJYQR\t-592.000000000000\t0.000000797945\t2015-03-12T00:01:20.410Z\n" + "FZICFOQEVPXJYQR\t519.500000000000\t0.049629654735\t2015-03-12T00:01:22.360Z\n" + "FZICFOQEVPXJYQR\t24.736416816711\t92.901168823242\t2015-03-12T00:01:22.830Z\n" + "FZICFOQEVPXJYQR\t336.000000000000\t0.000000089523\t2015-03-12T00:01:26.920Z\n" + "KJSMSSUQSRLTKVV\t0.091930281371\t482.941406250000\t2015-03-12T00:01:30.760Z\n" + "KJSMSSUQSRLTKVV\t539.789093017578\t396.667968750000\t2015-03-12T00:01:35.470Z\n" + "FZICFOQEVPXJYQR\t0.044912695885\t64.000000000000\t2015-03-12T00:01:37.820Z\n" + "KJSMSSUQSRLTKVV\t10.140126943588\t0.000004704022\t2015-03-12T00:01:38.600Z\n";
assertThat(expected, "select id, x, y, timestamp from tab where id in ('FZICFOQEVPXJYQR', 'UHUTMTRRNGCIPFZ', 'KJSMSSUQSRLTKVV')");
}
Aggregations