use of com.questdb.std.ObjHashSet in project questdb by bluestreak01.
the class SingleJournalQueryTest method createTabWithSymbol.
private void createTabWithSymbol() throws JournalException, NumericException {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").index().buckets(16).$sym("sym").$double("x").$double("y").$ts())) {
Rnd rnd = new Rnd();
ObjHashSet<String> names = getNames(rnd, 1024);
ObjHashSet<String> syms = new ObjHashSet<>();
for (int i = 0; i < 64; i++) {
syms.add(rnd.nextString(10));
}
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(2, rnd.nextDouble());
ew.putDouble(3, rnd.nextDouble());
ew.putDate(4, t += 10);
ew.putSym(1, syms.get(rnd.nextInt() & 63));
ew.append();
}
w.commit();
}
}
use of com.questdb.std.ObjHashSet in project questdb by bluestreak01.
the class SingleJournalQueryTest method testSearchUnindexedStrNull.
@Test
public void testSearchUnindexedStrNull() throws Exception {
try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$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.std.ObjHashSet 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.std.ObjHashSet in project questdb by bluestreak01.
the class EngineTest method testExpiry.
@Test
public void testExpiry() throws Exception {
TestUtils.assertMemoryLeak(() -> {
createX();
final ObjHashSet<Job> jobs = new ObjHashSet<>();
class MyListener implements PoolListener {
int count = 0;
@Override
public void onEvent(byte factoryType, long thread, CharSequence name, short event, short segment, short position) {
if (event == PoolListener.EV_EXPIRE) {
count++;
}
}
}
MyListener listener = new MyListener();
try (Engine engine = new Engine(configuration)) {
engine.setPoolListener(listener);
assertWriter(engine, "x");
assertReader(engine, "x");
engine.exportJobs(jobs);
Assert.assertEquals(1, jobs.size());
Job job = jobs.get(0);
Assert.assertNotNull(job);
Assert.assertTrue(job.run());
Assert.assertFalse(job.run());
Assert.assertEquals(2, listener.count);
}
});
}
Aggregations