Format | db_open_env(+Home, +Info, -Handle) db_config(+Info) | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Arguments |
| ||||||||||||
Note | Info is supposed to be a following feature structure; (ldbm:info_env& ldbm:mode\ +Mode& (optional) ldbm:bdbm_page_size\ +Pagesize& (optional) ldbm:bdbm_cache_size\ +Cachesize& (optional) ldbm:flags\ +Flags)
| ||||||||||||
db_open_env opens LiLDBM environment. db_config opens `default LiLDBM environment'. These are not necessary currently. They might be neccesarry if we develop multi-user processing functions or transaction. | |||||||||||||
> :- db_open_env("myenv", (ldbm:bdbm_page_size\ 1024 & ldbm:bdbm_cache_size\ 32768 & ldbm:flags\ ["CREATE", "INIT_MPOOL", "PRIVATE"]), $H). |
Format | db_open(+Pred) db_open(+File, +Info, +Pred) db_open(+Env, +file, +Info, +Pred) | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Arguments |
| |||||||||||||||||||||||||||||||
Note | The arguments of Pred are expressed as follows: list up definition of keys and datas that has any dimension by marking off with comma. But, DB is dealt with predicate,so sum of parameters must be under 15. key has two types:
DB name must be declared as predicate(subtype of pred) in advance.And don't put any space between array name and "(". Info is supposed to be the following feature structure; (ldbm:info_db& ldbm:mode\ +Mode& (optional) ldbm:flags\ +Flags& (optional) ldbm:type\ +Type& (optional) ldbm:cache_size\ +Cache (optional))
| |||||||||||||||||||||||||||||||
db_open/1 opens DB that keeps statistic values on memory. db_open/3 or db_open\4 opens DB on a file. | ||||||||||||||||||||||||||||||||
> myarr <- [pred]. > :- db_open("mydata.db", (ldbm:flags\ ["CREATE"]), myarr(key_integer & ARRAY_BASE\0 & ARRAY_SIZE\2000, array_value)). > myarr2 <- [pred]. > :- db_open(myarr2(key_inthash, array_value_string)).<BR><BR> > myarr3 <- [pred]. > :- db_open(myarr3((key_integer & ARRAY_BASE\ 0 & ARRAY_SIZE\ 100), (key_integer & ARRAY_BASE\ 0 & ARRAY_SIZE\ 200), array_value_integer, array_value_integer, array_value_string)). The first example is array that that has integer as a key and keeps one feature structure on a file. The second example is array that has integer as a key and keeps a string on memory. The third example is array (which has 2nd dimension) of 100x200,which keeps two integer and one strings.It is similar with struct arr1{ int a; int b; char *c; }arr1[100][200]; in C. |
Format | db_sync(+Pred) | |||
---|---|---|---|---|
Arguments |
| |||
The file DB is sync-ed. | ||||
> myarr <- [pred]. > :- db_open("mydata.db", (ldbm:flags\ ["CREATE"]), myarr(key_integer & ARRAY_BASE\0 & ARRAY_SIZE\2000, array_value)). > :- db_sync(myarr(_, _)). |
Format | db_close(+Pred) | |||
---|---|---|---|---|
Arguments |
| |||
db_close closes the specified DB. | ||||
> myarr <- [pred]. > :- db_open("mydata.db", (ldbm:flags\ ["CREATE"]), myarr(key_integer & ARRAY_BASE\0 & ARRAY_SIZE\2000, array_value)). > :- db_close(myarr(_, _)). |
Format | db_find(+Pred) db_find(+Iter, +Pred) | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Arguments |
| |||||||||
db_find/1 finds an entry specified keys in Pred. db_find/2 finds an entry specified by Iter. | ||||||||||
> myarr <- [pred]. > :- db_open("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_find(my_arr(10, X)), printAVM(X). > :- db_first(my_arr(_, _), I), db_find(I, X), printAVM(X). |
Format | db_insert(+Pred) | |||
---|---|---|---|---|
Arguments |
| |||
db_insert/1 stores/overwrite an entry. | ||||
> myarr <- [pred]. > :- db_open("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_find(my_arr(10, X)), printAVM(X). > :- db_first(my_arr(_, _), I), db_find(I, X), printAVM(X). |
Format | db_delete(+Pred) | |||
---|---|---|---|---|
Arguments |
| |||
db_delete/1 deletes an entry specified by keys from the DB. | ||||
> myarr <- [pred]. > :- db_open("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_delete(my_arr(10, _)). |
Format | db_clear(+Pred) | |||
---|---|---|---|---|
Arguments |
| |||
db_clear/1 deletes all entries in the DB. | ||||
> myarr <- [pred]. > :- db_open("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_clear(my_arr(_, _)). |
Format | db_findall(+Pred, -EntryList) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
db_findall/1 returns all entries in a list. | |||||||
> myarr <- [pred]. > :- db_declare("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_insert(my_arr(20, [4,5])). > :- db_insert(my_arr(30, [6,7,8,9])). > :- db_findall(my_arr(_, _), X), printAVM(X). |
Format | db_first(+Pred, -Iter) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
db_first returs the identifier of the first entry in the DB. | |||||||
> :- db_declare("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_first(my_arr(_, _), I), db_find(I, X), printAVM(X). |
Format | db_last(+Pred, -Iter) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
db_last returs the identifier of the last entry in the DB. | |||||||
> :- db_declare("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_last(my_arr(_, _), I), db_find(I, X), printAVM(X). |
Format | db_next(+Iter1, -Iter2) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
db_next returs the identifier of the next entry specified by Iter1. If there is no next entry, db_next fails. | |||||||
> myarr <- [pred]. > :- db_declare("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_insert(my_arr(30, [4,5,6,7])). > :- db_first(my_arr(_, _), I), db_next(I, J), db_find(J, X), printAVM(X). |
Format | db_prev(+Iter1, -Iter2) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
db_prev returs the identifier of the previous entry specified by Iter1. If there is no previous entry, db_prev fails. | |||||||
> myarr <- [pred]. > :- db_declare("hoge.db", ldbm:flags\ ["CREATE"], myarr(key_inthash, array_value)). > :- db_insert(my_arr(10, [1,2,3])). > :- db_insert(my_arr(30, [4,5,6,7])). > :- db_first(my_arr(_, _), I), db_prev(I, J), db_find(J, X), printAVM(X). |
Format | db_save(+FILE, +NAME) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
Save contents of DB into a file | |||||||
:- db_save("array1", arr1(_, _, _, _, _)). |
Format | db_load(+FILE, +NAME) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
Load contents of DB from a file | |||||||
:- db_load("array1", arr1(_, _, _, _, _)). |
Format | declare_array(+INFO) | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Arguments |
| |||||||||||||||||
Note | Array name must be declared as predicate(subtype of pred) in advance.And don't put any space between array name and "(". | |||||||||||||||||
Make arrray that keeps statistic values. | ||||||||||||||||||
> :- declare_array(arr1((key_integer & ARRAY_BASE\ 0 & ARRAY_SIZE\ 100), (key_integer & ARRAY_BASE\ 0 & ARRAY_SIZE\ 200), array_value_integer, array_value_integer, array_value_string)). > :- declare_array(arr2(key_string, array_value)). The first example is array (which has 2nd dimension) of 100x200,which keeps two integer and one strings.It is equal to struct arr1{ int a; int b; char *c; }arr1[100][200]; in C. The second example is array that has string as key ans keeps one feature structure. |
Format | delete_array(+NAME) | |||
---|---|---|---|---|
Arguments |
| |||
Delete array NAME. | ||||
:- delete_array(arr1(_, _, _, _, _)). |
Format | get_array(+INFO) | |||
---|---|---|---|---|
Arguments |
| |||
See also | set_array/1 | |||
Get value of array INFO. |
Format | set_array(+INFO) | |||
---|---|---|---|---|
Arguments |
| |||
See also | get_array/1 | |||
Set value of array. | ||||
> :- set_array(arr1(3,4,200,55,"abc")). > :- set_array(arr2("foo", abc & F1\aa)). > ?- get_array(arr1(3,4,X,Y,Z)). X: 200 Y: 55 Z: "abc" > ?- get_array(arr2("foo",X)). X: |~abc ~| |_F1:aa_| The first example is substitution of 200, 100, "abc" to the value of arr1[3][4]. The second example is entry of feature structure abc & F1\aa to arr2 with key key of "foo". To refer to value of array,describe query with array name as predicate. |
Format | unset_array(+INFO) | |||
---|---|---|---|---|
Arguments |
| |||
Unset value of array. | ||||
> :- unset_array(arr1(3,4,_,_,_)). > ?- get_array(arr1(3,4,X,Y,Z)). no |
Format | clear_array(+NAME) | |||
---|---|---|---|---|
Arguments |
| |||
Clear contents of array NAME. | ||||
:- clear_array(arr1(_, _, _, _, _)). |
Format | save_array(+FILE, +NAME) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
Save contents of array into a file | |||||||
:- save_array("array1", arr1(_, _, _, _, _)). |
Format | load_array(+FILE, +NAME) | ||||||
---|---|---|---|---|---|---|---|
Arguments |
| ||||||
Load contents of array from a file | |||||||
:- load_array("array1", arr1(_, _, _, _, _)). |