| 1 | /* |
| 2 | * ai_types.h |
| 3 | * |
| 4 | * Copyright (C) 2013-2015 Aerospike, Inc. |
| 5 | * |
| 6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
| 7 | * license agreements. |
| 8 | * |
| 9 | * This program is free software: you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU Affero General Public License as published by the Free |
| 11 | * Software Foundation, either version 3 of the License, or (at your option) any |
| 12 | * later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
| 17 | * details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
| 21 | */ |
| 22 | /* |
| 23 | * SYNOPSIS |
| 24 | * This file provides common declarations and definitions for |
| 25 | * the Aerospike Index module. |
| 26 | */ |
| 27 | |
| 28 | #pragma once |
| 29 | |
| 30 | #include <assert.h> |
| 31 | #include <inttypes.h> |
| 32 | #include <stdbool.h> |
| 33 | #include <stdio.h> |
| 34 | #include <sys/types.h> |
| 35 | |
| 36 | #include <citrusleaf/cf_ll.h> |
| 37 | #include <base/secondary_index.h> |
| 38 | |
| 39 | #define uchar unsigned char |
| 40 | #define ushort16 unsigned short |
| 41 | #define uint32 unsigned int |
| 42 | #define ull unsigned long long |
| 43 | #define uint128 __uint128_t |
| 44 | |
| 45 | #define AS_DIGEST_KEY_SZ 20 |
| 46 | typedef struct uint160 { |
| 47 | char digest[AS_DIGEST_KEY_SZ]; |
| 48 | } uint160; |
| 49 | |
| 50 | // Same as as_sindex_ktype |
| 51 | typedef uint8_t col_type_t; |
| 52 | #define COL_TYPE_INVALID 0 |
| 53 | #define COL_TYPE_LONG 1 |
| 54 | #define COL_TYPE_DIGEST 2 |
| 55 | #define COL_TYPE_GEOJSON 3 |
| 56 | #define COL_TYPE_MAX 4 |
| 57 | |
| 58 | #define C_IS_L(ctype) (ctype == COL_TYPE_LONG) |
| 59 | #define C_IS_DG(ctype) (ctype == COL_TYPE_DIGEST) |
| 60 | #define C_IS_G(ctype) (ctype == COL_TYPE_GEOJSON) |
| 61 | // TODO - should this have C_IS_G as well |
| 62 | #define C_IS_NUM(ctype) (C_IS_L(ctype)) |
| 63 | |
| 64 | #define VOIDINT (void *) (long) |
| 65 | |
| 66 | #define SPLICE_160(num) \ |
| 67 | ull ubh, ubm; uint32 u; \ |
| 68 | char *pbu = (char *) # \ |
| 69 | memcpy(&ubh, pbu + 12, 8); \ |
| 70 | memcpy(&ubm, pbu + 4, 8); \ |
| 71 | memcpy(&u, pbu, 4); |
| 72 | |
| 73 | #define DEBUG_U160(fp, num) \ |
| 74 | { \ |
| 75 | SPLICE_160(num); \ |
| 76 | fprintf(fp, "DEBUG_U160: high: %llu mid: %llu low: %u", ubh, ubm, u); \ |
| 77 | } |
| 78 | |
| 79 | /***************** Opaque Forward Type Declarations *****************/ |
| 80 | |
| 81 | /* |
| 82 | * B-Tree Object [Implementation defined in "btreepriv.h".] |
| 83 | */ |
| 84 | typedef struct btree bt; |
| 85 | |
| 86 | |
| 87 | /***************** Type Declarations *****************/ |
| 88 | typedef struct ai_obj { |
| 89 | ulong l; |
| 90 | uint160 y; |
| 91 | col_type_t type; |
| 92 | } ai_obj; |
| 93 | |
| 94 | typedef struct filter { |
| 95 | ai_obj alow; |
| 96 | ai_obj ahigh; |
| 97 | } f_t; |
| 98 | |
| 99 | typedef struct check_sql_where_clause { |
| 100 | f_t wf; |
| 101 | } cswc_t; |
| 102 | |