Search in sources :

Example 36 with MemoryARW

use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.

the class MemoryCARWImplTest method testLongRndOdd.

@Test
public void testLongRndOdd() {
    try (MemoryARW mem = new MemoryCARWImpl(11, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        mem.putByte(0, (byte) 1);
        int n = 999;
        long o = 1;
        for (int i = n; i > 0; i--) {
            mem.putLong(o, i);
            o += 8;
        }
        o = 1;
        assertEquals(1, mem.getByte(0));
        for (int i = n; i > 0; i--) {
            assertEquals(i, mem.getLong(o));
            o += 8;
        }
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 37 with MemoryARW

use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.

the class MemoryCARWImplTest method testFloatRndCompatibility.

@Test
public void testFloatRndCompatibility() {
    long pageSize = 64;
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        // prime
        mem.putByte(10, (byte) 5);
        mem.putFloat(61, 1024f);
        mem.putFloat(99, 2048f);
        assertEquals(1024f, mem.getFloat(61), 0.00001f);
        assertEquals(2048f, mem.getFloat(99), 0.0001f);
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 38 with MemoryARW

use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.

the class MemoryCARWImplTest method testLongOdd.

@Test
public void testLongOdd() {
    try (MemoryARW mem = new MemoryCARWImpl(11, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        mem.putByte((byte) 1);
        int n = 999;
        for (int i = n; i > 0; i--) {
            mem.putLong(i);
        }
        long o = 1;
        assertEquals(1, mem.getByte(0));
        for (int i = n; i > 0; i--) {
            assertEquals(i, mem.getLong(o));
            o += 8;
        }
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 39 with MemoryARW

use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.

the class TableWriterTest method testCancelMidPartition.

@Test
public void testCancelMidPartition() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        final Rnd rnd = new Rnd();
        final int N = 10000;
        create(FF, PartitionBy.DAY, N);
        // supposed to be stored have matching partitions
        try (MemoryARW vmem = Vm.getARWInstance(FF.getPageSize(), Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
            try (TableWriter writer = new TableWriter(configuration, PRODUCT)) {
                long ts = TimestampFormatUtils.parseTimestamp("2013-03-04T00:00:00.000Z");
                int i = 0;
                int cancelCount = 0;
                while (i < N) {
                    TableWriter.Row r = writer.newRow(ts += 60000 * 1000L);
                    r.putInt(0, rnd.nextPositiveInt());
                    r.putStr(1, rnd.nextString(7));
                    r.putSym(2, rnd.nextString(4));
                    r.putSym(3, rnd.nextString(11));
                    r.putDouble(4, rnd.nextDouble());
                    if (rnd.nextPositiveInt() % 30 == 0) {
                        r.cancel();
                        cancelCount++;
                    } else {
                        r.append();
                        // second append() is expected to be a NOOP
                        r.append();
                        vmem.putLong(ts);
                        i++;
                    }
                }
                writer.commit();
                Assert.assertEquals(N, writer.size());
                Assert.assertTrue(cancelCount > 0);
                verifyTimestampPartitions(vmem);
            }
        }
    });
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 40 with MemoryARW

use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.

the class MemoryCARWImplTest method testShortRndCompatibility.

@Test
public void testShortRndCompatibility() {
    long pageSize = 64;
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        // prime the page
        mem.putShort(5, (short) 3);
        mem.putShort(11, (short) 1024);
        mem.putShort(33, (short) 2048);
        assertEquals(1024, mem.getShort(11));
        assertEquals(2048, mem.getShort(33));
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Aggregations

MemoryARW (io.questdb.cairo.vm.api.MemoryARW)52 Test (org.junit.Test)46 Path (io.questdb.std.str.Path)4 CairoException (io.questdb.cairo.CairoException)2 MemoryMARW (io.questdb.cairo.vm.api.MemoryMARW)2 TestBinarySequence (io.questdb.griffin.engine.TestBinarySequence)2 TestRecord (io.questdb.cairo.TestRecord)1 RecordMetadata (io.questdb.cairo.sql.RecordMetadata)1 MemoryCMRImpl (io.questdb.cairo.vm.MemoryCMRImpl)1 MemoryMA (io.questdb.cairo.vm.api.MemoryMA)1 MemoryMR (io.questdb.cairo.vm.api.MemoryMR)1 FilesFacade (io.questdb.std.FilesFacade)1 StringSink (io.questdb.std.str.StringSink)1