use of com.questdb.store.FixedColumn in project questdb by bluestreak01.
the class KvIndexLongListHeadRowSource 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((int) (values.get(i) & buckets));
long r = -1;
boolean found = false;
while (c.hasNext()) {
r = rec.rowid = c.next();
if (r > lo && r < hi && col.getLong(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);
}
}
use of com.questdb.store.FixedColumn 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));
}
}
use of com.questdb.store.FixedColumn in project questdb by bluestreak01.
the class FixedColumnTest method testConsumerLargerThanProducer.
@Test
public void testConsumerLargerThanProducer() {
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 - 500000; 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());
Assert.assertFalse(producer.hasContent());
}
use of com.questdb.store.FixedColumn in project questdb by bluestreak01.
the class FixedColumnTest method testEmptyConsumerAndProducer.
@Test
public void testEmptyConsumerAndProducer() {
FixedColumn col1 = new FixedColumn(file, 4);
FixedColumn col2 = new FixedColumn(file2, 4);
FixedColumnDeltaProducer producer = new FixedColumnDeltaProducer(col1);
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());
}
Aggregations