use of com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer in project questdb by bluestreak01.
the class FixedColumnTest method testConsumerReset.
@Test
public void testConsumerReset() throws Exception {
FixedColumn col1 = new FixedColumn(file, 4);
FixedColumn col2 = new FixedColumn(file2, 4);
FixedColumnDeltaProducer producer = new FixedColumnDeltaProducer(col1);
ChannelConsumer consumer = new FixedColumnDeltaConsumer(col2);
int max = 1500000;
for (int i = 0; i < max; i++) {
col1.putInt(max - i);
col1.commit();
}
for (int i = 0; i < max - 500000; i++) {
col2.putInt(max - i);
col2.commit();
}
producer.configure(col2.size(), col1.size());
Assert.assertTrue(producer.hasContent());
producer.write(channel);
consumer.read(channel);
col2.commit();
Assert.assertEquals(col1.size(), col2.size());
for (int i = 0; i < 10000; i++) {
col1.putInt(max + 10000 - i);
col1.commit();
}
producer.configure(col2.size(), col1.size());
Assert.assertTrue(producer.hasContent());
producer.write(channel);
consumer.read(channel);
col2.commit();
Assert.assertEquals(col1.size(), col2.size());
for (int i = 0; i < max; i++) {
Assert.assertEquals(max - i, col2.getInt(i));
}
for (int i = max; i < max + 10000; i++) {
Assert.assertEquals(max + max + 10000 - i, col2.getInt(i));
}
}
use of com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer in project questdb by bluestreak01.
the class FixedColumnTest method testConsumerSmallerThanProducer.
@Test
public void testConsumerSmallerThanProducer() throws Exception {
FixedColumn col1 = new FixedColumn(file, 4);
FixedColumn col2 = new FixedColumn(file2, 4);
FixedColumnDeltaProducer producer = new FixedColumnDeltaProducer(col1);
ChannelConsumer consumer = new FixedColumnDeltaConsumer(col2);
int max = 1500000;
for (int i = 0; i < max; i++) {
col1.putInt(max - i);
col1.commit();
}
for (int i = 0; i < max - 500000; i++) {
col2.putInt(max - i);
col2.commit();
}
producer.configure(col2.size(), col1.size());
Assert.assertTrue(producer.hasContent());
producer.write(channel);
consumer.read(channel);
col2.commit();
Assert.assertEquals(col1.size(), col2.size());
for (int i = 0; i < max; i++) {
Assert.assertEquals(max - i, col2.getInt(i));
}
}
use of com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer in project questdb by bluestreak01.
the class FixedColumnTest method testEmptyConsumerAndPopulatedProducer.
@Test
public void testEmptyConsumerAndPopulatedProducer() throws Exception {
FixedColumn col1 = new FixedColumn(file, 4);
FixedColumn col2 = new FixedColumn(file2, 4);
FixedColumnDeltaProducer producer = new FixedColumnDeltaProducer(col1);
ChannelConsumer consumer = new FixedColumnDeltaConsumer(col2);
int max = 1500000;
for (int i = 0; i < max; i++) {
col1.putInt(max - i);
col1.commit();
}
producer.configure(col2.size(), col1.size());
// hasNext() can be true, because of compulsory header
// however, if column doesn't have data, hasContent() must be false.
Assert.assertTrue(producer.hasContent());
producer.write(channel);
consumer.read(channel);
col2.commit();
Assert.assertEquals(col1.size(), col2.size());
for (int i = 0; i < max; i++) {
Assert.assertEquals(max - i, col2.getInt(i));
}
}
Aggregations