Search in sources :

Example 21 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class ImportManager method importFile.

public static void importFile(Factory factory, String fileName, char delimiter, CharSequence schema, int sampleSize, boolean forceHeader) throws IOException {
    BootstrapEnv env = new BootstrapEnv();
    env.typeProbeCollection = new TypeProbeCollection();
    env.configuration = new ServerConfiguration();
    env.factory = factory;
    try (PlainTextLexer parser = new PlainTextLexer(env).of(delimiter)) {
        File file = new File(fileName);
        String location = file.getName();
        switch(factory.getConfiguration().exists(location)) {
            case JournalConfiguration.EXISTS_FOREIGN:
                throw new JournalRuntimeException("A foreign file/directory already exists: " + (new File(factory.getConfiguration().getJournalBase(), location)));
            default:
                try (PlainTextStoringParser l = new PlainTextStoringParser(env).of(location, false, false, PlainTextStoringParser.ATOMICITY_RELAXED)) {
                    analyzeAndParse(file, parser, l, schema, sampleSize, forceHeader);
                }
                break;
        }
    }
}
Also used : BootstrapEnv(com.questdb.BootstrapEnv) PlainTextStoringParser(com.questdb.parser.plaintext.PlainTextStoringParser) TypeProbeCollection(com.questdb.parser.typeprobe.TypeProbeCollection) ServerConfiguration(com.questdb.ServerConfiguration) JournalRuntimeException(com.questdb.common.JournalRuntimeException) PlainTextLexer(com.questdb.parser.plaintext.PlainTextLexer) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 22 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class JournalPartitionSource method next.

@Override
public PartitionSlice next() {
    try {
        slice.partition = journal.getPartition(partitionIndex++, open);
        slice.lo = 0;
        slice.calcHi = true;
        return slice;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 23 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException 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);
    }
}
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) FixedColumn(com.questdb.store.FixedColumn)

Example 24 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException 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);
    }
}
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) FixedColumn(com.questdb.store.FixedColumn)

Example 25 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.

the class KvIndexLongLookupRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        column = slice.partition.fixCol(columnIndex);
        KVIndex index = slice.partition.getIndexForColumn(columnIndex);
        this.indexCursor = newCursor ? index.newFwdCursor(key) : index.fwdCursor(key);
        this.lo = slice.lo - 1;
        this.hi = slice.calcHi ? slice.partition.open().size() : slice.hi + 1;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
    return this;
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException) KVIndex(com.questdb.store.KVIndex)

Aggregations

JournalRuntimeException (com.questdb.common.JournalRuntimeException)41 JournalException (com.questdb.std.ex.JournalException)30 KVIndex (com.questdb.store.KVIndex)9 IOException (java.io.IOException)6 IndexCursor (com.questdb.store.IndexCursor)5 Partition (com.questdb.store.Partition)5 ObjList (com.questdb.std.ObjList)4 FixedColumn (com.questdb.store.FixedColumn)2 File (java.io.File)2 MappedByteBuffer (java.nio.MappedByteBuffer)2 BootstrapEnv (com.questdb.BootstrapEnv)1 ServerConfiguration (com.questdb.ServerConfiguration)1 NumericException (com.questdb.common.NumericException)1 ImportColumnCountException (com.questdb.ex.ImportColumnCountException)1 ImportNameException (com.questdb.ex.ImportNameException)1 IncompatibleJournalException (com.questdb.ex.IncompatibleJournalException)1 JournalIOException (com.questdb.ex.JournalIOException)1 Quote (com.questdb.model.Quote)1 ClientConfig (com.questdb.net.ha.config.ClientConfig)1 ImportedColumnMetadata (com.questdb.parser.ImportedColumnMetadata)1