List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:April 24 2007 7:01am
Subject:Re: Language-specific wrappers/extensions
View as plain text  
Mika Raento wrote:
> Monty Taylor kirjoitti:
>> Monty Taylor wrote:
>>
>>> Maybe we should load the data dictionary at initialization time and have
>>> our wrappers for equal and setValue for char* types do a lookup in the
>>> data dictionary on the column type and either space pad char columns or
>>> add length to the varchar columns. That could all be done once in C++ in
>>> the swig file and taken advantage of by all the languages. Sound
>>> reasonable? 
> 
> Using the datadict sounds good. I could imagine taking much more
> advantage of it for scripting languages in general: create a single
> NdbRecAttr::value() as well which returns the correct target language
> type for the underlying database type (including making strings out of
> aRef() and get_size_in_bytes()).

Yes, I agree. I had also done this in the Python code, but I think that
doing it in the SWIG wrapper and using it everywhere will be good - at
least as much as we can.

> 
>> +            memcpy(theModifiedValue,theValue,strlen(theValue));
> 
> I would like to pass in the length instead of strlen. This will make it
> possible to use with binary data which may include nulls. Most of the
> target languages already keep the length. I don't know if there's a nice
> way to split the string into data and length in SWIG or whether you need
> a small language-specific wrapper for that bit.

I agree. I think we can do this with typemaps perhaps. But I think we'll
also need a languages specific bit, as getting the length from each
language will be different.

>> I haven't really tested this yet - but I thought I'd get some thoughts
>> on this approach before going to far. What do you think? If you want to
>> avoid the switch, you can just use setValueRaw.
> 
> I second keeping the raw interface available.

I did a quick test, and there are some issues with the code I posted,
namely I'm actually masking the setValue method I define with the rename
setValue statement. I'll figure that out in the morning - unless you
beat me to it. :)


-- 
Monty Taylor
Senior Consultant
MySQL Inc., www.mysql.com
Get More with MySQL!  www.mysql.com/consulting
Thread
Language-specific wrappers/extensionsMika Raento23 Apr
  • Re: Language-specific wrappers/extensionsMonty Taylor23 Apr
    • Re: Language-specific wrappers/extensionsMonty Taylor24 Apr
      • Re: Language-specific wrappers/extensionsMika Raento24 Apr
        • Re: Language-specific wrappers/extensionsMonty Taylor24 Apr
Re: Language-specific wrappers/extensionsMonty Taylor24 Apr
  • %/% rule in Makefile?Mika Raento25 Apr
    • Re: %/% rule in Makefile?Monty Taylor25 Apr
      • Re: %/% rule in Makefile?Mika Raento26 Apr
        • DocumentationMonty Taylor27 Apr
      • lifetime of Ndb and Ndb_cluster_connection objectsMika Raento26 Apr
        • Re: lifetime of Ndb and Ndb_cluster_connection objectsMonty Taylor27 Apr
          • Re: lifetime of Ndb and Ndb_cluster_connection objectsMika Raento7 May
            • Re: lifetime of Ndb and Ndb_cluster_connection objectsMonty Taylor7 May
      • Support for NdbIndex(Scan)Operation, prelim. support for typed attributeaccessMika Raento26 Apr
        • Re: Support for NdbIndex(Scan)Operation, prelim. support for typedattribute accessMonty Taylor28 Apr
Re: lifetime of Ndb and Ndb_cluster_connection objectsMonty Taylor8 May