summaryrefslogtreecommitdiff
path: root/storage/mroonga/vendor/groonga/lib/ts/ts_types.h
blob: 5a667e2ad17f9c0b7baa5bac0e24a23bb57ba6c9 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* -*- c-basic-offset: 2 -*- */
/*
  Copyright(C) 2015-2016 Brazil

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License version 2.1 as published by the Free Software Foundation.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#pragma once

#include "../grn.h"

#ifdef __cplusplus
extern "C" {
#endif

/*-------------------------------------------------------------
 * Built-in data types.
 */

/* grn_builtin_type or table ID. */
typedef grn_id grn_ts_data_type;

/* ID (_id). */
typedef grn_id grn_ts_id;

/* Score (_score). */
typedef float grn_ts_score;

/* Record (_id, _score). */
typedef struct {
  grn_ts_id id;
  grn_ts_score score;
} grn_ts_record;

/*-------------------------------------------------------------
 * Built-in scalar data kinds.
 */

/* Bool. */
typedef grn_bool grn_ts_bool;

/* Int. */
typedef int64_t grn_ts_int;

/* Float. */
typedef double grn_ts_float;

/* Time. */
typedef int64_t grn_ts_time;

/* Text. */
typedef struct {
  const char *ptr;
  size_t size;
} grn_ts_text;

/* Geo. */
typedef grn_geo_point grn_ts_geo;
typedef grn_geo_point grn_ts_tokyo_geo;
typedef grn_geo_point grn_ts_wgs84_geo;

/* Ref. */
typedef grn_ts_record grn_ts_ref;

/*-------------------------------------------------------------
 * Built-in vector data kinds.
 */

/* BoolVector. */
typedef struct {
  const grn_ts_bool *ptr;
  size_t size;
} grn_ts_bool_vector;

/* IntVector. */
typedef struct {
  const grn_ts_int *ptr;
  size_t size;
} grn_ts_int_vector;

/* FloatVector. */
typedef struct {
  const grn_ts_float *ptr;
  size_t size;
} grn_ts_float_vector;

/* TimeVector. */
typedef struct {
  const grn_ts_time *ptr;
  size_t size;
} grn_ts_time_vector;

/* TextVector. */
typedef struct {
  const grn_ts_text *ptr;
  size_t size;
} grn_ts_text_vector;

/* GeoVector. */
typedef struct {
  const grn_ts_geo *ptr;
  size_t size;
} grn_ts_geo_vector;
typedef grn_ts_geo_vector grn_ts_tokyo_geo_vector;
typedef grn_ts_geo_vector grn_ts_wgs84_geo_vector;

/* RefVector. */
typedef struct {
  const grn_ts_ref *ptr;
  size_t size;
} grn_ts_ref_vector;

/*-------------------------------------------------------------
 * Built-in data kinds.
 */

enum { GRN_TS_VECTOR_FLAG = 1 << 7 };

typedef enum {
  GRN_TS_VOID         = 0, /* GRN_DB_VOID */
  GRN_TS_BOOL         = 1, /* GRN_DB_BOOL */
  GRN_TS_INT          = 2, /* GRN_DB_[U]INT(8/16/32/64) */
  GRN_TS_FLOAT        = 3, /* GRN_DB_FLOAT */
  GRN_TS_TIME         = 4, /* GRN_DB_TIME */
  GRN_TS_TEXT         = 5, /* GRN_DB_[SHORT_/LONG_]TEST */
  GRN_TS_GEO          = 6, /* GRN_DB_(TOKYO/WGS84)_GEO_POINT */
  GRN_TS_REF          = 7, /* Table reference. */
  GRN_TS_BOOL_VECTOR  = GRN_TS_VECTOR_FLAG | GRN_TS_BOOL,
  GRN_TS_INT_VECTOR   = GRN_TS_VECTOR_FLAG | GRN_TS_INT,
  GRN_TS_FLOAT_VECTOR = GRN_TS_VECTOR_FLAG | GRN_TS_FLOAT,
  GRN_TS_TIME_VECTOR  = GRN_TS_VECTOR_FLAG | GRN_TS_TIME,
  GRN_TS_TEXT_VECTOR  = GRN_TS_VECTOR_FLAG | GRN_TS_TEXT,
  GRN_TS_GEO_VECTOR   = GRN_TS_VECTOR_FLAG | GRN_TS_GEO,
  GRN_TS_REF_VECTOR   = GRN_TS_VECTOR_FLAG | GRN_TS_REF
} grn_ts_data_kind;

typedef union {
  grn_ts_bool as_bool;
  grn_ts_int as_int;
  grn_ts_float as_float;
  grn_ts_time as_time;
  grn_ts_text as_text;
  grn_ts_geo as_geo;
  grn_ts_ref as_ref;
  grn_ts_bool_vector as_bool_vector;
  grn_ts_int_vector as_int_vector;
  grn_ts_float_vector as_float_vector;
  grn_ts_time_vector as_time_vector;
  grn_ts_text_vector as_text_vector;
  grn_ts_geo_vector as_geo_vector;
  grn_ts_ref_vector as_ref_vector;
} grn_ts_any;

#ifdef __cplusplus
}
#endif