Re: [boost] Interest in an ODBC library?

Joaquin! Glad you responded and Good to be "talking" with you again :) Below:
On Behalf Of JOAQUIN LOPEZ MU?Z
[Brian Braatz Writes:]
I am not sure if he is still interested, but Joaquin Munez and I exchanged emails awhile back about collaborating on such a beast.
The general idea was to take the functionality in multi-index containerand make it work dynamically.
[JOAQUIN LOPEZ MUNEZ Writes:]
I am still interested, and it is my plan to implement a dynamic_multi_index_container in the future, if there's interest in such a thing --serving as the foundation for a DB table structure would be a very exciting application, undoubtedly.
Let me sketch what I have in mind: The part of adding/removing indices at run time is not too hard: I haven't written any actual code, but the design of that feature seems reasonably straightforward to me. Some speed/space performance will be lost, but I guess this is expected.
The hard part, IMHO, is how to gain access to such indices. Clearly some kind of runtime polymorhpisn is involved for a dynamic_multi_index_container to have any use: otherwise, the user code would have to know the exact type of the index it is retrieving. So we need something more powerful than the current static get<> interface. A possibility is to retrieve indices by mean of *interfaces* as defined in Jonathan Turkanis' BIL library:
[Brian Braatz Writes:] If you would please elaborate. (some of us are "slower" than others :) ). is the problem getting to the index objects themselves via inherit_linearly? if you have dynamic data, then I am thinking you also have dynamically applied indices? Maybe I can elaborate- consider the following pseudo code: connection con = db.connect("myserver,root,password,mydatabase"); dynamic_table dt; // the select "*" means bring me back all the fields from that table // even though I don't know what the fields ARE yet dt = query("select * from person"); // ok so now dt has an UNKNOWN number of columns dt.add_index( index("first_name")); // or something along those lines. in this case, the index is applied dynamically. so how does that connect with the things you said ? Thanks, Brian

Brian Braatz <brianb <at> rmtg.com> writes:
If you would please elaborate. (some of us are "slower" than others :) ).
is the problem getting to the index objects themselves via inherit_linearly?
if you have dynamic data, then I am thinking you also have dynamically applied indices?
Maybe I can elaborate-
consider the following pseudo code:
connection con = db.connect("myserver,root,password,mydatabase");
dynamic_table dt;
// the select "*" means bring me back all the fields from that table // even though I don't know what the fields ARE yet dt = query("select * from person");
// ok so now dt has an UNKNOWN number of columns
dt.add_index( index("first_name"));
// or something along those lines.
in this case, the index is applied dynamically.
so how does that connect with the things you said ?
Let me formulate the problem in the terminology of Boost.MultiIndex --hopefully, the implications for a DB framework scenario will be clear after this. Consider the following perfectly normal code dealing with a static multi_index_container: typedef multi_index_container< element, indexed_by< ordered_unique<identity<element> >, sequenced<>
static_mic_t;
template<typename Index> void reverse_dump(const Index& i) { std::copy( i.rbegin(),i.rend(), std::ostream_iterator<typename Index::value_type>(std::cout)); } int main() { static_mic_t s_mic; ... reverse_dump(s_mic.get<0>()); reverse_dump(s_mic.get<1>()); } What would the equivalent be for the dynamic case? typedef dynamic_multi_index_container< element
dynamic_mic_t; // no indices specified at compile time
int main() { dynamic_mic_t d_mic; // add indices at run time d_mic.add_index<ordered_unique<identity<element> > >(); d_mic.add_index<sequenced<> >(); ... reverse_dump(d_mic.get(0)); // note index number is no longer reverse_dump(d_mic.get(1)); // a template parameter } Now, how are we supposed to define reverse_dump? Clearly it cannot be the same template as in the static case, since the types of the indices are only known at run time. Also, it is not clear what get(), which no longer accepts the index number as a template parameter, should return: now the function locates and provides the index at run time. What we want is some sort of run-time polymorphism, as provided by abstract classes or BIL interfaces. With the second option, we can have something like this: typedef dynamic_multi_index_container< element, // this is the interface indices must conform to when // added at run time IBidirectionalContainer<element>
dynamic_mic_t;
template<typename Element> void reverse_dump(IBidirectionalContainer<Element> i) { std::copy( i.rbegin(),i.rend(), std::ostream_iterator<Element>(std::cout)); } int main() { dynamic_mic_t d_mic; // add indices at run time // This is fine as both ordered and sequenced indices // model IBidirectionalContainer. If we tried to add // a hashed index, which only provides forward iterators, // a compile-time error would be triggered. d_mic.add_index<ordered_unique<identity<element> > >(); d_mic.add_index<sequenced<> >(); ... // OK now, get() returns a IBidirectionalContainer // interface object, providing "virtual" rbegin and // rend memfuns. reverse_dump(d_mic.get(0)); reverse_dump(d_mic.get(1)); } Get the idea? Interfaces provide the necessary virtuality into the run-time polymorphism realm. This concept is sometimes called "type erasure" and pops up recurrently when bridging templates and run-time polymorphism. If I wasn't clear enough please tell me so and I'll try to elaborate. I'll be more than happy to discuss and refine these ideas. IMHO the concepts around a potential multi_index_container sketched here can serve as the basis for a DB run-time data structure, much like for instance IndexedDBView in the DTL does. Best, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
Brian Braatz
-
Joaquin M Lopez Munoz