Commit 359f032306383f5da1938c4236da001f63cad708
1 parent
dc22d26d
maj sdbms4
Showing
1 changed file
with
25 additions
and
12 deletions
Show diff stats
anubis_dev/library/data_base/sdbms4.anubis
... | ... | @@ -128,7 +128,7 @@ define (DBInfo -> One) create_storer(DBIndex($Key, $Row) my_idx) = |
128 | 128 | with converter = (IDXData($Key, $Row) idxdata)|-> idx_data_save(version(idxdata), to_serialize(data_tree(idxdata))), |
129 | 129 | // We also need an asynchronous writer (using default timings), configured for that index (using its name) |
130 | 130 | with writing_fun = (IDXDataSave($Key, $Row) idx, String path) |-> safe_save(idx, path), |
131 | - with asaver = make_AData(name(my_idx), writing_fun), | |
131 | + with asaver = make_AData("",name(my_idx), writing_fun,0,0), | |
132 | 132 | // When writing, we set the directory on the fly |
133 | 133 | (DBInfo dbi)|-> |
134 | 134 | set_prefix(directory(dbi), asaver); |
... | ... | @@ -258,7 +258,7 @@ define IDXData($Key, $Row) check_convert_rebuilt( |
258 | 258 | *** [3.2.2] Index initialisation |
259 | 259 | ============================================================================================================== |
260 | 260 | |
261 | -define Result(DBLoadingError, DBIndex($Key, $Row)) init_index( | |
261 | +public define Result(DBLoadingError, DBIndex($Key, $Row)) init_index( | |
262 | 262 | DBInfo the_data_base, // The database and the table on which |
263 | 263 | DBTable($Row,$HRow) the_table, // the index must be installed. |
264 | 264 | String index_name, // Name of the index |
... | ... | @@ -295,6 +295,27 @@ define Result(DBLoadingError, DBIndex($Key, $Row)) init_index( |
295 | 295 | *** [3.3] Index consultation |
296 | 296 | ================================================================================================================ |
297 | 297 | |
298 | +public define Iterator( ($Key, List(DBRowId($Row))) ) take_key_ids( DBIndex($Key, $Row) my_idx) = | |
299 | + take_left(data_tree(*data(my_idx))). | |
300 | + | |
301 | +public define Iterator( $Key ) take_key( DBIndex($Key, $Row) my_idx) = | |
302 | + take_left_key(data_tree(*data(my_idx))). | |
303 | + | |
304 | +public define Iterator( DBRowId($Row) ) take_ids( DBIndex($Key, $Row) my_idx) = | |
305 | + fold_left( take_left_value(data_tree(*data(my_idx))), nil, | |
306 | + (Iterator(DBRowId($Row)) it, List(DBRowId($Row)) l)|-> append(take_left(l), it) | |
307 | + ). | |
308 | + | |
309 | +public define Iterator( DBRow($Row) ) take_rows( DBIndex($Key, $Row) my_idx) = | |
310 | + with table_data = data_tree(*table(my_idx)), | |
311 | + filter( | |
312 | + (DBRowId($Row) id) |-> get(id, table_data), | |
313 | + fold_left( take_left_value(data_tree(*data(my_idx))), nil, | |
314 | + (Iterator(DBRowId($Row)) it, List(DBRowId($Row)) l)|-> | |
315 | + append(take_left(l), it) | |
316 | + ) | |
317 | + ). | |
318 | + | |
298 | 319 | public define Iterator(DBRowId($Row)) get_ids($Key key, DBIndex($Key, $Row) my_idx) = |
299 | 320 | if get(key, data_tree(*data(my_idx))) is |
300 | 321 | { |
... | ... | @@ -304,15 +325,7 @@ public define Iterator(DBRowId($Row)) get_ids($Key key, DBIndex($Key, $Row) my_i |
304 | 325 | |
305 | 326 | public define Iterator(DBRow($Row)) get_rows($Key key, DBIndex($Key, $Row) my_idx) = |
306 | 327 | with table_data = data_tree(*table(my_idx)), |
307 | - fold_left(get_ids(key, my_idx), nil, (Iterator(DBRow($Row)) l, DBRowId($Row) id)|-> | |
308 | - if get(id, table_data) is | |
309 | - { | |
310 | - failure then should_not_happen(l) | |
311 | - success(item) then item .. l | |
312 | - } | |
313 | - ). | |
314 | - | |
315 | - | |
328 | + filter( (DBRowId($Row) id) |-> get(id, table_data), get_ids(key, my_idx) ). | |
316 | 329 | |
317 | 330 | *** [4] Database initialisation |
318 | 331 | ================================================================================================================== |
... | ... | @@ -390,7 +403,7 @@ public define Result(DBLoadingError, DBTable($Row,$HRow)) init_dbtable( |
390 | 403 | with tdata_v = var(tdata), // ** Dynamic variable created here ** |
391 | 404 | // 4: Create the saving function (delegate writer + conversion) |
392 | 405 | with writing_fun = (DBTableDataSave($HRow) idx, String path) |-> safe_save(idx, path), |
393 | - with asaver = make_AData(table_name, writing_fun), | |
406 | + with asaver = make_AData("", table_name, writing_fun, 0, 0), | |
394 | 407 | with saver = (DBInfo dbi)|-> |
395 | 408 | set_prefix(directory(dbi), asaver); |
396 | 409 | if *tdata_v is dbtable_data(c_, v_, st_, _) then | ... | ... |