Search in sources :

Example 41 with MemoryARW

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

the class MemoryCARWImplTest method testDoubleCompatibility.

@Test
public void testDoubleCompatibility() {
    long pageSize = 64;
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        mem.putInt(10);
        mem.putDouble(8980980284.22234);
        assertEquals(8980980284.22234, mem.getDouble(4), 0.00001);
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 42 with MemoryARW

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

the class MemoryCARWImplTest method testDoubleRndCompatibility.

@Test
public void testDoubleRndCompatibility() {
    long pageSize = 64;
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        // prime
        mem.putInt(10, 900);
        mem.putDouble(22, 8980980284.22234);
        mem.putDouble(84, 8979283749.72983477);
        assertEquals(8980980284.22234, mem.getDouble(22), 0.00001);
        assertEquals(8979283749.72983477, mem.getDouble(84), 0.00001);
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 43 with MemoryARW

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

the class MemoryCARWImplTest method testDouble.

@Test
public void testDouble() {
    try (MemoryARW mem = new MemoryCARWImpl(11, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        Rnd rnd = new Rnd();
        int n = 999;
        mem.putByte((byte) 1);
        for (int i = 0; i < n; i++) {
            mem.putDouble(rnd.nextDouble());
        }
        assertEquals(7993, mem.getAppendOffset());
        rnd.reset();
        long o = 1;
        assertEquals(1, mem.getByte(0));
        for (int i = 0; i < n; i++) {
            assertEquals(rnd.nextDouble(), mem.getDouble(o), 0.00001);
            o += 8;
        }
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 44 with MemoryARW

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

the class MemoryCARWImplTest method testJumpTo.

@Test
public void testJumpTo() {
    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);
        }
        assertEquals(1, mem.getByte(0));
        mem.jumpTo(1);
        for (int i = n; i > 0; i--) {
            mem.putLong(n - i);
        }
        long o = 1;
        for (int i = n; i > 0; i--) {
            assertEquals(n - i, mem.getLong(o));
            o += 8;
        }
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 45 with MemoryARW

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

the class MemoryCARWImplTest method testBool.

@Test
public void testBool() {
    Rnd rnd = new Rnd();
    try (MemoryARW mem = new MemoryCARWImpl(11, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        int n = 120;
        for (int i = 0; i < n; i++) {
            mem.putBool(rnd.nextBoolean());
        }
        long o = 0;
        rnd.reset();
        for (int i = 0; i < n; i++) {
            assertEquals(rnd.nextBoolean(), mem.getBool(o++));
        }
    }
}
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