List:Cluster« Previous MessageNext Message »
From:Magnus Blåudd Date:November 22 2012 7:25am
Subject:Re: Help with ClusterJ
View as plain text  
On 11/21/2012 10:12 PM, Graeme Wallace wrote:
> I have a stream of data that i'm trying to persist into a cluster using
> ClusterJ and I'm running into problems.
>
> For each ASCII record that i receive, I'm parsing into Java primitives then
> setting the fields on a Java representation that i've gotten via
> Session.newInstance()
>
> what i would really like to do then is to call
>
> session.savePersistent()
>
> so that if the primary key already exists in the db the row gets updated,
> and if the primary key doesnt exist a new row gets created.
>

Sounds like "INSERT INTO vs REPLACE INTO in SQL" or "insertTuple() vs 
writeTuple() in NdbApi". Seems like ClusterJ which is implemented on top 
of NdbApi should be able to do the same thing(if instructed to).


It actually looks like ClusterJ is using writeTuple, check out this part 
of SessionImpl.java:

>     /** Save the instance even if it does not exist.
>      * @param instance the instance to save
>      */
>     public <T> T savePersistent(T instance) {



/ Magnus


> Unfortunately, this doesnt work as I get an exception back if the primary
> key already exists.
>
> Is there a way around this without having to do a session.find() on the
> primary key and then updating the fields on the object returned ?
>
> The volume of data that I'm trying to insert is quite large (hundreds of
> millions of records) and this would seem like a significant overhead if i
> had to do a session.find() for every record.
>
>

Thread
Help with ClusterJGraeme Wallace21 Nov
  • Re: Help with ClusterJMagnus Blåudd22 Nov
    • Re: Help with ClusterJGraeme Wallace22 Nov