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));
}
}
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));
}
}
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));
}
}
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);
}
}
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);
}
}
Aggregations