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