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;
}
Aggregations