On Jan 19, 2012, at 3:16 PM, George Neill wrote:
> On Thu, Jan 19, 2012 at 3:59 PM, Craig L Russell <craig.russell@stripped
> > wrote:
> Hi George,
> On Jan 19, 2012, at 1:41 PM, George Neill wrote:
> Hi Folks,
> I am trying to understand the NDB blob API. When using
> transaction->readTuple(), the address of the blob pointer is written
> to the
> ndb record. After looking at the ndb code, this does NOT appear to
> with insertTuple()/updateTuple() calls. I am just starting to dig
> in to
> the NDB code base and I am trying to understand why a blob pointer
> is not
> written/allocated in to the blob stream in these situations. Or
> maybe the
> question is better asked as, Why is the blob pointer written only when
> using readTuple() ... Is there someone on the list who might have
> background on this subject and wouldn't mind explaining it to me!?
> The way I understand it, with insertTuple you allocate space in the
> buffer for the blob header pointer before you call insertTuple.
> After that, you can call getBlobHandle on the NdbOperation that is
> returned, you get a brand new blob handle, and you can write to the
> blob. What you are doing is defining one operation with insertTuple
> and other (set of) operations when you operate on the blob handle.
> I have allocated a buffer the size of the record (plus it's null
> bytes at the end) and handed this to the insertTuple() function. My
> understanding thus far ... at a minimum, the "key" parts have to be
> written to the record prior to calling insertTuple(). After
> insertTuple() is called, I can then call operation-
> >getBlobHandle(). I have done this and it DOES work.
> Here are the steps I am taking right now.
> build specification
> build the column insert mask
> copy data to the record (must include key columns, but not blob)
> operation = transaction->insertTuple()
> call blob = operation->getBlobHandle(col)
> call blob -> setValue()
> I just don't know enough about the API yet to know all of my
> options here. Still learning! I'd like to be able to merge the
> blob operations and the "copy data to the record" and execute them
> after the insertTuple() ... so any insight would be helpful.
As I understand it, everything you're doing is proper.
There is no way to merge the insertTuple and the setValue. But there
is no need to. There's no network activity until you do the execute.
The execute will do both the insert of the record and the writing of
the blob into the separate blob segment table.
Craig L Russell
408 276-5638 mailto:Craig.Russell@stripped
P.S. A good JDO? O, Gasp!