2018-08-25 13:55:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ConnectionParameters.h"
|
|
|
|
|
|
|
|
#include <Client/Connection.h>
|
2019-03-03 04:46:42 +00:00
|
|
|
#include <IO/ConnectionTimeouts.h>
|
2020-01-01 19:22:57 +00:00
|
|
|
#include <common/LineReader.h>
|
2020-05-20 20:16:32 +00:00
|
|
|
#include <thread>
|
2018-08-25 13:55:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-01-01 19:22:57 +00:00
|
|
|
class Suggest : public LineReader::Suggest, boost::noncopyable
|
2018-08-25 13:55:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-10-15 23:46:36 +00:00
|
|
|
Suggest();
|
|
|
|
~Suggest()
|
2019-08-22 03:24:05 +00:00
|
|
|
{
|
2020-10-15 23:46:36 +00:00
|
|
|
if (loading_thread.joinable())
|
|
|
|
loading_thread.join();
|
2019-08-22 03:24:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-01 19:22:57 +00:00
|
|
|
void load(const ConnectionParameters & connection_parameters, size_t suggestion_limit);
|
2018-08-25 16:05:01 +00:00
|
|
|
|
2020-01-01 19:22:57 +00:00
|
|
|
/// Older server versions cannot execute the query above.
|
|
|
|
static constexpr int MIN_SERVER_REVISION = 54406;
|
2018-08-25 13:55:18 +00:00
|
|
|
|
2020-01-01 19:22:57 +00:00
|
|
|
private:
|
2019-02-08 18:15:54 +00:00
|
|
|
|
2020-01-01 19:22:57 +00:00
|
|
|
void loadImpl(Connection & connection, const ConnectionTimeouts & timeouts, size_t suggestion_limit);
|
2021-04-13 12:39:13 +00:00
|
|
|
void fetch(Connection & connection, const ConnectionTimeouts & timeouts, const std::string & query);
|
2020-01-01 19:22:57 +00:00
|
|
|
void fillWordsFromBlock(const Block & block);
|
2018-08-25 13:55:18 +00:00
|
|
|
|
2020-01-01 19:22:57 +00:00
|
|
|
/// Words are fetched asynchronously.
|
|
|
|
std::thread loading_thread;
|
2018-08-25 13:55:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|