| Author |
Message |
|
| bparsia at email.unc.edu |
Posted: Thu Feb 25, 1999 12:46 am |
|
|
|
Guest
|
Are there additional restrictions on list comprehensions in queries?
I have the following query:
PathLength = length(Path) + Depth,
F = fun() ->
Q = query [Item || Item <- table(cvn_path_item),
lists:prefix(Path, Item.path),
length(Item.path) =< PathLength]
end,
mnemosyne:eval(Q)
end,
Where #cvn_path_item.path is a list.
If I try this I get:
{aborted,{badarg,{ets,lookup,
[db_get,[mnemosyne_catalog,{image,cvn_path_item}]]}}}
But if I do the query, and then do the rest of the list comprehension on
the result, it works fine.
Help?
Cheers,
Bijan Parsia.
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| btu at erix.ericsson.se |
Posted: Thu Feb 25, 1999 6:56 am |
|
|
|
Guest
|
On Wed, 24 Feb 1999, Bijan Parsia wrote:
> Are there additional restrictions on list comprehensions in queries?
>
>
> I have the following query:
>
> PathLength = length(Path) + Depth,
> F = fun() ->
> Q = query [Item || Item <- table(cvn_path_item),
> lists:prefix(Path, Item.path),
> length(Item.path) =< PathLength]
> end,
> mnemosyne:eval(Q)
> end,
>
> Where #cvn_path_item.path is a list.
>
> If I try this I get:
>
> {aborted,{badarg,{ets,lookup,
> [db_get,[mnemosyne_catalog,{image,cvn_path_item}]]}}}
>
> But if I do the query, and then do the rest of the list comprehension on
> the result, it works fine.
>
> Help?
>
> Cheers,
> Bijan Parsia.
I don't have the opensource release testable at my hands, but you did
remeber to start mnesia and mnemosyne, didn't you?
The following shell interaction works for me (slightly different release)
using the code shown below.
// Bjoern
--------------------------------------------------
btu_at_idril:mne$ erl
Erlang (JAM) emulator version 4.7.3.3
Eshell V4.7.3.3 (abort with ^G)
1> c(q).
{ok,q}
2> q:s().
{atomic,ok}
3> q:add_path([1,2,3,4,5]), q:add_path([2,3,4,5,6]),
q:add_path([3,4,5,6,7]).
{atomic,ok}
4> q:tstPath([2,3,4], 9999).
{atomic,[{cvn_path_item,[2,3,4,5,6],undefined}]}
--------------------------------------------------
Code as follows:
-module(q).
-export([s/0,add_path/1, tstPath/2]).
-include_lib("mnemosyne/include/mnemosyne.hrl").
-record (cvn_path_item, {path, other_fields}).
s () ->
mnesia:start (),
application:start(mnemosyne),
mnesia:create_table (cvn_path_item,
[{attributes, record_info(fields, cvn_path_item)}]).
add_path (Path) ->
Fun = fun () ->
mnesia:write (#cvn_path_item{path=Path})
end,
mnesia:transaction (Fun).
tstPath (Path, Depth) ->
PathLength = erlang:length(Path) + Depth,
F = fun() ->
Q = query [Item || Item <- table(cvn_path_item),
lists:prefix(Path, Item.path),
erlang:length(Item.path) =< PathLength]
end,
mnemosyne:eval(Q)
end,
mnesia:transaction(F).
--------------------------------------------------------------
--
Mouse moved last hour: 9.23, today: 9.23, this week: 870.62 (meters)
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| bparsia at email.unc.edu |
Posted: Thu Feb 25, 1999 10:52 am |
|
|
|
Guest
|
[snip]
>I don't have the opensource release testable at my hands, but you did
>remeber to start mnesia and mnemosyne, didn't you?
>The following shell interaction works for me (slightly different release)
>using the code shown below.
>
> // Bjoern
>
[snip]
No I didn't remember! Well, I remembered to start mnesia, but not
mnemosyne. Since "plain" queries were working I didn't even suspect I had
too. Thanks, you completely solved my problem and I'm much happier now :)
And this works find in the latest open source release.
Cheers,
Bijan Parsia.
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|