Search in sources :

Example 1 with FixedColumn

use of com.questdb.store.FixedColumn 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 FixedColumn

use of com.questdb.store.FixedColumn 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 FixedColumn

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

the class FixedColumnTest method testConsumerEqualToProducer.

@Test
public void testConsumerEqualToProducer() {
    FixedColumn col1 = new FixedColumn(file, 4);
    FixedColumn col2 = new FixedColumn(file2, 4);
    FixedColumnDeltaProducer producer = new FixedColumnDeltaProducer(col1);
    int max = 1500000;
    for (int i = 0; i < max; i++) {
        col1.putInt(max - i);
        col1.commit();
    }
    for (int i = 0; i < max; i++) {
        col2.putInt(max - i);
        col2.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.assertFalse(producer.hasContent());
    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) FixedColumn(com.questdb.store.FixedColumn)

Example 4 with FixedColumn

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

the class KvIndexIntLambdaHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        FixedColumn col = partition.fixCol(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = keys.size(); i < n; i++) {
            IndexCursor c = index.cursor(keys.get(i) & buckets);
            while (c.hasNext()) {
                long r = rec.rowid = c.next();
                if (r > lo && r < hi && col.getInt(r) == keys.get(i) && (filter == null || filter.getBool(rec))) {
                    rows.add(r);
                    break;
                }
            }
        }
        rows.sort();
        cursor = 0;
        return this;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : Partition(com.questdb.store.Partition) JournalException(com.questdb.std.ex.JournalException) IndexCursor(com.questdb.store.IndexCursor) KVIndex(com.questdb.store.KVIndex) FixedColumn(com.questdb.store.FixedColumn)

Example 5 with FixedColumn

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

the class KvIndexIntListHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        FixedColumn col = partition.fixCol(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = values.size(); i < n; i++) {
            IndexCursor c = index.cursor(values.get(i) & buckets);
            long r = -1;
            boolean found = false;
            while (c.hasNext()) {
                r = rec.rowid = c.next();
                if (r > lo && r < hi && col.getInt(r) == values.get(i) && (filter == null || filter.getBool(rec))) {
                    found = true;
                    break;
                }
            }
            if (found) {
                rows.add(r);
            }
        }
        rows.sort();
        keyIndex = 0;
        return this;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : Partition(com.questdb.store.Partition) JournalException(com.questdb.std.ex.JournalException) IndexCursor(com.questdb.store.IndexCursor) JournalRuntimeException(com.questdb.common.JournalRuntimeException) KVIndex(com.questdb.store.KVIndex) FixedColumn(com.questdb.store.FixedColumn)

Aggregations

FixedColumn (com.questdb.store.FixedColumn)9 FixedColumnDeltaProducer (com.questdb.net.ha.producer.FixedColumnDeltaProducer)6 FixedColumnDeltaConsumer (com.questdb.net.ha.comsumer.FixedColumnDeltaConsumer)3 JournalException (com.questdb.std.ex.JournalException)3 IndexCursor (com.questdb.store.IndexCursor)3 KVIndex (com.questdb.store.KVIndex)3 Partition (com.questdb.store.Partition)3 JournalRuntimeException (com.questdb.common.JournalRuntimeException)2