use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class AbstractCairoTest method setUp.
@Before
public void setUp() {
SharedRandom.RANDOM.set(new Rnd());
LOG.info().$("Starting test ").$(getClass().getSimpleName()).$('#').$(testName.getMethodName()).$();
TestUtils.createTestPath(root);
engine.openTableId();
engine.resetTableId();
SharedRandom.RANDOM.set(new Rnd());
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class BitmapIndexFwdNullReaderTest method testCursor.
@Test
public void testCursor() {
final Rnd rnd = new Rnd();
for (int i = 0; i < 10; i++) {
int n = rnd.nextPositiveInt() % 1024;
int m = 0;
RowCursor cursor = reader.getCursor(true, 0, 0, n);
while (cursor.hasNext()) {
Assert.assertEquals(m++, cursor.next());
}
Assert.assertEquals(n + 1, m);
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class GeoHashesAppendCharBenchmark method appendChar2.
@Benchmark
public void appendChar2() throws NumericException {
Rnd rnd = new Rnd();
long geohash = 0;
for (int j = 0, m = 12; j < m; j++) {
geohash = appendChar2(geohash, rnd_geochar(rnd));
}
if (geohash != 592262567632380556L) {
throw new AssertionError();
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class GeoHashesSwitchOnIntVsCharBenchmark method isValidBits0.
@Benchmark
public static void isValidBits0() {
Rnd rnd = new Rnd();
StringSink sink = Misc.getThreadLocalBuilder();
for (int j = 0, m = 10_000_000; j < m; j++) {
if (!isValidBits0(rnd_geobits(rnd, sink), 0)) {
throw new AssertionError();
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class LineTCPSenderMainVarLenStrings method main.
public static void main(String[] args) {
final long count = 2_000_000_000L;
String hostIPv4 = "127.0.0.1";
int port = 9009;
int bufferCapacity = 64;
final Rnd rnd = new Rnd();
long start = System.nanoTime();
FilesFacade ff = new FilesFacadeImpl();
try (Path path = new Path()) {
long logFd = -1;
if (args.length == 1) {
path.put(args[0]).$();
logFd = ff.openRW(path);
}
try (LineTcpSender sender = new LoggingLineTcpSender(Net.parseIPv4(hostIPv4), port, bufferCapacity, logFd, ff)) {
for (int i = 0; i < count; i++) {
sender.metric("md_msgs");
sender.field("ts_nsec", rnd.nextPositiveLong()).field("pkt_size", rnd.nextPositiveInt()).field("pcap_file", nextString(rnd.nextPositiveInt() % 64, rnd)).field("raw_msg", nextString(rnd.nextPositiveInt() % 512, rnd)).field("Length", rnd.nextInt()).field("MsgSeqNum", i).field("MsgType", rnd.nextInt() % 1000).field("src_ip", rnd.nextString(rnd.nextPositiveInt() % 16)).field("dst_ip", rnd.nextString(rnd.nextPositiveInt() % 16)).field("src_port", rnd.nextInt() % 10000).field("dst_port", rnd.nextInt() % 10000).field("first_dir", rnd.nextBoolean()).$(i * 10_000_000L);
}
sender.flush();
} finally {
if (logFd > 0) {
ff.close(logFd);
}
}
}
System.out.println("Actual rate: " + (count * 1_000_000_000L / (System.nanoTime() - start)));
}
Aggregations