[erlang-questions] Mnesia -- "equals ignore case" equivalent?

Ulf Wiger ulf.wiger@REDACTED
Tue Jun 9 11:19:19 CEST 2009


I once wrote some code to convert a regexp to a
match specification. Given that you cannot recurse
in match specs, it has some severe limitations. If you
can live with those, you might get some mileage out of
this approach.

http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/rdbms/src/rdbms_ms.erl?revision=1.1&view=markup


Eshell V5.7.1  (abort with ^G)
1> rdbms_ms:re_match(["ulf","Ulf","ULF","abc"],"[uU][lL][fF]").
["ulf","Ulf","ULF"]
3> rdbms_ms:re("[uU][lL][fF]").
[{['$1','$2','$3'],
   [{'andalso',
        {'andalso',
            {'=/=','$1',[]},
            {'orelse',{'==','$1',85},{'==','$1',117}}},
        {'andalso',
            {'andalso',
                {'=/=','$2',[]},
                {'orelse',{'==','$2',76},{'==','$2',108}}},
            {'andalso',
                {'andalso',
                    {'=/=','$3',[]},
                    {'orelse',{'==','$3',70},{'==','$3',102}}},
                true}}}],
   ['$_']}]

At least it beats writing the same thing by hand. :)

One obvious problem is that, since the key part will be unbound,
it will result in a linear search. Not knowing your specific
problem, this may or may not be a killer. :/

BR,
Ulf W

Steve Davis wrote:
> Hi,
> 
> I can't see any advice previously offered for the best way to query a
> (large) mnesia table with a query comparable to "equals ignore case".
> 
> My first thought is to storing an indexed lower or upper "case"
> version of the data in an additional field, but with nearly 20 million
> records that doesn't seem very attractive.
> 
> TIA for any thoughts,
> 
> Regards,
> Steve
> 
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
> 


-- 
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com


More information about the erlang-questions mailing list