Boost logo

Boost Users :

Subject: [Boost-users] Request for conditional index feature in boost multi-index
From: Gokulakannan Somasundaram (gokul007_at_[hidden])
Date: 2010-12-21 15:36:03


Hi,
   First of all thanks for the great library, which had reduced our
development time by a lot.
   In boost multi-index, we currently have almost all the indexing concepts
integrated. Hence i am requesting for a new feature called conditional
indexes, where in an index/view inside multi-index will only index a portion
of the entries inside the entire multi-index(Say something that satisfies a
functor). This is in resemblance to the partial indexes in Postgresql.
    I feel that would provide elegant solutions to lot of issues without
forming round about solutions. For example i have a requirement where in
there are two sets of data with the same search criteria, but different
eviction criteria

Say i have two sets of data with same search condition, but one set needs a
MRU(Most Recently Used) list of 100 and the other set requires a MRU of 200.
Say the entry is like this

class Student
{
     int student_no;
     char sex;
     std::string address;
};

The search criteria is student_no, but for sex='m', we need MRU of 200 and
for sex='f', we need a MRU of 100. Now i have a solution where in i
introduce a new ordered index to maintain ordering.

For example the IndexSpecifierList will be something like this

typedef multi_index_container<
  Student,
  indexed_by<
    ordered_unique< member<Student, int, &Student::student_no> >,
    ordered_unique< composite_key<
                    member<Student, char, &Student::sex>,
                    member<Student, int,
&Student::sex_specific_student_counter> > >
>
> student_set

Here i have to introduce a new counter called sex_specific_student_counter,
and during the eviction time, i need a logn search. Insertion also involves
a extra logn complexity. Now instead if i have two sequenced indexes (like
mentioned in the MRU example) in the place of second ordered index, but both
with a condition on indexing only a few items, this would have looked more
elegant and with better performance.

Thanks in advance,

Gokul.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net