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));
}
}
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));
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
Aggregations