ClickHouse/programs/library-bridge/SharedLibraryHandler.h

49 lines
1.2 KiB
C++
Raw Normal View History

2021-03-05 09:38:00 +00:00
#pragma once
#include <Common/SharedLibrary.h>
#include <common/logger_useful.h>
#include <DataStreams/OneBlockInputStream.h>
#include "LibraryUtils.h"
namespace DB
{
2021-03-22 14:39:17 +00:00
/// A class that manages all operations with library dictionary.
/// Every library dictionary source has its own object of this class, accessed by UUID.
2021-03-05 09:38:00 +00:00
class SharedLibraryHandler
{
public:
2021-03-24 08:41:42 +00:00
SharedLibraryHandler(const std::string & library_path_, const std::vector<std::string> & library_settings, const Block & sample_block);
2021-03-05 09:38:00 +00:00
2021-03-05 15:37:43 +00:00
SharedLibraryHandler(const SharedLibraryHandler & other);
2021-03-05 09:38:00 +00:00
2021-03-05 15:37:43 +00:00
~SharedLibraryHandler();
2021-03-05 09:38:00 +00:00
2021-03-24 08:41:42 +00:00
BlockInputStreamPtr loadAll(size_t num_attributes);
2021-03-05 09:38:00 +00:00
2021-03-24 08:41:42 +00:00
BlockInputStreamPtr loadIds(const std::vector<uint64_t> & ids, size_t num_attributes);
2021-03-05 09:38:00 +00:00
2021-03-24 08:41:42 +00:00
BlockInputStreamPtr loadKeys(const Columns & key_columns);
2021-03-07 15:23:20 +00:00
2021-03-05 10:43:47 +00:00
bool isModified();
bool supportsSelectiveLoad();
2021-03-24 08:41:42 +00:00
const Block & getSampleBlock() { return sample_block; }
2021-03-05 09:38:00 +00:00
private:
2021-03-24 08:41:42 +00:00
Block dataToBlock(const ClickHouseLibrary::RawClickHouseLibraryTable data);
2021-03-05 09:38:00 +00:00
std::string library_path;
SharedLibraryPtr library;
2021-03-24 08:41:42 +00:00
const Block sample_block;
2021-03-05 09:38:00 +00:00
std::shared_ptr<CStringsHolder> settings_holder;
void * lib_data;
};
using SharedLibraryHandlerPtr = std::shared_ptr<SharedLibraryHandler>;
}