use of com.questdb.std.ObjList in project questdb by bluestreak01.
the class IteratorTest method testMerge.
@Test
public void testMerge() throws Exception {
populateQuotes();
ObjList<Journal<Quote>> journals = new ObjList<Journal<Quote>>() {
{
add(getFactory().reader(Quote.class, "quote-0"));
add(getFactory().reader(Quote.class, "quote-1"));
add(getFactory().reader(Quote.class, "quote-2"));
add(getFactory().reader(Quote.class, "quote-3"));
add(getFactory().reader(Quote.class, "quote-4"));
}
};
try {
List<JournalIterator<Quote>> list = new ArrayList<>();
for (int i = 0; i < journals.size(); i++) {
list.add(JournalIterators.bufferedIterator(journals.get(i)));
}
long ts = 0;
for (Quote q : MergingIterator.merge(list, comparator)) {
Assert.assertTrue(ts <= q.getTimestamp());
ts = q.getTimestamp();
}
} finally {
for (int i = 0, n = journals.size(); i < n; i++) {
journals.getQuick(i).close();
}
}
}
use of com.questdb.std.ObjList in project questdb by bluestreak01.
the class JournalIterators method createRanges.
private static <T> ObjList<JournalIteratorRange> createRanges(Journal<T> journal, long lo) {
ObjList<JournalIteratorRange> ranges = new ObjList<>();
int loPartitionID = Rows.toPartitionIndex(lo);
long loLocalRowID = Rows.toLocalRowID(lo);
try {
int count = journal.getPartitionCount();
for (int i = loPartitionID; i < count; i++) {
long localRowID = 0;
if (i == loPartitionID) {
localRowID = loLocalRowID;
}
Partition<T> p = journal.getPartition(i, true);
long size = p.size();
if (size > 0) {
ranges.add(new JournalIteratorRange(p.getPartitionIndex(), localRowID, size - 1));
}
}
return ranges;
} catch (JournalException e) {
throw new JournalRuntimeException(e);
}
}
Aggregations