Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_lmdb_function_lmdb.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * afw_lmdb_function_execute_* functions for lmdb
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw.h"
15 #include "afw_adaptor.h"
16 
17 #include "afw_lmdb_internal.h"
18 
19 /*
20  * Adaptive function: reader_check
21  *
22  * afw_lmdb_function_execute_reader_check
23  *
24  * See afw_lmdb_function_bindings.h for more information.
25  *
26  * Check for stale entries in the reader lock table.
27  *
28  * This function is not pure, so it may return a different result
29  * given exactly the same parameters.
30  *
31  * Declaration:
32  *
33  * ```
34  * function reader_check(
35  * adaptorId: string
36  * ): integer;
37  * ```
38  *
39  * Parameters:
40  *
41  * adaptorId - (string) Adaptor Id.
42  *
43  * Returns:
44  *
45  * (integer) Number of stale slots that were cleared.
46  */
47 const afw_value_t *
50 {
51  const afw_value_string_t *adaptorId;
52  const afw_adaptor_session_t *session;
53  int deadReaders;
54  int rc;
55 
57 
58  session = afw_adaptor_session_get_cached(&adaptorId->internal, false,
59  x->xctx);
60 
61  rc = afw_lmdb_internal_reader_check(session->adaptor, &deadReaders,
62  x->xctx);
63  if (rc) {
64  AFW_THROW_ERROR_Z(general, "Error in reader_check()", x->xctx);
65  }
66 
67  return afw_value_create_integer(deadReaders, x->p, x->xctx);
68 }
69 
70 
71 
72 /*
73  * Adaptive function: reader_list
74  *
75  * afw_lmdb_function_execute_reader_list
76  *
77  * See afw_lmdb_function_bindings.h for more information.
78  *
79  * Dump the entries in the reader lock table.
80  *
81  * This function is not pure, so it may return a different result
82  * given exactly the same parameters.
83  *
84  * Declaration:
85  *
86  * ```
87  * function reader_list(
88  * adaptorId: string
89  * ): string;
90  * ```
91  *
92  * Parameters:
93  *
94  * adaptorId - (string) Adaptor Id.
95  *
96  * Returns:
97  *
98  * (string) Reader entries.
99  */
100 const afw_value_t *
103 {
104  const afw_value_string_t *adaptorId;
105  const afw_adaptor_session_t *session;
106  const afw_utf8_t *list;
107  int rc;
108 
110 
111  session = afw_adaptor_session_get_cached(&adaptorId->internal, false,
112  x->xctx);
113 
114  rc = afw_lmdb_internal_reader_list(session->adaptor, &list, x->p, x->xctx);
115  if (rc < 0) {
116  AFW_THROW_ERROR_Z(general, "Error in reader_list()", x->xctx);
117  }
118 
119  return afw_value_create_string(list, x->p, x->xctx);
120 }
Adaptive Framework Core API.
Header for interface afw_adaptor* helpers.
Adaptive Framework LMDB Adaptor Internal Header.
afw_adaptor_session_get_cached(const afw_utf8_t *adaptor_id, afw_boolean_t begin_transaction, afw_xctx_t *xctx)
Get/create an active cached session for adaptor_id.
Definition: afw_adaptor.c:375
afw_value_create_integer(afw_integer_t internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type integer value.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
#define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
Definition: afw_function.h:328
const afw_value_t * afw_lmdb_function_execute_reader_list(afw_function_execute_t *x)
Adaptive Function reader_list
const afw_value_t * afw_lmdb_function_execute_reader_check(afw_function_execute_t *x)
Adaptive Function reader_check
Interface afw_adaptor_session public struct.
Function execute parameter.
Definition: afw_function.h:53
afw_xctx_t * xctx
The execution context (xctx) of caller.
Definition: afw_function.h:62
const afw_pool_t * p
Pool for result.
Definition: afw_function.h:59
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
struct for data type string values.