Search in sources :

Example 1 with VariableColumn

use of com.questdb.store.VariableColumn in project questdb by bluestreak01.

the class VariableColumnTest method testEmptyConsumerAndPopulatedProducer.

@Test
public void testEmptyConsumerAndPopulatedProducer() throws Exception {
    VariableColumn col1 = new VariableColumn(file, indexFile);
    VariableColumn col2 = new VariableColumn(file2, indexFile2);
    ChannelConsumer consumer = new VariableColumnDeltaConsumer(col2);
    VariableColumnDeltaProducer producer = new VariableColumnDeltaProducer(col1);
    int max = 150000;
    for (int i = 0; i < max; i++) {
        col1.putStr("test123" + (max - 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("test123" + (max - i), col2.getStr(i));
    }
}
Also used : VariableColumnDeltaProducer(com.questdb.net.ha.producer.VariableColumnDeltaProducer) VariableColumnDeltaConsumer(com.questdb.net.ha.comsumer.VariableColumnDeltaConsumer) VariableColumn(com.questdb.store.VariableColumn)

Example 2 with VariableColumn

use of com.questdb.store.VariableColumn in project questdb by bluestreak01.

the class VariableColumnTest method testConsumerReset.

@Test
public void testConsumerReset() throws Exception {
    VariableColumn col1 = new VariableColumn(file, indexFile);
    VariableColumn col2 = new VariableColumn(file2, indexFile2);
    ChannelConsumer consumer = new VariableColumnDeltaConsumer(col2);
    VariableColumnDeltaProducer producer = new VariableColumnDeltaProducer(col1);
    int max = 150000;
    for (int i = 0; i < max; i++) {
        col1.putStr("test123" + (max - i));
        col1.commit();
    }
    for (int i = 0; i < max - 50000; i++) {
        col2.putStr("test123" + (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 < 1000; i++) {
        col1.putStr("test123" + (max + 1000 - 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("test123" + (max - i), col2.getStr(i));
    }
    for (int i = 0; i < 1000; i++) {
        Assert.assertEquals("test123" + (max + 1000 - i), col2.getStr(i + max));
    }
}
Also used : VariableColumnDeltaProducer(com.questdb.net.ha.producer.VariableColumnDeltaProducer) VariableColumnDeltaConsumer(com.questdb.net.ha.comsumer.VariableColumnDeltaConsumer) VariableColumn(com.questdb.store.VariableColumn)

Example 3 with VariableColumn

use of com.questdb.store.VariableColumn in project questdb by bluestreak01.

the class VariableColumnTest method testConsumerSmallerThanProducer.

@Test
public void testConsumerSmallerThanProducer() throws Exception {
    VariableColumn col1 = new VariableColumn(file, indexFile);
    VariableColumn col2 = new VariableColumn(file2, indexFile2);
    ChannelConsumer consumer = new VariableColumnDeltaConsumer(col2);
    VariableColumnDeltaProducer producer = new VariableColumnDeltaProducer(col1);
    int max = 150000;
    for (int i = 0; i < max; i++) {
        col1.putStr("test123" + (max - i));
        col1.commit();
    }
    for (int i = 0; i < max - 50000; i++) {
        col2.putStr("test123" + (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("test123" + (max - i), col2.getStr(i));
    }
}
Also used : VariableColumnDeltaProducer(com.questdb.net.ha.producer.VariableColumnDeltaProducer) VariableColumnDeltaConsumer(com.questdb.net.ha.comsumer.VariableColumnDeltaConsumer) VariableColumn(com.questdb.store.VariableColumn)

Example 4 with VariableColumn

use of com.questdb.store.VariableColumn in project questdb by bluestreak01.

the class VariableColumnTest method testEmptyConsumerAndProducer.

@Test
public void testEmptyConsumerAndProducer() {
    VariableColumn col1 = new VariableColumn(file, indexFile);
    VariableColumn col2 = new VariableColumn(file2, indexFile2);
    VariableColumnDeltaProducer producer = new VariableColumnDeltaProducer(col1);
    producer.configure(col2.size(), col1.size());
    Assert.assertFalse(producer.hasContent());
    Assert.assertEquals(col1.size(), col2.size());
}
Also used : VariableColumnDeltaProducer(com.questdb.net.ha.producer.VariableColumnDeltaProducer) VariableColumn(com.questdb.store.VariableColumn)

Example 5 with VariableColumn

use of com.questdb.store.VariableColumn in project questdb by bluestreak01.

the class VariableColumnTest method testConsumerEqualToProducer.

@Test
public void testConsumerEqualToProducer() {
    VariableColumn col1 = new VariableColumn(file, indexFile);
    VariableColumn col2 = new VariableColumn(file2, indexFile2);
    VariableColumnDeltaProducer producer = new VariableColumnDeltaProducer(col1);
    int max = 150000;
    for (int i = 0; i < max; i++) {
        col1.putStr("test123" + (max - i));
        col1.commit();
    }
    for (int i = 0; i < max; i++) {
        col2.putStr("test123" + (max - i));
        col2.commit();
    }
    producer.configure(col2.size(), col1.size());
    Assert.assertFalse(producer.hasContent());
    Assert.assertEquals(col1.size(), col2.size());
    for (int i = 0; i < max; i++) {
        Assert.assertEquals("test123" + (max - i), col2.getStr(i));
    }
}
Also used : VariableColumnDeltaProducer(com.questdb.net.ha.producer.VariableColumnDeltaProducer) VariableColumn(com.questdb.store.VariableColumn)

Aggregations

VariableColumn (com.questdb.store.VariableColumn)9 VariableColumnDeltaProducer (com.questdb.net.ha.producer.VariableColumnDeltaProducer)7 VariableColumnDeltaConsumer (com.questdb.net.ha.comsumer.VariableColumnDeltaConsumer)4 JournalException (com.questdb.std.ex.JournalException)2 IndexCursor (com.questdb.store.IndexCursor)2 KVIndex (com.questdb.store.KVIndex)2 Partition (com.questdb.store.Partition)2 JournalRuntimeException (com.questdb.common.JournalRuntimeException)1