2017-09-05 01:08:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-09-08 18:24:15 +00:00
|
|
|
#include <cstdint>
|
2021-03-13 11:09:56 +00:00
|
|
|
#include <string>
|
2017-09-08 18:24:15 +00:00
|
|
|
|
2018-02-16 17:12:22 +00:00
|
|
|
#define CLICKHOUSE_DICTIONARY_LIBRARY_API 1
|
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
namespace ClickHouseLibrary
|
|
|
|
{
|
|
|
|
using CString = const char *;
|
|
|
|
using ColumnName = CString;
|
|
|
|
using ColumnNames = ColumnName[];
|
|
|
|
|
|
|
|
struct CStrings
|
|
|
|
{
|
|
|
|
CString * data = nullptr;
|
|
|
|
uint64_t size = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VectorUInt64
|
|
|
|
{
|
|
|
|
const uint64_t * data = nullptr;
|
|
|
|
uint64_t size = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ColumnsUInt64
|
|
|
|
{
|
|
|
|
VectorUInt64 * data = nullptr;
|
|
|
|
uint64_t size = 0;
|
|
|
|
};
|
2018-02-16 17:12:22 +00:00
|
|
|
|
|
|
|
struct Field
|
|
|
|
{
|
|
|
|
const void * data = nullptr;
|
|
|
|
uint64_t size = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Row
|
|
|
|
{
|
|
|
|
const Field * data = nullptr;
|
|
|
|
uint64_t size = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Table
|
|
|
|
{
|
|
|
|
const Row * data = nullptr;
|
|
|
|
uint64_t size = 0;
|
|
|
|
uint64_t error_code = 0; // 0 = ok; !0 = error, with message in error_string
|
|
|
|
const char * error_string = nullptr;
|
|
|
|
};
|
2018-06-05 19:17:16 +00:00
|
|
|
|
2018-06-06 20:21:16 +00:00
|
|
|
enum LogLevel
|
2018-06-05 19:17:16 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
FATAL = 1,
|
|
|
|
CRITICAL,
|
|
|
|
ERROR,
|
|
|
|
WARNING,
|
|
|
|
NOTICE,
|
|
|
|
INFORMATION,
|
|
|
|
DEBUG,
|
|
|
|
TRACE,
|
2018-06-05 19:17:16 +00:00
|
|
|
};
|
|
|
|
|
2018-06-06 20:21:16 +00:00
|
|
|
void log(LogLevel level, CString msg);
|
2021-03-13 11:09:56 +00:00
|
|
|
|
2021-03-14 11:29:02 +00:00
|
|
|
extern std::string_view LIBRARY_CREATE_NEW_FUNC_NAME;
|
|
|
|
extern std::string_view LIBRARY_CLONE_FUNC_NAME;
|
|
|
|
extern std::string_view LIBRARY_DELETE_FUNC_NAME;
|
2021-03-13 11:09:56 +00:00
|
|
|
|
2021-03-14 11:29:02 +00:00
|
|
|
extern std::string_view LIBRARY_DATA_NEW_FUNC_NAME;
|
|
|
|
extern std::string_view LIBRARY_DATA_DELETE_FUNC_NAME;
|
2021-03-13 11:09:56 +00:00
|
|
|
|
2021-03-14 11:29:02 +00:00
|
|
|
extern std::string_view LIBRARY_LOAD_ALL_FUNC_NAME;
|
|
|
|
extern std::string_view LIBRARY_LOAD_IDS_FUNC_NAME;
|
|
|
|
extern std::string_view LIBRARY_LOAD_KEYS_FUNC_NAME;
|
2021-03-13 11:09:56 +00:00
|
|
|
|
2021-03-14 11:29:02 +00:00
|
|
|
extern std::string_view LIBRARY_IS_MODIFIED_FUNC_NAME;
|
|
|
|
extern std::string_view LIBRARY_SUPPORTS_SELECTIVE_LOAD_FUNC_NAME;
|
2021-03-13 11:09:56 +00:00
|
|
|
|
|
|
|
using LibraryContext = void *;
|
|
|
|
|
|
|
|
using LibraryLoggerFunc = void (*)(LogLevel, CString /* message */);
|
|
|
|
|
|
|
|
using LibrarySettings = CStrings *;
|
|
|
|
|
|
|
|
using LibraryNewFunc = LibraryContext (*)(LibrarySettings, LibraryLoggerFunc);
|
|
|
|
using LibraryCloneFunc = LibraryContext (*)(LibraryContext);
|
|
|
|
using LibraryDeleteFunc = void (*)(LibraryContext);
|
|
|
|
|
|
|
|
using LibraryData = void *;
|
|
|
|
using LibraryDataNewFunc = LibraryData (*)(LibraryContext);
|
|
|
|
using LibraryDataDeleteFunc = void (*)(LibraryContext, LibraryData);
|
|
|
|
|
|
|
|
/// Can be safely casted into const Table * with static_cast<const ClickHouseLibrary::Table *>
|
|
|
|
using RawClickHouseLibraryTable = void *;
|
|
|
|
using RequestedColumnsNames = CStrings *;
|
|
|
|
|
|
|
|
using LibraryLoadAllFunc = RawClickHouseLibraryTable (*)(LibraryData, LibrarySettings, RequestedColumnsNames);
|
|
|
|
|
|
|
|
using RequestedIds = const VectorUInt64 *;
|
|
|
|
using LibraryLoadIdsFunc = RawClickHouseLibraryTable (*)(LibraryData, LibrarySettings, RequestedColumnsNames, RequestedIds);
|
|
|
|
|
|
|
|
using RequestedKeys = Table *;
|
2021-04-04 09:33:06 +00:00
|
|
|
/// There are no requested column names for load keys func
|
2021-03-13 11:09:56 +00:00
|
|
|
using LibraryLoadKeysFunc = RawClickHouseLibraryTable (*)(LibraryData, LibrarySettings, RequestedKeys);
|
|
|
|
|
|
|
|
using LibraryIsModifiedFunc = bool (*)(LibraryContext, LibrarySettings);
|
|
|
|
using LibrarySupportsSelectiveLoadFunc = bool (*)(LibraryContext, LibrarySettings);
|
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
}
|