use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.
the class MemoryCARWImplTest method testLongRndOdd.
@Test
public void testLongRndOdd() {
try (MemoryARW mem = new MemoryCARWImpl(11, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
mem.putByte(0, (byte) 1);
int n = 999;
long o = 1;
for (int i = n; i > 0; i--) {
mem.putLong(o, i);
o += 8;
}
o = 1;
assertEquals(1, mem.getByte(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 testFloatRndCompatibility.
@Test
public void testFloatRndCompatibility() {
long pageSize = 64;
try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
// prime
mem.putByte(10, (byte) 5);
mem.putFloat(61, 1024f);
mem.putFloat(99, 2048f);
assertEquals(1024f, mem.getFloat(61), 0.00001f);
assertEquals(2048f, mem.getFloat(99), 0.0001f);
}
}
use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.
the class MemoryCARWImplTest method testLongOdd.
@Test
public void testLongOdd() {
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);
}
long o = 1;
assertEquals(1, mem.getByte(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 TableWriterTest method testCancelMidPartition.
@Test
public void testCancelMidPartition() throws Exception {
TestUtils.assertMemoryLeak(() -> {
final Rnd rnd = new Rnd();
final int N = 10000;
create(FF, PartitionBy.DAY, N);
// supposed to be stored have matching partitions
try (MemoryARW vmem = Vm.getARWInstance(FF.getPageSize(), Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
try (TableWriter writer = new TableWriter(configuration, PRODUCT)) {
long ts = TimestampFormatUtils.parseTimestamp("2013-03-04T00:00:00.000Z");
int i = 0;
int cancelCount = 0;
while (i < N) {
TableWriter.Row r = writer.newRow(ts += 60000 * 1000L);
r.putInt(0, rnd.nextPositiveInt());
r.putStr(1, rnd.nextString(7));
r.putSym(2, rnd.nextString(4));
r.putSym(3, rnd.nextString(11));
r.putDouble(4, rnd.nextDouble());
if (rnd.nextPositiveInt() % 30 == 0) {
r.cancel();
cancelCount++;
} else {
r.append();
// second append() is expected to be a NOOP
r.append();
vmem.putLong(ts);
i++;
}
}
writer.commit();
Assert.assertEquals(N, writer.size());
Assert.assertTrue(cancelCount > 0);
verifyTimestampPartitions(vmem);
}
}
});
}
use of io.questdb.cairo.vm.api.MemoryARW in project questdb by bluestreak01.
the class MemoryCARWImplTest method testShortRndCompatibility.
@Test
public void testShortRndCompatibility() {
long pageSize = 64;
try (MemoryARW mem = new MemoryCARWImpl(pageSize, Integer.MAX_VALUE, MemoryTag.NATIVE_DEFAULT)) {
// prime the page
mem.putShort(5, (short) 3);
mem.putShort(11, (short) 1024);
mem.putShort(33, (short) 2048);
assertEquals(1024, mem.getShort(11));
assertEquals(2048, mem.getShort(33));
}
}
Aggregations