-
Notifications
You must be signed in to change notification settings - Fork 5
/
schema.h
45 lines (36 loc) · 1.48 KB
/
schema.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef __KVS_SCHEMA_H__
#define __KVS_SCHEMA_H__
#include "variant.h"
#include "buffer.h"
#include "record.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct kvs_column {
const char *name;
kvs_variant_type type;
int32_t pk;
/* leave the next field for schema to initialize */
size_t index;
} kvs_column;
typedef struct kvs_schema kvs_schema;
typedef enum kvs_schema_flag {
KVS_SCHEMA_FLAG_DEFAULT = 0,
KVS_SCHEMA_FLAG_INTERPRETED = 0,
KVS_SCHEMA_FLAG_PREPARED = 1 << 0,
KVS_SCHEMA_FLAG_JIT = 1 << 1
} kvs_schema_flag;
typedef struct kvs_schema_projection kvs_schema_projection;
kvs_record *kvs_schema_record_create(const kvs_schema *schema);
kvs_schema *kvs_schema_create(const kvs_column *columns, size_t size, int32_t flags);
void kvs_schema_destroy(kvs_schema *schema);
void kvs_schema_record_serialize(const kvs_schema *schema, kvs_record *record, kvs_buffer *key, kvs_buffer *value);
void kvs_schema_record_deserialize(const kvs_schema *schema, kvs_buffer *key, kvs_buffer *value, kvs_record *dest);
kvs_variant **kvs_schema_record_get(const kvs_schema *schema, kvs_record *record, const char *column);
kvs_schema_projection *kvs_schema_projection_create(const kvs_schema *schema, const char **columns, size_t num_column);
void kvs_schema_projection_destroy(kvs_schema_projection *projection);
kvs_variant **kvs_schema_projection_record_get(const kvs_schema_projection *projection, kvs_record *record, size_t index);
#ifdef __cplusplus
}
#endif
#endif /* __KVS_SCHEMA_H__ */