use of io.confluent.ksql.api.client.exception.KsqlException in project ksql by confluentinc.
the class StreamQueryResponseHandler method handleRow.
@Override
protected void handleRow(final Buffer buff) {
if (queryResult == null) {
throw new IllegalStateException("handleRow called before metadata processed");
}
final Object json = buff.toJson();
final Row row;
if (json instanceof JsonArray) {
row = new RowImpl(queryResult.columnNames(), queryResult.columnTypes(), (JsonArray) json, columnNameToIndex);
final boolean full = queryResult.accept(row);
if (full && !paused) {
recordParser.pause();
queryResult.drainHandler(this::publisherReceptive);
paused = true;
}
} else if (json instanceof JsonObject) {
final JsonObject jsonObject = (JsonObject) json;
// Don't add it to the publisher's buffer since the user should not see it
if (jsonObject.getMap() != null && jsonObject.getMap().containsKey("consistencyToken")) {
LOG.info("Response contains consistency vector " + jsonObject);
serializedConsistencyVector.set((String) ((JsonObject) json).getMap().get("consistencyToken"));
} else {
queryResult.handleError(new KsqlException(jsonObject.getString("message")));
}
} else {
throw new RuntimeException("Could not decode JSON: " + json);
}
}
Aggregations