is_member in match specs

Ulf Wiger ulf.wiger@REDACTED
Thu Jan 22 12:19:05 CET 2004


I keep revisiting a certain database problem where I
want to perform fast lookups of a certain type. The
solution I keep coming back to is this:

I would like to have the boolFunction 'is_member',
corresponding to lists:member(X, List) to use in
an ets:select().

Basically, the problem is this:

I have a table, file_vsn:

#file_vsn{key = {Filename, Vsn}, views = [View]}

and another table, file_views:

#file_views{key = {View, Filename}, vsn = Vsn}

I want to be able to perform rapid searches on
file_vsn, where I select exactly the version of
a file that is visible in the current view (the
name of the view is a member of the list #file_vsn.views.

The alternative I will probably use is to fetch every
version of {Filename, Vsn} (could be 10-15 different ones)
to the heap and "manually" filter on lists:member().

It seems to me as if this pattern should be quite useful
in several different settings.

/Uffe

-- 
Ulf Wiger, Senior System Architect
EAB/UPD/S



More information about the erlang-questions mailing list