Search in sources :

Example 1 with HttpRequestHeader

use of io.questdb.cutlass.http.HttpRequestHeader in project questdb by bluestreak01.

the class JsonQueryProcessorState method of.

boolean of(RecordCursorFactory factory, SqlExecutionContextImpl sqlExecutionContext) throws PeerDisconnectedException, PeerIsSlowToReadException, SqlException {
    this.recordCursorFactory = factory;
    queryCacheable = true;
    this.cursor = factory.getCursor(sqlExecutionContext);
    final RecordMetadata metadata = factory.getMetadata();
    HttpRequestHeader header = httpConnectionContext.getRequestHeader();
    DirectByteCharSequence columnNames = header.getUrlParam("cols");
    int columnCount;
    columnSkewList.clear();
    if (columnNames != null) {
        columnsQueryParameter.clear();
        try {
            TextUtil.utf8Decode(columnNames.getLo(), columnNames.getHi(), columnsQueryParameter);
        } catch (Utf8Exception e) {
            info().$("utf8 error when decoding column list '").$(columnNames).$('\'').$();
            HttpChunkedResponseSocket socket = getHttpConnectionContext().getChunkedResponseSocket();
            JsonQueryProcessor.header(socket, "");
            socket.put('{').putQuoted("error").put(':').putQuoted("utf8 error in column list");
            socket.put('}');
            socket.sendChunk(true);
            return false;
        }
        columnCount = 1;
        int start = 0;
        int comma = 0;
        while (comma > -1) {
            comma = Chars.indexOf(columnsQueryParameter, start, ',');
            if (comma > -1) {
                if (addColumnToOutput(metadata, columnsQueryParameter, start, comma)) {
                    return false;
                }
                start = comma + 1;
                columnCount++;
            } else {
                int hi = columnsQueryParameter.length();
                if (addColumnToOutput(metadata, columnsQueryParameter, start, hi)) {
                    return false;
                }
            }
        }
    } else {
        columnCount = metadata.getColumnCount();
        for (int i = 0; i < columnCount; i++) {
            addColumnTypeAndName(metadata, i);
        }
    }
    this.columnCount = columnCount;
    return true;
}
Also used : RecordMetadata(io.questdb.cairo.sql.RecordMetadata) HttpChunkedResponseSocket(io.questdb.cutlass.http.HttpChunkedResponseSocket) DirectByteCharSequence(io.questdb.std.str.DirectByteCharSequence) HttpRequestHeader(io.questdb.cutlass.http.HttpRequestHeader) Utf8Exception(io.questdb.cutlass.text.Utf8Exception)

Aggregations

RecordMetadata (io.questdb.cairo.sql.RecordMetadata)1 HttpChunkedResponseSocket (io.questdb.cutlass.http.HttpChunkedResponseSocket)1 HttpRequestHeader (io.questdb.cutlass.http.HttpRequestHeader)1 Utf8Exception (io.questdb.cutlass.text.Utf8Exception)1 DirectByteCharSequence (io.questdb.std.str.DirectByteCharSequence)1