JULEA
jdb-internal.h
Go to the documentation of this file.
1 /*
2  * JULEA - Flexible storage framework
3  * Copyright (C) 2019 Benjamin Warnke
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
23 #ifndef JULEA_DB_INTERNAL_H
24 #define JULEA_DB_INTERNAL_H
25 
26 #if !defined(JULEA_DB_H) && !defined(JULEA_DB_COMPILATION)
27 #error "Only <julea-db.h> can be included directly."
28 #endif
29 
30 #include <glib.h>
31 
32 #include <bson.h>
33 
34 #include <julea.h>
35 
36 #include <db-util/jbson.h>
37 
38 #include <db/jdb-entry.h>
39 #include <db/jdb-iterator.h>
40 #include <db/jdb-schema.h>
41 #include <db/jdb-selector.h>
42 
43 G_BEGIN_DECLS
44 
45 struct JDBEntry
46 {
47  bson_t bson;
48  bson_t id;
49 
51 
52  gint ref_count;
53 };
54 
56 {
57  bson_t bson;
58 
61 
62  gpointer iterator;
63 
64  gint ref_count;
65 
66  gboolean valid;
67  gboolean bson_valid;
68 };
69 
71 {
72  GHashTable* variables;
73 
75 };
76 
77 struct JDBSchema
78 {
79  bson_t bson;
80  bson_t bson_index;
81 
82  GHashTable* variables; //contains char*
83  GArray* index; //contains GHashTable * which contain char*
84 
85  gchar* namespace;
86  gchar* name;
87 
89  gint ref_count;
90 
91  gboolean bson_initialized;
93  gboolean server_side;
94 };
95 
102 {
103  bson_t selection;
104  bson_t joins;
105 
111  bson_t final;
112 
113  gboolean final_valid;
114 
117 
118  GHashTable* join_schema;
119 
121  gint ref_count;
122 };
123 
124 // Client-side wrappers for backend functions
125 gboolean j_db_internal_schema_create(JDBSchema* j_db_schema, JBatch* batch, GError** error);
126 gboolean j_db_internal_schema_get(JDBSchema* j_db_schema, JBatch* batch, GError** error);
127 gboolean j_db_internal_schema_delete(JDBSchema* j_db_schema, JBatch* batch, GError** error);
128 gboolean j_db_internal_insert(JDBEntry* j_db_entry, JBatch* batch, GError** error);
129 gboolean j_db_internal_update(JDBEntry* j_db_entry, JDBSelector* j_db_selector, JBatch* batch, GError** error);
130 gboolean j_db_internal_delete(JDBEntry* j_db_entry, JDBSelector* j_db_selector, JBatch* batch, GError** error);
131 gboolean j_db_internal_query(JDBSchema* j_db_schema, JDBSelector* j_db_selector, JDBIterator* j_db_iterator, JBatch* batch, GError** error);
132 gboolean j_db_internal_iterate(JDBIterator* j_db_iterator, GError** error);
133 
134 // Client-side additional internal functions
135 
145 bson_t* j_db_selector_get_bson(JDBSelector* selector);
146 
161 gboolean j_db_selector_finalize(JDBSelector* selector, GError** error);
162 
163 G_GNUC_INTERNAL JBackend* j_db_get_backend(void);
164 
165 G_END_DECLS
166 
167 #endif
G_GNUC_INTERNAL JBackend * j_db_get_backend(void)
Definition: jdb.c:103
gboolean j_db_internal_update(JDBEntry *j_db_entry, JDBSelector *j_db_selector, JBatch *batch, GError **error)
Definition: jdb-internal.c:327
gboolean j_db_internal_insert(JDBEntry *j_db_entry, JBatch *batch, GError **error)
Definition: jdb-internal.c:286
gboolean j_db_selector_finalize(JDBSelector *selector, GError **error)
Build the final field of the selector.
Definition: jdb-internal.c:511
gboolean j_db_internal_iterate(JDBIterator *j_db_iterator, GError **error)
Definition: jdb-internal.c:455
gboolean j_db_internal_schema_create(JDBSchema *j_db_schema, JBatch *batch, GError **error)
Definition: jdb-internal.c:167
gboolean j_db_internal_schema_delete(JDBSchema *j_db_schema, JBatch *batch, GError **error)
Definition: jdb-internal.c:247
gboolean j_db_internal_schema_get(JDBSchema *j_db_schema, JBatch *batch, GError **error)
Definition: jdb-internal.c:207
gboolean j_db_internal_query(JDBSchema *j_db_schema, JDBSelector *j_db_selector, JDBIterator *j_db_iterator, JBatch *batch, GError **error)
Definition: jdb-internal.c:412
bson_t * j_db_selector_get_bson(JDBSelector *selector)
Get the selector data represented as a single bson document.
Definition: jdb-internal.c:580
gboolean j_db_internal_delete(JDBEntry *j_db_entry, JDBSelector *j_db_selector, JBatch *batch, GError **error)
Definition: jdb-internal.c:370
JDBSelectorMode
Definition: jdb-selector.h:35
Definition: jbackend.h:132
Definition: jbatch.c:49
Definition: jdb-internal.h:46
JDBSchema * schema
Definition: jdb-internal.h:50
bson_t id
Definition: jdb-internal.h:48
gint ref_count
Definition: jdb-internal.h:52
bson_t bson
Definition: jdb-internal.h:47
Definition: jdb-internal.h:56
JDBSelector * selector
Definition: jdb-internal.h:60
gpointer iterator
Definition: jdb-internal.h:62
gboolean valid
Definition: jdb-internal.h:66
gint ref_count
Definition: jdb-internal.h:64
JDBSchema * schema
Definition: jdb-internal.h:59
gboolean bson_valid
Definition: jdb-internal.h:67
bson_t bson
Definition: jdb-internal.h:57
Definition: jdb-internal.h:71
guint variable_count
Definition: jdb-internal.h:74
GHashTable * variables
Definition: jdb-internal.h:72
Definition: jdb-internal.h:78
GHashTable * variables
Definition: jdb-internal.h:82
bson_t bson
Definition: jdb-internal.h:79
gboolean bson_index_initialized
Definition: jdb-internal.h:92
guint bson_index_count
Definition: jdb-internal.h:88
gint ref_count
Definition: jdb-internal.h:89
bson_t bson_index
Definition: jdb-internal.h:80
gchar * name
Definition: jdb-internal.h:85
gboolean bson_initialized
Definition: jdb-internal.h:91
gboolean server_side
Definition: jdb-internal.h:93
GArray * index
Definition: jdb-internal.h:83
Definition: jdb-internal.h:102
bson_t joins
The selector encoded as BSON. Joins and tables are managed separately.
Definition: jdb-internal.h:104
JDBSelectorMode mode
TRUE iff final got built and the selector was not modified.
Definition: jdb-internal.h:115
GHashTable * join_schema
Primary schema. This one must be used for joins.
Definition: jdb-internal.h:118
gboolean final_valid
Definition: jdb-internal.h:113
gint ref_count
The number of selecotr entries must not exceed 500.
Definition: jdb-internal.h:121
guint selection_count
Stores the names of joined schemas. It is used as a set and all values are NULL.
Definition: jdb-internal.h:120
bson_t selection
Definition: jdb-internal.h:103
JDBSchema * schema
Definition: jdb-internal.h:116