List:MySQL++« Previous MessageNext Message »
From:Rick Gutleber Date:October 15 2008 4:30pm
Subject:Re: Using MySQL++ with lots and lots of data
View as plain text  
Warren Young wrote:
> On Oct 14, 2008, at 3:20 PM, Rick Gutleber wrote:
>
>> Do you envision the policy as an actual object (i.e., class)?
> Yes.
>
> The only other alternative that comes to mind is an enum and a switch 
> statement inside insert(con, policy), but I think you will actually 
> end up with multiple versions of insert(con, policy), if only due to 
> the differences between sequence and associative containers.  So, 
> you'd end up duplicating code if you don't factor it out somehow.
Actually, that was my original thought, which is why I was thinking of 
the enum... I didn't quite get what you meant by the Policy class until 
this message.  I think I do now.

> Also, people may want to create their own policy classes.  I don't 
> propose to solve everyone's problem with this, just most people's. :)
The template function would work with a completely external Policy class 
as long as it provides the right methods:  OO without all the messing 
around with abstract base classes (although I like abstract base 
classes).  That's still a new idea to me, I have to get used to it.

>> Or maybe the policy should be a private struct....
>
> End-user code can't create policy objects if the declaration is private.
Duh. <smacks face> I meant a public member struct of the Query class.
>
>> Or, would you prefer me to use my own judgement and show you when I 
>> have something?  ;-)
>
> That, too, but be prepared for requests to go back and rewrite it.  :)
No problem.

>
> You have read HACKERS.txt, I hope?
I have now.  :-)

By the way, I really don't know I originally concluded that insert( Iter 
first, Iter last ) only inserts a row at a time.  That's obviously not 
true.  I think someone spiked my Mountain Dew.

However, that leads me to another question.  I was all ready to start 
knocking this thing out, but I realized each of the insert( ), replace( 
), etc calls in class Query puts a single query into the stream which 
gets executed when you call execute( ).  But now we are creating a 
situation where one call to insert( ) could result in multiple queries.  
We are doing so, among other things, to avoid exceeding the maximum 
packet size.  If I call execute( ) with, which in turn calls 
mysql_real_query( ) which requires multi-statement execution to be 
turned on to process multiple statements at once.  I would guess that 
maximum packet size would apply to the compound statement not each 
individual one.

The only alternative I can see is maintaining state outside of calls to 
insert( ), something like this:

Query::insert( Iter & it, Policy policy ) {
}

Iter it = container.begin( );

for ( Iter it = container.begin( ); it != container.end( ); 
query.insert( it, policy ) ) {
    query.execute( );
}

Am I missing something here?

Rick

Thread
Using MySQL++ with lots and lots of dataRick Gutleber13 Oct
  • Re: Using MySQL++ with lots and lots of dataAndrew Sayers14 Oct
  • Re: Using MySQL++ with lots and lots of dataWarren Young14 Oct
    • Re: Using MySQL++ with lots and lots of dataRick Gutleber14 Oct
      • Re: Using MySQL++ with lots and lots of dataWarren Young15 Oct
        • Re: Using MySQL++ with lots and lots of dataRick Gutleber15 Oct
          • Re: Using MySQL++ with lots and lots of dataWarren Young15 Oct
            • Re: Using MySQL++ with lots and lots of dataRick Gutleber15 Oct
              • Re: Using MySQL++ with lots and lots of dataWarren Young15 Oct