use of com.questdb.std.Rnd in project questdb by bluestreak01.
the class HugeTableTest method testLargeSymbolTable.
@Test
public void testLargeSymbolTable() throws Exception {
try (JournalWriter<Name> w = getFactory().writer(Name.class, "name")) {
Name name = new Name();
Rnd rnd = new Rnd();
long t = 0;
for (int i = -500000; i < 2000000; i++) {
if (i == 0) {
t = System.nanoTime();
}
name.name = rnd.nextString(10);
w.append(name);
}
w.commit();
LOG.info().$("Appended 2M symbols in ").$(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - t)).$("ms").$();
}
}
use of com.questdb.std.Rnd in project questdb by bluestreak01.
the class JournalTest method testTxTumbleDrier.
@Test
public void testTxTumbleDrier() throws Exception {
int SIZE = 1000000;
try (JournalWriter<Quote> origin = getFactory().writer(Quote.class, "origin", SIZE / 12)) {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class, "q", SIZE / 12)) {
TestUtils.generateQuoteData(origin, SIZE, DateFormatUtils.parseDateTime("2014-01-30T00:11:00.000Z"), 100000);
origin.commit();
ResultSet<Quote> originRs = origin.query().all().asResultSet();
int blockSize = 5130;
Rnd rnd = new Rnd(System.currentTimeMillis(), System.nanoTime());
try {
for (int i = 0; i < originRs.size(); ) {
int d = Math.min(i + blockSize, originRs.size());
ResultSet<Quote> rs = originRs.subset(i, d);
w.append(rs);
if (rnd.nextBoolean()) {
w.commit();
i += blockSize;
} else {
w.rollback();
}
}
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertFalse(w.isTxActive());
TestUtils.assertDataEquals(origin, w);
}
}
}
use of com.questdb.std.Rnd in project questdb by bluestreak01.
the class JournalTest method testAppendBreak.
@Test
public void testAppendBreak() throws Exception {
Rnd random = new Rnd(System.nanoTime(), System.currentTimeMillis());
try (JournalWriter<TestEntity> w = getFactory().writer(TestEntity.class)) {
try {
w.append(new TestEntity().setSym("ABC").setDStr("test1"));
w.append(new TestEntity().setSym("ABC").setDStr(random.nextString(100)));
w.append(new TestEntity().setSym("ABC").setDStr(random.nextString(70000)).setTimestamp(-1));
} catch (Exception e) {
// OK
} finally {
w.commit();
}
w.append(new TestEntity().setSym("ABC").setDStr(random.nextString(300)));
Assert.assertEquals(3, w.query().all().withKeys("ABC").asResultSet().size());
Assert.assertEquals(1, w.query().head().withKeys("ABC").asResultSet().size());
}
}
use of com.questdb.std.Rnd in project questdb by bluestreak01.
the class UnstructuredFileTest method testIntArrays.
@Test
public void testIntArrays() throws Exception {
Rnd rnd = new Rnd();
UnstructuredFile hb = new UnstructuredFile(temp.newFile(), 16, JournalMode.APPEND);
int[] vals = new int[100];
long pos = hb.getPos();
for (int i = 0; i < 10000; i++) {
for (int k = 0; k < vals.length; k++) {
vals[k] = rnd.nextInt();
}
hb.put(vals);
}
rnd.reset();
hb.setPos(pos);
for (int i = 0; i < 10000; i++) {
hb.get(vals);
for (int k = 0; k < vals.length; k++) {
Assert.assertEquals(rnd.nextInt(), vals[k]);
}
}
}
use of com.questdb.std.Rnd in project questdb by bluestreak01.
the class UnstructuredFileTest method testLongArrays.
@Test
public void testLongArrays() throws Exception {
Rnd rnd = new Rnd();
UnstructuredFile hb = new UnstructuredFile(temp.newFile(), 16, JournalMode.APPEND);
long[] vals = new long[100];
long pos = hb.getPos();
for (int i = 0; i < 10000; i++) {
for (int k = 0; k < vals.length; k++) {
vals[k] = rnd.nextLong();
}
hb.put(vals);
}
rnd.reset();
hb.setPos(pos);
for (int i = 0; i < 10000; i++) {
hb.get(vals);
for (int k = 0; k < vals.length; k++) {
Assert.assertEquals(rnd.nextLong(), vals[k]);
}
}
}
Aggregations