Christian,
Hi.
To end this topic, you should find enclosed two files that fulfills now my requirements. I found these objects very practical, their purpose are to handle set or maps of nodes / functions.
I am publishing them here very informally, hoping other BaseX users could find them as helpful as I do, or maybe yourself, or a standardization committee.
- The first one, idmap.xqm, allows to use maps, with nodes or functions as keys.
- The second one, set.xqm, allows to define set of items (I use such an object to define a stack).
These files consists in small overload of the BaseX map module. Both require an external id function of atomic type, that must be provided by the user.
Below are the profile tests for these maps and set. The profile function is located into idmap:profile($i,$j) to be run by others. Basically, the "idmap" seems to be five time slower than BaseX map for inserting atomic types. Set seems to be quite comparable to BaseX map. This overload come from perf issues in XQUERY, but I can handle this small overload for my purposes. Obviously, for atomic type, it is better to use directly the map module, and these objects embed a basic protection to avoid a misusing.
Some remarks :
1) It means that users are linked to BaseX map module when they are using these objects. As you already know, I tried unsuccessfully to write them in pure XQUERY, one of the motivation was not to be linked an external module.
2) Using a map module to define a set is not really the best way to proceed, but it seems that XQUERY 3.0 users don't have any other choice.
3) I think that BaseX could provide a simplified access to such objects. Indeed, the BaseX interpreter must have a default id for nodes or functions that it could expose to users, or use it directly through the BaseX map module.
Hope that helps
Cheers,
Jean-Marc
Tag
name/Text |
nb |
integer_set |
node_set |
integer_map |
Basex_integer_map |
node_map |
|
test |
1024 |
24.63 ms |
43.36 ms |
51.6 ms |
6.35 ms |
70.92 ms |
|
test |
2048 |
10.91 ms |
46.71 ms |
17.52 ms |
3.57 ms |
51.62 ms |
|
test |
4096 |
1.71 ms |
31.52 ms |
11.7 ms |
1.04 ms |
23.59 ms |
|
test |
8192 |
2.49 ms |
22.88 ms |
15.41 ms |
1.72 ms |
32.5 ms |
|
test |
16384 |
5.12 ms |
20.23 ms |
33.47 ms |
2.9 ms |
50.62 ms |
|
test |
32768 |
8.31 ms |
31.54 ms |
58.95 ms |
5.77 ms |
86.86 ms |
|
test |
65536 |
20.1 ms |
71.39 ms |
99.57 ms |
13.0 ms |
162.09 ms |
|
test |
131072 |
48.15 ms |
157.27 ms |
680.47 ms |
33.68 ms |
947.9 ms |
|
test |
262144 |
99.67 ms |
305.88 ms |
1132.31 ms |
77.85 ms |
683.37 ms |
|
test |
524288 |
239.43 ms |
569.46 ms |
1769.53 ms |
383.77 ms |
2903.24 ms |
|
test |
1.05E+06 |
737.79 ms |
2485.75 ms |
5022.02 ms |
1031.71 ms |
10204.07 ms |
|