mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "ConnectionParameters.h"
|
|
|
|
#include <Client/Connection.h>
|
|
#include <IO/ConnectionTimeouts.h>
|
|
#include <common/LineReader.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
}
|
|
|
|
class Suggest : public LineReader::Suggest, boost::noncopyable
|
|
{
|
|
public:
|
|
static Suggest & instance()
|
|
{
|
|
static Suggest instance;
|
|
return instance;
|
|
}
|
|
|
|
/// Need to set before load
|
|
void setCaseInsensitive() { case_insensitive = true; }
|
|
|
|
void load(const ConnectionParameters & connection_parameters, size_t suggestion_limit);
|
|
|
|
/// Older server versions cannot execute the query above.
|
|
static constexpr int MIN_SERVER_REVISION = 54406;
|
|
|
|
private:
|
|
Suggest();
|
|
~Suggest()
|
|
{
|
|
if (loading_thread.joinable())
|
|
loading_thread.join();
|
|
}
|
|
|
|
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);
|
|
|
|
/// Words are fetched asynchronously.
|
|
std::thread loading_thread;
|
|
};
|
|
|
|
}
|