All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_record.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 #pragma once
18 
19 #include <aerospike/as_bin.h>
20 #include <aerospike/as_bytes.h>
21 #include <aerospike/as_integer.h>
22 #include <aerospike/as_key.h>
23 #include <aerospike/as_list.h>
24 #include <aerospike/as_map.h>
25 #include <aerospike/as_rec.h>
26 #include <aerospike/as_string.h>
27 #include <aerospike/as_util.h>
28 #include <aerospike/as_val.h>
29 
30 #include <stdbool.h>
31 #include <stdint.h>
32 
33 /******************************************************************************
34  * TYPES
35  *****************************************************************************/
36 
37 /**
38  * Records in Aerospike are collections of named bins.
39  *
40  * The bins in a record are analogous to columns in relational databases.
41  * However, unlike columns, the bins themselves are not typed. Instead, bins
42  * contain values which are typed. So, it is possible to have multiple records
43  * with bins of the same name but different types for values.
44  *
45  * The bin's value can only be of the types defined in `as_bin_value`.
46  *
47  * ## Initialization
48  *
49  * There are several ways to initialize an `as_record`.
50  *
51  * You can create the `as_record` on the stack:
52  *
53  * ~~~~~~~~~~{.c}
54  * as_record rec;
55  * ~~~~~~~~~~
56  *
57  * Then initialize it using either the `as_record_init()` function or
58  * `as_record_inita()` macro.
59  *
60  * The `as_record_init()` function will initialize the variable, then
61  * allocate the specified number of bins using `malloc()`. The following
62  * initializes `rec` with 2 bins.
63  *
64  * ~~~~~~~~~~{.c}
65  * as_record_init(&rec, 2);
66  * ~~~~~~~~~~
67  *
68  * The `as_record_inita()` macro will initialize the variable, then allocate
69  * the specified number of bins using `alloca()`. The following initializes
70  * `rec` with 2 bins.
71  *
72  * ~~~~~~~~~~{.c}
73  * as_record_inita(&rec, 2);
74  * ~~~~~~~~~~
75  *
76  * The `as_record_new()` function will allocate an `as_record` on the heap
77  * using `malloc()` then allocate the specified number of bins using
78  * `malloc()`. The following creates a new `as_record` with 2 bins.
79  *
80  * ~~~~~~~~~~{.c}
81  * as_record * rec = as_record_new(2);
82  * ~~~~~~~~~~
83  *
84  * ## Destruction
85  *
86  * When you no longer require an as_record, you should call `as_record_destroy()`
87  * to release the record and associated resources.
88  *
89  * ~~~~~~~~~~{.c}
90  * as_record_destroy(rec);
91  * ~~~~~~~~~~
92  *
93  * If the record has been ref-counted, then the ref-count will be decremented,
94  * until it reaches 0 (zero), at which point, the record will be released.
95  *
96  * ## Setting Bin Values
97  *
98  * The following are functions for setting values in bins of a record. Utilize
99  * the appropriate setter for the data you want to store in a bin.
100  *
101  * Function | Description
102  * ---------------------------- | ----------------------------------------------
103  * `as_record_set_int64()` | Set the bin value to a 64-bit integer.
104  * `as_record_set_str()` | Set the bin value to a NULL-terminated string.
105  * `as_record_set_integer()` | Set the bin value to an `as_integer`.
106  * `as_record_set_string()` | Set the bin value to an `as_string`.
107  * `as_record_set_bytes()` | Set the bin value to an `as_bytes`.
108  * `as_record_set_list()` | Set the bin value to an `as_list`.
109  * `as_record_set_map()` | Set the bin value to an `as_map`.
110  * `as_record_set_nil()` | Set the bin value to an `as_nil`.
111  * `as_record_set()` | Set the bin value to an `as_bin_value`.
112  *
113  * ## Getting Bin Values
114  *
115  * The following are functions for getting values from bins of a record.
116  * Utilize the appropriate getter for the data you want to read from a bin.
117  *
118  *
119  * Function | Description
120  * ---------------------------- | ----------------------------------------------
121  * `as_record_get_int64()` | Get the bin as a 64-bit integer.
122  * `as_record_get_str()` | Get the bin as a NULL-terminated string.
123  * `as_record_get_integer()` | Get the bin as an `as_integer`.
124  * `as_record_get_string()` | Get the bin as an `as_string`.
125  * `as_record_get_bytes()` | Get the bin as an `as_bytes`.
126  * `as_record_get_list()` | Get the bin as an `as_list`.
127  * `as_record_get_map()` | Get the bin as an `as_map`.
128  * `as_record_get()` | Get the bin as an `as_bin_value`.
129  *
130  * If you are unsure of the type of data stored in the bin, then you should
131  * use `as_record_get()`. You can then check the type of the value using
132  * `as_val_type()`.
133  *
134  * ~~~~~~~~~~{.c}
135  * as_val * value = as_record_get(rec, "bin1");
136  * switch ( as_val_type(value) ) {
137  * case AS_NIL: break;
138  * case AS_INTEGER: break;
139  * case AS_STRING: break;
140  * case AS_BYTES: break;
141  * case AS_LIST: break;
142  * case AS_MAP: break;
143  * case AS_REC: break;
144  * case AS_UNDEF: break;
145  * }
146  * ~~~~~~~~~~
147  *
148  * ## Traversing Bins
149  *
150  * If you want to traverse the bins of a record, then you have two options:
151  *
152  * - as_record_foreach() — Calls a function for each bin traversed.
153  * - as_record_iterator — Uses an iterator pattern to traverse bins.
154  *
155  * @extends as_rec
156  * @ingroup client_objects
157  */
158 typedef struct as_record_s {
159 
160  /**
161  * @private
162  * as_record is "derived" from as_rec.
163  * So you can actually type cast as_record to as_rec.
164  */
166 
167  /**
168  * The key of the record.
169  * This is populated when a record is read from the database.
170  * This should not be set by the user.
171  */
173 
174  /**
175  * The generation of the record.
176  */
177  uint16_t gen;
178 
179  /**
180  * The time-to-live (expiration) of the record in seconds.
181  * There are two special values that can be set in the record TTL:
182  * (*) ZERO (defined as AS_RECORD_DEFAULT_TTL), which means that the
183  * record will adopt the default TTL value from the namespace.
184  * (*) 0xFFFFFFFF (also, -1 in a signed 32 bit int)
185  * (defined as AS_RECORD_NO_EXPIRE_TTL), which means that the record
186  * will get an internal "void_time" of zero, and thus will never expire.
187  *
188  * Note that the TTL value will be employed ONLY on write/update calls.
189  */
190  uint32_t ttl;
191 
192  /**
193  * The bins of the record.
194  */
196 
197 } as_record;
198 
199 /**
200  * When the record is given a TTL value of ZERO, it will adopt the TTL value
201  * that is the default TTL value for the namespace (defined in the config file).
202  */
203 #define AS_RECORD_DEFAULT_TTL 0
204 
205 /**
206  * When the record is given a TTL value of 0xFFFFFFFF, it will set the internal
207  * void_time value (the absolute clock time value that shows when a record
208  * will expire) to zero, which means the record will never expire
209  */
210 #define AS_RECORD_NO_EXPIRE_TTL 0xFFFFFFFF
211 
212 /******************************************************************************
213  * MACROS
214  *****************************************************************************/
215 
216 /**
217  * Initialize a stack allocated `as_record` then allocate `__nbins` capacity
218  * for as_record.bins on the stack.
219  *
220  * ~~~~~~~~~~{.c}
221  * as_record record;
222  * as_record_inita(&record, 2);
223  * as_record_set_int64(&record, "bin1", 123);
224  * as_record_set_int64(&record, "bin2", 456);
225  * ~~~~~~~~~~
226  *
227  * When you are finished using the `as_record` instance, you should release the
228  * resources allocated to it by calling `as_record_destroy()`.
229  *
230  * @param __rec The `as_record *` to initialize.
231  * @param __nbins The number of `as_record.bins.entries` to allocate on the
232  * stack.
233  *
234  * @relates as_record
235  */
236 #define as_record_inita(__rec, __nbins) \
237  as_record_init(__rec, 0);\
238  (__rec)->bins._free = false;\
239  (__rec)->bins.capacity = __nbins;\
240  (__rec)->bins.size = 0;\
241  (__rec)->bins.entries = (as_bin *) alloca(sizeof(as_bin) * __nbins);
242 
243 /******************************************************************************
244  * FUNCTIONS
245  *****************************************************************************/
246 
247 /**
248  * Create a new as_record on the heap.
249  *
250  * ~~~~~~~~~~{.c}
251  * as_record * r = as_record_new(2);
252  * as_record_set_int64(r, "bin1", 123);
253  * as_record_set_str(r, "bin1", "abc");
254  * ~~~~~~~~~~
255  *
256  * When you are finished using the `as_record` instance, you should release the
257  * resources allocated to it by calling `as_record_destroy()`.
258  *
259  * @param nbins The number of bins to initialize. Set to 0, if unknown.
260  *
261  * @return a pointer to the new as_record if successful, otherwise NULL.
262  *
263  * @relates as_record
264  */
265 as_record * as_record_new(uint16_t nbins);
266 
267 /**
268  * Initializes an as_record created on the stack.
269  *
270  * ~~~~~~~~~~{.c}
271  * as_record r;
272  * as_record_init(&r, 2);
273  * as_record_set_int64(&r, "bin1", 123);
274  * as_record_set_str(&r, "bin1", "abc");
275  * ~~~~~~~~~~
276  *
277  * When you are finished using the `as_record` instance, you should release the
278  * resources allocated to it by calling `as_record_destroy()`.
279  *
280  * @param rec The record to initialize.
281  * @param nbins The number of bins to initialize. Set to 0, if unknown.
282  *
283  * @return a pointer to the initialized as_record if successful, otherwise NULL.
284  *
285  * @relates as_record
286  */
287 as_record * as_record_init(as_record * rec, uint16_t nbins);
288 
289 /**
290  * Destroy the as_record and associated resources.
291  *
292  * @param rec The record to destroy.
293  *
294  * @relates as_record
295  */
296 void as_record_destroy(as_record * rec);
297 
298 /**
299  * Get the number of bins in the record.
300  *
301  * @return the number of bins in the record.
302  *
303  * @relates as_record
304  */
305 uint16_t as_record_numbins(const as_record * rec);
306 
307 /**
308  * Set specified bin's value to an as_bin_value.
309  *
310  * @param rec The record containing the bin.
311  * @param name The name of the bin.
312  * @param value The value of the bin.
313  *
314  * @return true on success, false on failure.
315  *
316  * @relates as_record
317  */
318 bool as_record_set(as_record * rec, const as_bin_name name, as_bin_value * value);
319 
320 /**
321  * Set specified bin's value to an int64_t.
322  *
323  * ~~~~~~~~~~{.c}
324  * as_record_set_int64(rec, "bin", 123);
325  * ~~~~~~~~~~
326  *
327  * @param rec The record containing the bin.
328  * @param name The name of the bin.
329  * @param value The value of the bin.
330  *
331  * @return true on success, false on failure.
332  *
333  * @relates as_record
334  */
335 bool as_record_set_int64(as_record * rec, const as_bin_name name, int64_t value);
336 
337 /**
338  * Set specified bin's value to an NULL terminated string.
339  *
340  * ~~~~~~~~~~{.c}
341  * as_record_set_strp(rec, "bin", strdup("abc"), true);
342  * ~~~~~~~~~~
343  *
344  * @param rec The record containing the bin.
345  * @param name The name of the bin.
346  * @param value The value of the bin.
347  * @param free If true, then the value will be freed when the record is destroyed.
348  *
349  * @return true on success, false on failure.
350  *
351  * @relates as_record
352  */
353 bool as_record_set_strp(as_record * rec, const as_bin_name name, const char * value, bool free);
354 
355 /**
356  * Set specified bin's value to an NULL terminated string.
357  *
358  * ~~~~~~~~~~{.c}
359  * as_record_set_str(rec, "bin", "abc");
360  * ~~~~~~~~~~
361  *
362  * @param rec The record containing the bin.
363  * @param name The name of the bin.
364  * @param value The value of the bin. Must last for the lifetime of the record.
365  *
366  * @return true on success, false on failure.
367  *
368  * @relates as_record
369  */
370 static inline bool as_record_set_str(as_record * rec, const as_bin_name name, const char * value)
371 {
372  return as_record_set_strp(rec, name, value, false);
373 }
374 
375 /**
376  * Set specified bin's value to an NULL terminated string.
377  *
378  * ~~~~~~~~~~{.c}
379  * uint8_t * bytes = (uint8_t *) malloc(3);
380  * bytes[0] = 1;
381  * bytes[1] = 2;
382  * bytes[3] = 3;
383  *
384  * as_record_set_raw(rec, "bin", bytes, 3, true);
385  * ~~~~~~~~~~
386  *
387  * @param rec The record containing the bin.
388  * @param name The name of the bin.
389  * @param value The value of the bin.
390  * @param size The size of the value.
391  * @param free If true, then the value will be freed when the record is destroyed.
392  *
393  * @return true on success, false on failure.
394  *
395  * @relates as_record
396  */
397 bool as_record_set_rawp(as_record * rec, const as_bin_name name, const uint8_t * value, uint32_t size, bool free);
398 
399 /**
400  * Set specified bin's value to an as_bytes value of a specified type.
401  *
402  * ~~~~~~~~~~{.c}
403  * uint8_t * bytes = (uint8_t *) malloc(3);
404  * bytes[0] = 1;
405  * bytes[1] = 2;
406  * bytes[3] = 3;
407  *
408  * as_record_set_raw(rec, "bin", bytes, 3, true);
409  * ~~~~~~~~~~
410  *
411  * @param rec The record containing the bin.
412  * @param name The name of the bin.
413  * @param value The value of the bin.
414  * @param size The size of the value.
415  * @param type The as_bytes_type designation (AS_BYTES_*)
416  * @param free If true, then the value will be freed when the record is destroyed.
417  *
418  * @return true on success, false on failure.
419  *
420  * @relates as_record
421  */
422 bool as_record_set_raw_typep(as_record * rec, const as_bin_name name, const uint8_t * value, uint32_t size, as_bytes_type type, bool free);
423 
424 /**
425  * Set specified bin's value to an NULL terminated string.
426  *
427  * ~~~~~~~~~~{.c}
428  * uint8_t bytes[3] = {1,2,3};
429  * as_record_set_raw(rec, "bin", bytes, 3);
430  * ~~~~~~~~~~
431  *
432  * @param rec The record containing the bin.
433  * @param name The name of the bin.
434  * @param value The value of the bin.
435  * @param size The size of the value. Must last for the lifetime of the record.
436  *
437  * @return true on success, false on failure.
438  *
439  * @relates as_record
440  */
441 static inline bool as_record_set_raw(as_record * rec, const as_bin_name name, const uint8_t * value, uint32_t size)
442 {
443  return as_record_set_rawp(rec, name, value, size, false);
444 }
445 
446 /**
447  * Set specified bin's value to an as_integer.
448  *
449  * ~~~~~~~~~~{.c}
450  * as_record_set_integer(rec, "bin", as_integer_new(123));
451  * ~~~~~~~~~~
452  *
453  * @param rec The record containing the bin.
454  * @param name The name of the bin.
455  * @param value The value of the bin.
456  *
457  * @return true on success, false on failure.
458  *
459  * @relates as_record
460  */
461 bool as_record_set_integer(as_record * rec, const as_bin_name name, as_integer * value);
462 
463 /**
464  * Set specified bin's value to an as_string.
465  *
466  * ~~~~~~~~~~{.c}
467  * as_record_set_string(rec, "bin", as_string_new("abc", false));
468  * ~~~~~~~~~~
469  *
470  * @param rec The record containing the bin.
471  * @param name The name of the bin.
472  * @param value The value of the bin.
473  *
474  * @return true on success, false on failure.
475  *
476  * @relates as_record
477  */
478 bool as_record_set_string(as_record * rec, const as_bin_name name, as_string * value);
479 
480 /**
481  * Set specified bin's value to an as_bytes.
482  *
483  * ~~~~~~~~~~{.c}
484  * as_record_set_integer(rec, "bin", bytes);
485  * ~~~~~~~~~~
486  *
487  * @param rec The record containing the bin.
488  * @param name The name of the bin.
489  * @param value The value of the bin.
490  *
491  * @return true on success, false on failure.
492  *
493  * @relates as_record
494  */
495 bool as_record_set_bytes(as_record * rec, const as_bin_name name, as_bytes * value);
496 
497 /**
498  * Set specified bin's value to an as_list.
499  *
500  * ~~~~~~~~~~{.c}
501  * as_arraylist list;
502  * as_arraylist_init(&list);
503  * as_arraylist_add_int64(&list, 1);
504  * as_arraylist_add_int64(&list, 2);
505  * as_arraylist_add_int64(&list, 3);
506  *
507  * as_record_set_list(rec, "bin", &list);
508  * ~~~~~~~~~~
509  *
510  * @param rec The record containing the bin.
511  * @param name The name of the bin.
512  * @param value The value of the bin.
513  *
514  * @return true on success, false on failure.
515  *
516  * @relates as_record
517  */
518 bool as_record_set_list(as_record * rec, const as_bin_name name, as_list * value);
519 
520 /**
521  * Set specified bin's value to an as_map.
522  *
523  * ~~~~~~~~~~{.c}
524  * as_map map;
525  * as_stringmap_init(&map);
526  * as_stringmap_set_int64(&map, "a", 1);
527  * as_stringmap_set_int64(&map, "b", 2);
528  * as_stringmap_set_int64(&map, "c", 3);
529  *
530  * as_record_set_map(rec, "bin", &map);
531  * ~~~~~~~~~~
532  *
533  * @param rec The record containing the bin.
534  * @param name The name of the bin.
535  * @param value The value of the bin.
536  *
537  * @return true on success, false on failure.
538  *
539  * @relates as_record
540  */
541 bool as_record_set_map(as_record * rec, const as_bin_name name, as_map * value);
542 
543 /**
544  * Set specified bin's value to as_nil.
545  *
546  * ~~~~~~~~~~{.c}
547  * as_record_set_nil(rec, "bin");
548  * ~~~~~~~~~~
549  *
550  * @param rec The record containing the bin.
551  * @param name The name of the bin.
552  *
553  * @return true on success, false on failure.
554  *
555  * @relates as_record
556  */
557 bool as_record_set_nil(as_record * rec, const as_bin_name name);
558 
559 /**
560  * Get specified bin's value.
561  *
562  * ~~~~~~~~~~{.c}
563  * as_val * value = as_record_get(rec, "bin");
564  * ~~~~~~~~~~
565  *
566  * @param rec The record containing the bin.
567  * @param name The name of the bin.
568  *
569  * @return the value if it exists, otherwise NULL.
570  *
571  * @relates as_record
572  */
573 as_bin_value * as_record_get(const as_record * rec, const as_bin_name name);
574 
575 /**
576  * Get specified bin's value as an int64_t.
577  *
578  * ~~~~~~~~~~{.c}
579  * int64_t value = as_record_get_int64(rec, "bin", INT64_MAX);
580  * ~~~~~~~~~~
581  *
582  * @param rec The record containing the bin.
583  * @param name The name of the bin.
584  * @param fallback The default value to use, if the bin doesn't exist or is not an integer.
585  *
586  * @return the value if it exists, otherwise 0.
587  *
588  * @relates as_record
589  */
590 int64_t as_record_get_int64(const as_record * rec, const as_bin_name name, int64_t fallback);
591 
592 /**
593  * Get specified bin's value as an NULL terminated string.
594  *
595  * ~~~~~~~~~~{.c}
596  * char * value = as_record_get_str(rec, "bin");
597  * ~~~~~~~~~~
598  *
599  * @param rec The record containing the bin.
600  * @param name The name of the bin.
601  *
602  * @return the value if it exists, otherwise NULL.
603  *
604  * @relates as_record
605  */
606 char * as_record_get_str(const as_record * rec, const as_bin_name name);
607 
608 /**
609  * Get specified bin's value as an as_integer.
610  *
611  * ~~~~~~~~~~{.c}
612  * as_integer * value = as_record_get_integer(rec, "bin");
613  * ~~~~~~~~~~
614  *
615  * @param rec The record containing the bin.
616  * @param name The name of the bin.
617  *
618  * @return the value if it exists, otherwise NULL.
619  *
620  * @relates as_record
621  */
622 as_integer * as_record_get_integer(const as_record * rec, const as_bin_name name);
623 
624 /**
625  * Get specified bin's value as an as_string.
626  *
627  * ~~~~~~~~~~{.c}
628  * as_string * value = as_record_get_string(rec, "bin");
629  * ~~~~~~~~~~
630  *
631  * @param rec The record containing the bin.
632  * @param name The name of the bin.
633  *
634  * @return the value if it exists, otherwise NULL.
635  *
636  * @relates as_record
637  */
638 as_string * as_record_get_string(const as_record * rec, const as_bin_name name);
639 
640 /**
641  * Get specified bin's value as an as_bytes.
642  *
643  * ~~~~~~~~~~{.c}
644  * as_bytes * value = as_record_get_bytes(rec, "bin");
645  * ~~~~~~~~~~
646  *
647  * @param rec The record containing the bin.
648  * @param name The name of the bin.
649  *
650  * @return the value if it exists, otherwise NULL.
651  *
652  * @relates as_record
653  */
654 as_bytes * as_record_get_bytes(const as_record * rec, const as_bin_name name);
655 
656 /**
657  * Get specified bin's value as an as_list.
658  *
659  * ~~~~~~~~~~{.c}
660  * as_list * value = as_record_get_list(rec, "bin");
661  * ~~~~~~~~~~
662  *
663  * @param rec The record containing the bin.
664  * @param name The name of the bin.
665  *
666  * @return the value if it exists, otherwise NULL.
667  *
668  * @relates as_record
669  */
670 as_list * as_record_get_list(const as_record * rec, const as_bin_name name);
671 
672 /**
673  * Get specified bin's value as an as_map.
674  *
675  * ~~~~~~~~~~{.c}
676  * as_map * value = as_record_get_map(rec, "bin");
677  * ~~~~~~~~~~
678  *
679  * @param rec The record containing the bin.
680  * @param name The name of the bin.
681  *
682  * @return the value if it exists, otherwise NULL.
683  *
684  * @relates as_record
685  */
686 as_map * as_record_get_map(const as_record * rec, const as_bin_name name);
687 
688 /******************************************************************************
689  * ITERATION FUNCTIONS
690  ******************************************************************************/
691 
692 /**
693  * Iterate over each bin in the record and invoke the callback function.
694  *
695  * ~~~~~~~~~~{.c}
696  * bool print_bin(const char * name, const as_val * value, void * udata) {
697  * char * sval = as_val_tostring(value);
698  * printf("bin: name=%s, value=%s\n", name, sval);
699  * free(sval);
700  * return true;
701  * }
702  *
703  * as_record_foreach(rec, print_bin, NULL);
704  * ~~~~~~~~~~
705  *
706  * If the callback returns true, then iteration will continue to the next bin.
707  * Otherwise, the iteration will halt and `as_record_foreach()` will return
708  * false.
709  *
710  * @param rec The record containing the bins to iterate over.
711  * @param callback The callback to invoke for each bin.
712  * @param udata User-data provided for the callback.
713  *
714  * @return true if iteration completes fully. false if iteration was aborted.
715  *
716  * @relates as_record
717  */
718 bool as_record_foreach(const as_record * rec, as_rec_foreach_callback callback, void * udata);
719 
720 /******************************************************************************
721  * CONVERSION FUNCTIONS
722  ******************************************************************************/
723 
724 /**
725  * Convert to an as_val.
726  *
727  * @relates as_record
728  */
729 static inline as_val * as_record_toval(const as_record * rec)
730 {
731  return (as_val *) rec;
732 }
733 
734 /**
735  * Convert from an as_val.
736  *
737  * @relates as_record
738  */
739 static inline as_record * as_record_fromval(const as_val * v)
740 {
741  return (as_record *) as_util_fromval(v, AS_REC, as_rec);
742 }
743 
as_record * as_record_new(uint16_t nbins)
AS_REC
Definition: as_val.h:209
static bool as_record_set_raw(as_record *rec, const as_bin_name name, const uint8_t *value, uint32_t size)
Definition: as_record.h:441
as_bin_value * as_record_get(const as_record *rec, const as_bin_name name)
Definition: as_rec.h:71
char * as_record_get_str(const as_record *rec, const as_bin_name name)
Definition: as_map.h:57
bool as_record_set_list(as_record *rec, const as_bin_name name, as_list *value)
as_list * as_record_get_list(const as_record *rec, const as_bin_name name)
static as_record * as_record_fromval(const as_val *v)
Definition: as_record.h:739
bool(* as_rec_foreach_callback)(const char *name, const as_val *value, void *udata)
Definition: as_rec.h:59
#define as_util_fromval(object, type_id, type)
Definition: as_util.h:38
as_bins bins
Definition: as_record.h:195
bool as_record_set_bytes(as_record *rec, const as_bin_name name, as_bytes *value)
as_string * as_record_get_string(const as_record *rec, const as_bin_name name)
bool as_record_set_int64(as_record *rec, const as_bin_name name, int64_t value)
bool as_record_foreach(const as_record *rec, as_rec_foreach_callback callback, void *udata)
uint16_t gen
Definition: as_record.h:177
bool as_record_set(as_record *rec, const as_bin_name name, as_bin_value *value)
bool as_record_set_string(as_record *rec, const as_bin_name name, as_string *value)
Definition: as_val.h:51
as_map * as_record_get_map(const as_record *rec, const as_bin_name name)
static bool as_record_set_str(as_record *rec, const as_bin_name name, const char *value)
Definition: as_record.h:370
uint32_t ttl
Definition: as_record.h:190
bool as_record_set_strp(as_record *rec, const as_bin_name name, const char *value, bool free)
bool as_record_set_integer(as_record *rec, const as_bin_name name, as_integer *value)
as_record * as_record_init(as_record *rec, uint16_t nbins)
int64_t as_record_get_int64(const as_record *rec, const as_bin_name name, int64_t fallback)
uint16_t as_record_numbins(const as_record *rec)
as_rec _
Definition: as_record.h:165
void as_record_destroy(as_record *rec)
Definition: as_bin.h:95
char as_bin_name[AS_BIN_NAME_MAX_SIZE]
Definition: as_bin.h:47
as_bytes_type
Definition: as_bytes.h:34
as_integer * as_record_get_integer(const as_record *rec, const as_bin_name name)
bool as_record_set_rawp(as_record *rec, const as_bin_name name, const uint8_t *value, uint32_t size, bool free)
static as_val * as_record_toval(const as_record *rec)
Definition: as_record.h:729
Definition: as_key.h:193
as_bytes * as_record_get_bytes(const as_record *rec, const as_bin_name name)
bool as_record_set_raw_typep(as_record *rec, const as_bin_name name, const uint8_t *value, uint32_t size, as_bytes_type type, bool free)
bool as_record_set_map(as_record *rec, const as_bin_name name, as_map *value)
bool as_record_set_nil(as_record *rec, const as_bin_name name)
as_key key
Definition: as_record.h:172