Search in sources :

Example 1 with PlainTextStoringParser

use of com.questdb.parser.plaintext.PlainTextStoringParser 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)

Aggregations

BootstrapEnv (com.questdb.BootstrapEnv)1 ServerConfiguration (com.questdb.ServerConfiguration)1 JournalRuntimeException (com.questdb.common.JournalRuntimeException)1 PlainTextLexer (com.questdb.parser.plaintext.PlainTextLexer)1 PlainTextStoringParser (com.questdb.parser.plaintext.PlainTextStoringParser)1 TypeProbeCollection (com.questdb.parser.typeprobe.TypeProbeCollection)1 File (java.io.File)1 RandomAccessFile (java.io.RandomAccessFile)1