Contiki-NG
db-options.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Swedish Institute of Computer Science
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /**
31  * \file
32  * Database configuration options.
33  * \author
34  * Nicolas Tsiftes <nvt@sics.se>
35  */
36 
37 #ifndef DB_OPTIONS_H
38 #define DB_OPTIONS_H
39 
40 #include "contiki.h"
41 #include "cfs-coffee-arch.h"
42 
43 /*----------------------------------------------------------------------------*/
44 
45 /* Optional Antelope features. Include only what is needed
46  in order to save space. */
47 
48 /* Support join operations on relations. */
49 #ifndef DB_FEATURE_JOIN
50 #define DB_FEATURE_JOIN 1
51 #endif /* DB_FEATURE_JOIN */
52 
53 /* Support tuple removals. */
54 #ifndef DB_FEATURE_REMOVE
55 #define DB_FEATURE_REMOVE 1
56 #endif /* DB_FEATURE_REMOVE */
57 
58 /* Support floating-point values in attributes. */
59 #ifndef DB_FEATURE_FLOATS
60 #define DB_FEATURE_FLOATS 0
61 #endif /* DB_FEATURE_FLOATS */
62 
63 /* Optimize storage access for the Coffee file system. */
64 #ifndef DB_FEATURE_COFFEE
65 #define DB_FEATURE_COFFEE 1
66 #endif /* DB_FEATURE_COFFEE */
67 
68 /* Enable basic data integrity checks. */
69 #ifndef DB_FEATURE_INTEGRITY
70 #define DB_FEATURE_INTEGRITY 0
71 #endif /* DB_FEATURE_INTEGRITY */
72 
73 /*----------------------------------------------------------------------------*/
74 
75 /* Configuration parameters that may be trimmed to save space. */
76 
77 /* The size of the error message buffer used by the parser. */
78 #ifndef DB_ERROR_BUF_SIZE
79 #define DB_ERROR_BUF_SIZE 50
80 #endif /* DB_ERROR_BUF_SIZE */
81 
82 /* The maximum number of indexes in use by all relations loaded in memory. */
83 #ifndef DB_INDEX_POOL_SIZE
84 #define DB_INDEX_POOL_SIZE 3
85 #endif /* DB_INDEX_POOL_SIZE */
86 
87 /* The maximum number of relations loaded in memory. */
88 #ifndef DB_RELATION_POOL_SIZE
89 #define DB_RELATION_POOL_SIZE 5
90 #endif /* DB_RELATION_POOL_SIZE */
91 
92 /* The maximum number of attributes loaded in memory. */
93 #ifndef DB_ATTRIBUTE_POOL_SIZE
94 #define DB_ATTRIBUTE_POOL_SIZE 16
95 #endif /* DB_ATTRIBUTE_POOL_SIZE */
96 
97 /* The maximum number of attributes in a relation. */
98 #ifndef DB_MAX_ATTRIBUTES_PER_RELATION
99 #define DB_MAX_ATTRIBUTES_PER_RELATION 6
100 #endif /* DB_MAX_ATTRIBUTES_PER_RELATION */
101 
102 /* The maximum physical storage size on an attribute value. */
103 #ifndef DB_MAX_ELEMENT_SIZE
104 #define DB_MAX_ELEMENT_SIZE 16
105 #endif /* DB_MAX_ELEMENT_SIZE */
106 
107 
108 /* The maximum size of the LVM bytecode compiled from a
109  single database query. */
110 #ifndef DB_VM_BYTECODE_SIZE
111 #define DB_VM_BYTECODE_SIZE 256
112 #endif /* DB_VM_BYTECODE_SIZE */
113 
114 /*----------------------------------------------------------------------------*/
115 
116 /* Language options. */
117 
118 /* The maximum length of a database query in AQL text format. */
119 #ifndef AQL_MAX_QUERY_LENGTH
120 #define AQL_MAX_QUERY_LENGTH 128
121 #endif /* AQL_MAX_QUERY_LENGTH */
122 
123 #ifndef AQL_MAX_VALUE_LENGTH
124 #define AQL_MAX_VALUE_LENGTH DB_MAX_ELEMENT_SIZE
125 #endif /* AQL_MAX_VALUE_LENGTH */
126 
127 /* The maximum number of relations used in a single query. */
128 #ifndef AQL_RELATION_LIMIT
129 #define AQL_RELATION_LIMIT 3
130 #endif /* AQL_RELATION_LIMIT */
131 
132 /* The maximum number of attributes used in a single query. */
133 #ifndef AQL_ATTRIBUTE_LIMIT
134 #define AQL_ATTRIBUTE_LIMIT 5
135 #endif /* AQL_ATTRIBUTE_LIMIT */
136 
137 /*----------------------------------------------------------------------------*/
138 
139 /*
140  * Physical storage options. Changing these options might cause
141  * compatibility problems if the database files are moved between
142  * different installations of Antelope.
143  */
144 
145 /* The default relation file size to reserve when using Coffee. */
146 #ifndef DB_COFFEE_RESERVE_SIZE
147 #define DB_COFFEE_RESERVE_SIZE (COFFEE_SIZE / 8)
148 #endif /* DB_COFFEE_RESERVE_SIZE */
149 
150 /*
151  * Ensure that the default size of Coffee file reservations is suitable
152  * for the file system size.
153  */
154 #if DB_COFFEE_RESERVE_SIZE > (COFFEE_SIZE / 2)
155 #error DB_COFFEE_RESERVE_SIZE is too large for the file system.
156 #endif
157 
158 /* The maximum size of the physical storage of a tuple (labelled a "row"
159  in Antelope's terminology. */
160 #ifndef DB_MAX_CHAR_SIZE_PER_ROW
161 #define DB_MAX_CHAR_SIZE_PER_ROW 64
162 #endif /* DB_MAX_CHAR_SIZE_PER_ROW */
163 
164 /* The maximum file name length to use for creating various database file. */
165 #ifndef DB_MAX_FILENAME_LENGTH
166 #define DB_MAX_FILENAME_LENGTH 16
167 #endif /* DB_MAX_FILENAME_LENGTH */
168 
169 /* The maximum length of an attribute name. */
170 #ifndef ATTRIBUTE_NAME_LENGTH
171 #define ATTRIBUTE_NAME_LENGTH 12
172 #endif /* ATTRIBUTE_NAME_LENGTH */
173 
174 /* The maximum length on a relation name. */
175 #ifndef RELATION_NAME_LENGTH
176 #define RELATION_NAME_LENGTH 10
177 #endif /* RELATION_NAME_LENGTH */
178 
179 /* The name of the intermediate "result" relation file, which is used
180  for presenting the result of a query to a user. */
181 #ifndef RESULT_RELATION
182 #define RESULT_RELATION "db-result"
183 #endif /* RESULT_RELATION */
184 
185 /* The name of the relation used for processing a REMOVE query. */
186 #ifndef REMOVE_RELATION
187 #define REMOVE_RELATION "db-remove"
188 #endif /* REMOVE_RELATION */
189 
190 /*----------------------------------------------------------------------------*/
191 
192 /* Index options. */
193 
194 #ifndef DB_INDEX_COST
195 #define DB_INDEX_COST 64
196 #endif /* DB_INDEX_COST */
197 
198 /* The maximum number of hash table indexes. */
199 #ifndef DB_MEMHASH_INDEX_LIMIT
200 #define DB_MEMHASH_INDEX_LIMIT 1
201 #endif /* DB_MEMHASH_INDEX_LIMIT */
202 
203 /* The default hash table index size. */
204 #ifndef DB_MEMHASH_TABLE_SIZE
205 #define DB_MEMHASH_TABLE_SIZE 61
206 #endif /* DB_MEMHASH_TABLE_SIZE */
207 
208 /* The maximum number of Maxheap indexes. */
209 #ifndef DB_HEAP_INDEX_LIMIT
210 #define DB_HEAP_INDEX_LIMIT 1
211 #endif /* DB_HEAP_INDEX_LIMIT */
212 
213 /* The maximum number of buckets cached in the MaxHeap index. */
214 #ifndef DB_HEAP_CACHE_LIMIT
215 #define DB_HEAP_CACHE_LIMIT 1
216 #endif /* DB_HEAP_CACHE_LIMIT */
217 
218 /*----------------------------------------------------------------------------*/
219 
220 /* LVM options. */
221 
222 /* The maximum length of a variable in LVM. This value should preferably
223  be identical to the maximum attribute name length. */
224 #ifndef LVM_MAX_NAME_LENGTH
225 #define LVM_MAX_NAME_LENGTH ATTRIBUTE_NAME_LENGTH
226 #endif /* LVM_MAX_NAME_LENGTH */
227 
228 /* The maximum variable identifier number in the LVM. The default
229  value corresponds to the highest attribute ID. */
230 #ifndef LVM_MAX_VARIABLE_ID
231 #define LVM_MAX_VARIABLE_ID AQL_ATTRIBUTE_LIMIT - 1
232 #endif /* LVM_MAX_VARIABLE_ID */
233 
234 /* Specify whether floats should be used or not inside the LVM. */
235 #ifndef LVM_USE_FLOATS
236 #define LVM_USE_FLOATS DB_FEATURE_FLOATS
237 #endif /* LVM_USE_FLOATS */
238 
239 
240 #endif /* !DB_OPTIONS_H */