ClickHouse/dbms/programs/client/Suggest.h

48 lines
1.0 KiB
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>
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-01-19 00:23:35 +00:00
static Suggest & instance()
{
static Suggest instance;
2020-01-19 00:23:35 +00:00
return instance;
}
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:
Suggest();
~Suggest()
{
if (loading_thread.joinable())
loading_thread.join();
}
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);
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
};
}