Search in sources :

Example 6 with VariableColumn

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

the class VariableColumnTest method testNulls.

@Test
public void testNulls() throws Exception {
    VariableColumn col1 = new VariableColumn(file, indexFile);
    VariableColumn col2 = new VariableColumn(file2, indexFile2);
    ChannelConsumer consumer = new VariableColumnDeltaConsumer(col2);
    VariableColumnDeltaProducer producer = new VariableColumnDeltaProducer(col1);
    col1.putNull();
    col1.commit();
    producer.configure(col2.size(), col1.size());
    Assert.assertTrue(producer.hasContent());
    producer.write(channel);
    consumer.read(channel);
    col2.commit();
    Assert.assertEquals(1, col1.size());
    Assert.assertEquals(1, col2.size());
}
Also used : VariableColumnDeltaProducer(com.questdb.net.ha.producer.VariableColumnDeltaProducer) VariableColumnDeltaConsumer(com.questdb.net.ha.comsumer.VariableColumnDeltaConsumer) VariableColumn(com.questdb.store.VariableColumn)

Example 7 with VariableColumn

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

the class VariableColumnTest method testConsumerLargerThanProducer.

@Test
public void testConsumerLargerThanProducer() {
    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 - 50000; 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());
}
Also used : VariableColumnDeltaProducer(com.questdb.net.ha.producer.VariableColumnDeltaProducer) VariableColumn(com.questdb.store.VariableColumn)

Example 8 with VariableColumn

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

the class KvIndexStrLambdaHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        VariableColumn col = partition.varCol(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = hashes.size(); i < n; i++) {
            IndexCursor c = index.cursor(hashes.getQuick(i));
            while (c.hasNext()) {
                long r = rec.rowid = c.next();
                if (r > lo && r < hi && Chars.equals(col.getFlyweightStr(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) VariableColumn(com.questdb.store.VariableColumn)

Example 9 with VariableColumn

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

the class KvIndexStrListHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        VariableColumn col = partition.varCol(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(Hash.boundedHash(values.get(i), buckets));
            while (c.hasNext()) {
                long r = rec.rowid = c.next();
                if (r > lo && r < hi && col.cmpStr(r, values.get(i)) && (filter == null || filter.getBool(rec))) {
                    rows.add(r);
                    break;
                }
            }
        }
        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) 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