Search in sources :

Example 51 with Rnd

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());
}
Also used : Rnd(io.questdb.std.Rnd)

Example 52 with 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);
    }
}
Also used : Rnd(io.questdb.std.Rnd) RowCursor(io.questdb.cairo.sql.RowCursor) Test(org.junit.Test)

Example 53 with Rnd

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();
    }
}
Also used : Rnd(io.questdb.std.Rnd)

Example 54 with Rnd

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();
        }
    }
}
Also used : Rnd(io.questdb.std.Rnd) StringSink(io.questdb.std.str.StringSink)

Example 55 with Rnd

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)));
}
Also used : Path(io.questdb.std.str.Path) FilesFacade(io.questdb.std.FilesFacade) Rnd(io.questdb.std.Rnd) LineTcpSender(io.questdb.cutlass.line.LineTcpSender) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl)

Aggregations

Rnd (io.questdb.std.Rnd)76 Test (org.junit.Test)49 Record (io.questdb.cairo.sql.Record)32 RecordCursor (io.questdb.cairo.sql.RecordCursor)29 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)28 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)24 TableWriter (io.questdb.cairo.TableWriter)23 Path (io.questdb.std.str.Path)10 RuntimeIntervalModel (io.questdb.griffin.model.RuntimeIntervalModel)4 CyclicBarrier (java.util.concurrent.CyclicBarrier)3 DataFrameCursor (io.questdb.cairo.sql.DataFrameCursor)2 ReaderOutOfDateException (io.questdb.cairo.sql.ReaderOutOfDateException)2 RowCursor (io.questdb.cairo.sql.RowCursor)2 StaticSymbolTable (io.questdb.cairo.sql.StaticSymbolTable)2 LineTcpSender (io.questdb.cutlass.line.LineTcpSender)2 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)2 AbstractFunctionFactoryTest (io.questdb.griffin.engine.AbstractFunctionFactoryTest)2 BinarySequence (io.questdb.std.BinarySequence)2 BytecodeAssembler (io.questdb.std.BytecodeAssembler)2 FilesFacade (io.questdb.std.FilesFacade)2