Search in sources :

Example 6 with MemoryARW

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

the class MemoryCARWImplTest method testShortCompatibility.

@Test
public void testShortCompatibility() {
    long pageSize = 64;
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        mem.putShort((short) 1024);
        mem.putShort((short) 2048);
        assertEquals(1024, mem.getShort(0));
        assertEquals(2048, mem.getShort(2));
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 7 with MemoryARW

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

the class MemoryCARWImplTest method testByteRandom.

@Test
public void testByteRandom() {
    try (MemoryARW mem = new MemoryCARWImpl(128, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        long offset1 = 512;
        mem.putByte(offset1, (byte) 3);
        mem.putByte(offset1 + 1, (byte) 4);
        mem.jumpTo(offset1 + 2);
        mem.putByte((byte) 5);
        assertEquals(3, mem.getByte(offset1));
        assertEquals(4, mem.getByte(offset1 + 1));
        assertEquals(5, mem.getByte(offset1 + 2));
    }
}
Also used : MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 8 with MemoryARW

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

the class MemoryCARWImplTest method testLongEven.

@Test
public void testLongEven() {
    try (MemoryARW mem = new MemoryCARWImpl(11, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        int n = 999;
        for (int i = n; i > 0; i--) {
            mem.putLong(i);
        }
        long o = 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 9 with MemoryARW

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

the class MemoryCARWImplTest method testLong256Null.

@Test
public void testLong256Null() {
    long pageSize = 64;
    final int N = 1000;
    Long256Impl long256 = new Long256Impl();
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        for (int i = 0; i < N; i++) {
            mem.putLong256((CharSequence) null);
        }
        StringSink sink = new StringSink();
        long offset = 0;
        for (int i = 0; i < N; i++) {
            mem.getLong256(offset, long256);
            Assert.assertEquals(Numbers.LONG_NaN, long256.getLong0());
            Assert.assertEquals(Numbers.LONG_NaN, long256.getLong1());
            Assert.assertEquals(Numbers.LONG_NaN, long256.getLong2());
            Assert.assertEquals(Numbers.LONG_NaN, long256.getLong3());
            mem.getLong256(offset, sink);
            Assert.assertEquals(0, sink.length());
            offset += Long256.BYTES;
        }
    }
}
Also used : StringSink(io.questdb.std.str.StringSink) MemoryARW(io.questdb.cairo.vm.api.MemoryARW) Test(org.junit.Test)

Example 10 with MemoryARW

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

the class MemoryCARWImplTest method testLong256Direct.

@Test
public void testLong256Direct() {
    long pageSize = 64;
    Rnd rnd = new Rnd();
    Long256Impl sink = new Long256Impl();
    try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
        for (int i = 0; i < 1000; i++) {
            mem.putLong256(rnd.nextLong(), rnd.nextLong(), rnd.nextLong(), rnd.nextLong());
        }
        rnd.reset();
        long offset = 0;
        for (int i = 0; i < 1000; i++) {
            mem.getLong256(offset, sink);
            Assert.assertEquals(rnd.nextLong(), sink.getLong0());
            Assert.assertEquals(rnd.nextLong(), sink.getLong1());
            Assert.assertEquals(rnd.nextLong(), sink.getLong2());
            Assert.assertEquals(rnd.nextLong(), sink.getLong3());
            Long256 long256A = mem.getLong256A(offset);
            Assert.assertEquals(sink, long256A);
            Long256 long256B = mem.getLong256B(offset);
            Assert.assertEquals(sink, long256B);
            offset += Long256.BYTES;
        }
    }
}
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