Search in sources :

Example 1 with FixedColumnDeltaConsumer

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));
    }
}
Also used : FixedColumnDeltaProducer(com.questdb.net.ha.producer.FixedColumnDeltaProducer) FixedColumnDeltaConsumer(com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer) FixedColumn(com.questdb.store.FixedColumn)

Example 2 with FixedColumnDeltaConsumer

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));
    }
}
Also used : FixedColumnDeltaProducer(com.questdb.net.ha.producer.FixedColumnDeltaProducer) FixedColumnDeltaConsumer(com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer) FixedColumn(com.questdb.store.FixedColumn)

Example 3 with FixedColumnDeltaConsumer

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));
    }
}
Also used : FixedColumnDeltaProducer(com.questdb.net.ha.producer.FixedColumnDeltaProducer) FixedColumnDeltaConsumer(com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer) FixedColumn(com.questdb.store.FixedColumn)

Aggregations

FixedColumnDeltaConsumer (com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer)3 FixedColumnDeltaProducer (com.questdb.net.ha.producer.FixedColumnDeltaProducer)3 FixedColumn (com.questdb.store.FixedColumn)3