2017-09-05 01:08:26 +00:00
|
|
|
/// Pure c sample dictionary library
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
typedef const char * CString;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const uint64_t size;
|
|
|
|
const uint64_t * data;
|
|
|
|
} ClickHouseLibVectorUInt64;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint64_t size;
|
|
|
|
CString * data;
|
|
|
|
} ClickHouseLibCStrings;
|
|
|
|
|
2018-06-06 20:21:16 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void (*log)(int, CString);
|
|
|
|
} LibHolder;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LibHolder * lib;
|
|
|
|
int someField;
|
|
|
|
} DataHolder;
|
|
|
|
|
|
|
|
#define LOG(logger, format, ...) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
char buffer[128]; \
|
|
|
|
sprintf(buffer, (format), ##__VA_ARGS__); \
|
|
|
|
(logger)(6, buffer); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
2018-06-07 17:41:14 +00:00
|
|
|
void * ClickHouseDictionary_v3_loadIds(
|
2018-02-26 16:57:14 +00:00
|
|
|
void * data_ptr, ClickHouseLibCStrings * settings, ClickHouseLibCStrings * columns, ClickHouseLibVectorUInt64 * ids)
|
2017-09-05 01:08:26 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
LibHolder * lib = ((DataHolder *)(data_ptr))->lib;
|
|
|
|
LOG(lib->log, "loadIds c lib call ptr=%p size=%" PRIu64, data_ptr, ids->size);
|
2017-09-05 01:08:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-07 17:41:14 +00:00
|
|
|
void * ClickHouseDictionary_v3_loadAll(void * data_ptr, ClickHouseLibCStrings * settings, ClickHouseLibCStrings * columns)
|
2017-09-05 01:08:26 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
LibHolder * lib = ((DataHolder *)(data_ptr))->lib;
|
|
|
|
LOG(lib->log, "loadAll c lib call ptr=%p", data_ptr);
|
2017-09-05 01:08:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-07 17:41:14 +00:00
|
|
|
void * ClickHouseDictionary_v3_loadKeys(
|
2018-02-26 16:57:14 +00:00
|
|
|
void * data_ptr, ClickHouseLibCStrings * settings, ClickHouseLibCStrings * columns, const ClickHouseLibVectorUInt64 * requested_rows)
|
2017-09-05 01:08:26 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
LibHolder * lib = ((DataHolder *)(data_ptr))->lib;
|
|
|
|
LOG(lib->log, "loadKeys c lib call ptr=%p size=%" PRIu64, data_ptr, requested_rows->size);
|
2017-09-05 01:08:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-07 17:41:14 +00:00
|
|
|
void * ClickHouseDictionary_v3_libNew(ClickHouseLibCStrings * settings, void (*logFunc)(int, CString))
|
2018-02-26 16:57:14 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
LibHolder * lib_ptr = (LibHolder *)malloc(sizeof(LibHolder));
|
|
|
|
lib_ptr->log = logFunc;
|
|
|
|
LOG(lib_ptr->log, "libNew c lib call lib_ptr=%p", lib_ptr);
|
2018-02-26 16:57:14 +00:00
|
|
|
return lib_ptr;
|
|
|
|
}
|
|
|
|
|
2018-06-07 17:41:14 +00:00
|
|
|
void ClickHouseDictionary_v3_libDelete(void * lib_ptr)
|
2018-02-26 16:57:14 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
LibHolder * lib = (LibHolder *)(lib_ptr);
|
|
|
|
LOG(lib->log, "libDelete c lib call lib_ptr=%p", lib_ptr);
|
2018-02-26 16:57:14 +00:00
|
|
|
free(lib_ptr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
|
2018-06-07 17:41:14 +00:00
|
|
|
void * ClickHouseDictionary_v3_dataNew(void * lib_ptr)
|
2017-09-05 01:08:26 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
DataHolder * data_ptr = (DataHolder *)malloc(sizeof(DataHolder));
|
|
|
|
data_ptr->lib = (LibHolder *)lib_ptr;
|
|
|
|
data_ptr->someField = 42;
|
|
|
|
LOG(data_ptr->lib->log, "dataNew c lib call lib_ptr=%p data_ptr=%p", lib_ptr, data_ptr);
|
2017-09-05 01:08:26 +00:00
|
|
|
return data_ptr;
|
|
|
|
}
|
|
|
|
|
2018-06-07 17:41:14 +00:00
|
|
|
void ClickHouseDictionary_v3_dataDelete(void * lib_ptr, void * data_ptr)
|
2017-09-05 01:08:26 +00:00
|
|
|
{
|
2018-06-06 20:21:16 +00:00
|
|
|
LibHolder * lib = (LibHolder *)(lib_ptr);
|
|
|
|
LOG(lib->log, "dataDelete c lib call lib_ptr=%p data_ptr=%p", lib_ptr, data_ptr);
|
2017-09-05 01:08:26 +00:00
|
|
|
free(data_ptr);
|
|
|
|
return;
|
|
|
|
}
|