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