1 | /* |
2 | * This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
5 | * |
6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
7 | */ |
8 | |
9 | #include <stdint.h> |
10 | |
11 | typedef void *(*malloc_function_ptr)(size_t); |
12 | typedef void (*free_function_ptr)(void*); |
13 | |
14 | typedef struct { |
15 | unsigned char day; |
16 | unsigned char month; |
17 | int year; |
18 | } cudf_data_date; |
19 | |
20 | typedef struct { |
21 | unsigned int ms; |
22 | unsigned char seconds; |
23 | unsigned char minutes; |
24 | unsigned char hours; |
25 | } cudf_data_time; |
26 | |
27 | typedef struct { |
28 | cudf_data_date date; |
29 | cudf_data_time time; |
30 | } cudf_data_timestamp; |
31 | |
32 | typedef struct { |
33 | size_t size; |
34 | void* data; |
35 | } cudf_data_blob; |
36 | |
37 | #define DEFAULT_STRUCT_DEFINITION(type, typename) \ |
38 | struct cudf_data_struct_##typename \ |
39 | { \ |
40 | type *data; \ |
41 | size_t count; \ |
42 | type null_value; \ |
43 | double scale; \ |
44 | int (*is_null)(type value); \ |
45 | void (*initialize)(void *self, size_t count); \ |
46 | void *bat; \ |
47 | } |
48 | |
49 | DEFAULT_STRUCT_DEFINITION(int8_t, bit); |
50 | DEFAULT_STRUCT_DEFINITION(int8_t, bte); |
51 | DEFAULT_STRUCT_DEFINITION(int16_t, sht); |
52 | DEFAULT_STRUCT_DEFINITION(int, int); |
53 | DEFAULT_STRUCT_DEFINITION(int64_t, lng); |
54 | DEFAULT_STRUCT_DEFINITION(float, flt); |
55 | DEFAULT_STRUCT_DEFINITION(double, dbl); |
56 | DEFAULT_STRUCT_DEFINITION(char*, str); |
57 | DEFAULT_STRUCT_DEFINITION(cudf_data_date, date); |
58 | DEFAULT_STRUCT_DEFINITION(cudf_data_time, time); |
59 | DEFAULT_STRUCT_DEFINITION(cudf_data_timestamp, timestamp); |
60 | DEFAULT_STRUCT_DEFINITION(cudf_data_blob, blob); |
61 | DEFAULT_STRUCT_DEFINITION(size_t, oid); |
62 | |