use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.
the class QueryAllImpl method createRanges.
private ObjList<JournalIteratorRange> createRanges() {
final int partitionCount = journal.getPartitionCount();
ObjList<JournalIteratorRange> ranges = new ObjList<>(partitionCount);
try {
for (int i = 0; i < partitionCount; i++) {
Partition<T> p = journal.getPartition(i, true);
long size = p.size();
if (size > 0) {
ranges.add(new JournalIteratorRange(p.getPartitionIndex(), 0, size - 1));
}
}
} catch (JournalException e) {
throw new JournalRuntimeException(e);
}
return ranges;
}
use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.
the class QueryAllImpl method incrementIterator.
@Override
public JournalPeekingIterator<T> incrementIterator() {
try {
long lo = journal.getMaxRowID();
journal.refresh();
return new JournalIteratorImpl<>(journal, createRanges(journal.incrementRowID(lo)));
} catch (JournalException e) {
throw new JournalRuntimeException(e);
}
}
use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.
the class ExportManager method export.
public static void export(RecordSource from, ReaderFactory factory, File to, char delimiter) throws JournalException, IOException {
if (to.isDirectory()) {
throw new JournalException(to + "cannot be a directory");
}
try (FileSink sink = new FileSink(to)) {
RecordSourcePrinter printer = new RecordSourcePrinter(sink, delimiter);
printer.print(from, factory, true);
}
}
use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.
the class RenameJournalTest method testJournalAlreadyOpenButIdle.
@Test
@SuppressWarnings("unchecked")
public void testJournalAlreadyOpenButIdle() throws Exception {
createX();
Factory factory = getFactory();
assertJournal(factory, "x");
sink.clear();
compiler.execute(factory, "rename table x to y");
assertJournal(factory, "y");
// make sure caching readerFactory doesn't return old journal
try {
factory.reader(new JournalKey("x"));
Assert.fail();
} catch (JournalException e) {
Assert.assertEquals("Journal does not exist", e.getMessage());
}
// make sure compile doesn't pick up old journal
try {
compiler.compile(factory, "x");
Assert.fail("still exists");
} catch (ParserException e) {
Assert.assertEquals(0, QueryError.getPosition());
TestUtils.assertEquals("Journal does not exist", QueryError.getMessage());
}
sink.clear();
createX();
assertJournal(factory, "x");
}
use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.
the class JournalTest method testSingleWriterModel.
@Test
public void testSingleWriterModel() throws Exception {
try (JournalWriter<Quote> writer = getFactory().writer(Quote.class)) {
Assert.assertTrue(writer != null);
final CountDownLatch finished = new CountDownLatch(1);
final AtomicInteger errors = new AtomicInteger();
new Thread(() -> {
try {
getFactory().writer(Quote.class);
errors.incrementAndGet();
} catch (JournalException e) {
// ignore
}
finished.countDown();
}).start();
Assert.assertTrue(finished.await(1, TimeUnit.SECONDS));
Assert.assertEquals(0, errors.get());
// check if we can open a reader
try (Journal<Quote> r = getFactory().reader(Quote.class)) {
Assert.assertTrue(r != null);
}
// check if we can open writer in alt location
try (JournalWriter w = getFactory().writer(Quote.class, "test-Quote")) {
Assert.assertTrue(w != null);
}
}
}
Aggregations