Search in sources :

Example 1 with TypeAdapter

use of io.questdb.cutlass.text.types.TypeAdapter in project questdb by bluestreak01.

the class TextMetadataDetector method evaluateResults.

public void evaluateResults(long lineCount, long errorCount) {
    // if some fields come up as non-string after subtracting row - we have a header
    if ((calcTypes(lineCount - errorCount, true) && !calcTypes(lineCount - errorCount - 1, false)) || forceHeader) {
        // copy headers
        header = true;
    } else {
        LOG.info().$("no header [table=").$(tableName).$(", lineCount=").$(lineCount).$(", errorCount=").$(errorCount).$(", forceHeader=").$(forceHeader).$(']').$();
    }
    // make up field names if there is no header
    for (int i = 0; i < fieldCount; i++) {
        if (!header || columnNames.getQuick(i).length() == 0) {
            tempSink.clear();
            tempSink.put('f').put(i);
            columnNames.setQuick(i, tempSink.toString());
        }
    }
    // 
    if (schemaColumns.size() > 0) {
        for (int i = 0, k = columnNames.size(); i < k; i++) {
            TypeAdapter type = schemaColumns.get(columnNames.getQuick(i));
            if (type != null) {
                columnTypes.setQuick(i, type);
            }
        }
    }
}
Also used : TypeAdapter(io.questdb.cutlass.text.types.TypeAdapter)

Example 2 with TypeAdapter

use of io.questdb.cutlass.text.types.TypeAdapter in project questdb by bluestreak01.

the class TextMetadataDetector method onFields.

@Override
public void onFields(long line, ObjList<DirectByteCharSequence> values, int fieldCount) {
    // keep first line in case its a header
    if (line == 0) {
        seedFields(fieldCount);
        stashPossibleHeader(values, fieldCount);
    }
    int count = typeManager.getProbeCount();
    for (int i = 0; i < fieldCount; i++) {
        DirectByteCharSequence cs = values.getQuick(i);
        if (cs.length() == 0) {
            _blanks.increment(i);
        }
        int offset = i * count;
        for (int k = 0; k < count; k++) {
            final TypeAdapter probe = typeManager.getProbe(k);
            if (probe.probe(cs)) {
                _histogram.increment(k + offset);
            }
        }
    }
}
Also used : DirectByteCharSequence(io.questdb.std.str.DirectByteCharSequence) TypeAdapter(io.questdb.cutlass.text.types.TypeAdapter)

Aggregations

TypeAdapter (io.questdb.cutlass.text.types.TypeAdapter)2 DirectByteCharSequence (io.questdb.std.str.DirectByteCharSequence)1