ClickHouse/programs/client/Suggest.h

44 lines
981 B
C++
Raw Normal View History

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>
#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:
Suggest();
~Suggest()
{
if (loading_thread.joinable())
loading_thread.join();
}
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:
2020-01-01 19:22:57 +00:00
void loadImpl(Connection & connection, const ConnectionTimeouts & timeouts, size_t suggestion_limit);
void fetch(Connection & connection, const ConnectionTimeouts & timeouts, const std::string & query, Settings & settings);
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
};
}