-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 18/05/11 10:33, P.Kremen wrote:
> Hi folks,
> 
> I have a SDB-backed web application. So far it worked as follows: 1)
> created a SDB backed model 2) performed model reads and writes (using
> various methods including model.add(Statement), Resource.addProperty,
> etc). 3) the SDB model is closed
> 
> This worked *most of the time*, but sometimes the results were lost
> during save which pointed me to SDB wiki that says, that whenever
> using 'model.add', the batch has to be demarked by 
> Model.notifyEvent(GraphEvents.startRead); ... WRITE ... 
> Model.notifyEvent(GraphEvents.finishRead);
> 
> I also came across another option for demarkation: 
> store.getLoader().startBulkUpdate(); ... WRITE ... 
> store.getLoader().finishBulkUpdate();
> 
> Could you please help me make clear 1) Which Model/Resource
> add/addProperty/addLabel/etc. operations need batch demarkation and 
> 2) Which of the demarkation mechanism is preferred.
> 
> Thanks !
> 
> Cheers, Petr
> 

Hi Petr,

Hmm, just checked the wiki and agree it ought to be clearer.

model.add _does not need_ batches to be indicated. By default each add
operation, that is each statement, list of statements or model add,
happens in a batch load.

If your results were occasionally lost something is definitely wrong and
we ought to investigate. Could you post your code?

What's the deal with explicitly marking adds then?

If you are writing code like:

for (Statement s: collectionOfStatements) {
  if (matchesSomeCondition(s)) sdbModel.add(s);
}

each add operation is a separate batched add, and that's expensive. By
wrapping this with notifications or bulk update call (they resolve to
the same thing so you can use either) you'll experience a substantial
performance increase -- though you need to be careful.

It's typically much better to just write to an in-memory model or list
of statements then add the whole thing to the sdbModel. No nasty finally
{} business etc.

Damian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3TmFQACgkQAyLCB+mTtynIhACg8fL59zdiXWMiODsWy3S+xlvD
pd0An1veNscFsAwTjVIVh3qYdtOE9/rF
=JxSW
-----END PGP SIGNATURE-----

Reply via email to