Search in sources :

Example 21 with MemoryARW

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

the class MemoryCARWImplTest method testSkip.

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

Example 22 with MemoryARW

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

the class MemoryCARWImplTest method testFloatCompatibility.

@Test
public void testFloatCompatibility() {
    long pageSize = 64;
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        mem.putFloat(1024f);
        mem.putFloat(2048f);
        assertEquals(1024f, mem.getFloat(0), 0.00001f);
        assertEquals(2048f, mem.getFloat(4), 0.0001f);
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 23 with MemoryARW

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

the class MemoryCARWImplTest method testInt.

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

Example 24 with MemoryARW

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

the class MemoryCARWImplTest method testBoolRnd.

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

Example 25 with MemoryARW

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

the class MemoryCARWImplTest method testIntRnd.

@Test
public void testIntRnd() {
    try (MemoryARW mem = new MemoryCARWImpl(7, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        long o = 1;
        mem.putByte(0, (byte) 1);
        int n = 999;
        for (int i = n; i > 0; i--) {
            mem.putInt(o, i);
            o += 4;
        }
        o = 1;
        assertEquals(1, mem.getByte(0));
        for (int i = n; i > 0; i--) {
            assertEquals(i, mem.getInt(o));
            o += 4;
        }
    }
}
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