Return-Path: X-Original-To: apmail-clerezza-dev-archive@www.apache.org Delivered-To: apmail-clerezza-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4190C10C26 for ; Wed, 4 Dec 2013 11:24:55 +0000 (UTC) Received: (qmail 84837 invoked by uid 500); 4 Dec 2013 11:24:53 -0000 Delivered-To: apmail-clerezza-dev-archive@clerezza.apache.org Received: (qmail 84742 invoked by uid 500); 4 Dec 2013 11:24:46 -0000 Mailing-List: contact dev-help@clerezza.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@clerezza.apache.org Delivered-To: mailing list dev@clerezza.apache.org Received: (qmail 84734 invoked by uid 99); 4 Dec 2013 11:24:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 11:24:42 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [213.238.45.90] (HELO r2-d2.netlabs.org) (213.238.45.90) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 11:24:36 +0000 Received: (qmail 6427 invoked by uid 89); 4 Dec 2013 11:24:04 -0000 Received: from unknown (HELO mail-lb0-f170.google.com) (farewellutopia@netlabs.org@209.85.217.170) by 0 with ESMTPA; 4 Dec 2013 11:24:04 -0000 Received: by mail-lb0-f170.google.com with SMTP id w7so9354145lbi.15 for ; Wed, 04 Dec 2013 03:23:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=kaVt4edWrsckck800zLo7OOHDjRxey+cE1FP0eTmsWg=; b=G9/tiHrSSqmO6QBtCYOd/moe3f5EpPw9nwuyRuxJvptdlAMvKT2AFqQ6yMcC5CP/Rt aYYd9cWAA/L4Mi+F0wN1k0WOLINLfTbzkQb7/0zhkGM7SfielT13rSSuJUlw099a6s7H BcIITDXQdSR/OJMBMwhPaM6vgjvDCWMq6FnY55B2n45lo4mFxZyKFsXnnjd6qY7Txt9k 7rJPMaQnr5n8z+0zyYap8oPGDH7wJpXP7YFq9KnP586t54n5tv6H/0CJJN+yoqTTuBw7 wXlLh1YAu+sNnSnCd3eBpslywAuAdEl7Vdir13Io7MydZwhTEBe6uganDqXrkX4C+KgG fYqA== X-Gm-Message-State: ALoCoQnROdda08CE5FXH+W4+6Hlhg/dTr+NqaguqzkV1th+W6BKU4OJBdAWX6cOKD6hSbfyYAfrO MIME-Version: 1.0 X-Received: by 10.152.180.228 with SMTP id dr4mr4824249lac.32.1386156229621; Wed, 04 Dec 2013 03:23:49 -0800 (PST) Received: by 10.152.28.166 with HTTP; Wed, 4 Dec 2013 03:23:49 -0800 (PST) X-Originating-IP: [147.87.243.214] In-Reply-To: <529E2104.8050203@apache.org> References: <5271077E.5090506@xup.nl> <529E2104.8050203@apache.org> Date: Wed, 4 Dec 2013 12:23:49 +0100 Message-ID: Subject: Re: Problem with SingleTdbDatasetProvider From: =?ISO-8859-1?Q?Reto_Bachmann=2DGm=FCr?= To: dev@clerezza.apache.org Content-Type: multipart/alternative; boundary=001a1134640cab905c04ecb3a516 X-Virus-Checked: Checked by ClamAV on apache.org --001a1134640cab905c04ecb3a516 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Dec 3, 2013 at 7:20 PM, Andy Seaborne wrote: > On 03/12/13 15:13, Reto Bachmann-Gm=FCr wrote: > >> So here's some code to reproduced the ConcurrentModificationException >> directly with jena (using transactions): >> >> String directory =3D "target/Dataset1"; >> Dataset dataset =3D TDBFactory.createDataset(directory); >> { >> dataset.begin(ReadWrite.WRITE); >> Model foo1 =3D ModelFactory.createDefaultModel(); >> foo1.add(RDFS.Class, RDF.type, RDFS.Class); >> foo1.add(RDFS.Class, RDF.type, RDFS.Resource); >> dataset.addNamedModel(URNXFOO1, foo1); >> dataset.commit(); >> dataset.end(); >> } >> { >> dataset.begin(ReadWrite.WRITE); >> Model foo2 =3D ModelFactory.createDefaultModel(); >> dataset.addNamedModel(URNXFOO2, foo2); >> dataset.commit(); >> dataset.end(); >> } >> { >> dataset.begin(ReadWrite.WRITE); >> Model foo1 =3D dataset.getNamedModel(URNXFOO1); >> Model foo2 =3D dataset.getNamedModel(URNXFOO2); >> StmtIterator iter =3D foo1.listStatements(); >> while (iter.hasNext()) { >> foo2.add(iter.nextStatement()); >> } >> > > You are modifying the dataset while iterating over it. > > Model foo2 is just a view of the dataset, not an isolated copy. 'fraid > you can't modify the dataset and get a consistent view for the iterator a= t > the same time. The code just happens to check otherwise there would be > non-deterministic behaviour. (The check isn't perfect BTW.) > I don't see why Jena can't be a bit more selective, an addition to another graph cannot possibly affect the current iterator. The above is what happens when we addAll is invoked on a clerezza graph. Isee that for simialr methods the jena implementation copy the graph to be added to memory first, it would be good to have a more efficient solution. > > This does it as well - and no transactions. > > public static void main1() throws Exception { > String directory =3D "target/Dataset1"; > String URNXFOO1 =3D "urn:x-foo:1" ; > String URNXFOO2 =3D "urn:x-foo:2" ; > > Dataset dataset =3D TDBFactory.createDataset(); > dataset.getNamedModel(URNXFOO1).add(RDFS.Class, RDF.type, > RDFS.Class); > dataset.getNamedModel(URNXFOO1).add(RDFS.Class, RDF.type, > RDFS.Resource); > > > Model foo1 =3D dataset.getNamedModel(URNXFOO1); > Model foo2 =3D dataset.getNamedModel(URNXFOO2); > StmtIterator iter =3D foo1.listStatements(); > while (iter.hasNext()) { > foo2.add(iter.nextStatement()); > } > } > That's more elegant ;) Reto > > > > Andy > > > dataset.commit(); >> dataset.end(); >> } >> >> >> On Wed, Oct 30, 2013 at 2:42 PM, Reto Bachmann-Gm=FCr > >wrote: >> >> Hi Minto >>> >>> Interesting problem you have there. >>> >>>> >>>> >>> Thanks ;) >>> >>> >>>> Best is to fix the dreaded ConcurrentModificationException. >>>> Occasionally >>>> I run into it it als well. But most probably it is not that trivial to >>>> solve. >>>> >>>> >>> On hand we had some concurrency issues that caused the exception. I fix= ed >>> (some of) them recently, the tests are now passing. >>> >>> On the other hand the exception is coming from Jena (as well as as from >>> java collections) if the dataset (respectively the collection) is >>> modified >>> while iterating over it. Inthe case of addAll the modification of the >>> underlying dataset is necessary, so this is not about some >>> timing/concurrency. >>> >>> Cheers, >>> Reto >>> >>> >>> >>> >>> >>>> The only work around that I see is copy the MGraph to a different >>>> provider and do the normal addAll(). This other provider does not >>>> necessarily need to be in memory. Basically it is 2x addAll(). One to = a >>>> different provider and one back. >>>> >>>> My knowledge is too limited to comment on forwarding it to Jena. >>>> >>>> Hope this is of some help to you. >>>> >>>> Regards, >>>> >>>> Minto >>>> >>>> Reto Bachmann-Gm=FCr schreef op 30-10-2013 12:46: >>>> >>>>> Hi >>>>> >>>>> I'm having a problem using addAll two add one Mgraph from >>>>> SingeTdbDatasetProvider to another such MGraph. >>>>> >>>>> The problem is that the iterator over that added graph will return a >>>>> ConcurrentModificationException as soon as a triple has been added to >>>>> >>>> the >>>> >>>>> target graph. >>>>> >>>>> I don't know how to solve this. Copying the graph to be added to memo= ry >>>>> doesn't seem to be a compealing solution. Maybe the add-all could be >>>>> forwarded to Jena but this would solve the problem only in some cases= , >>>>> >>>> not >>>> >>>>> if there is any wrapper on the added graph or if union-graphs are use= d. >>>>> >>>>> Cheers, >>>>> Reto >>>>> >>>>> >>>> >>>> -- >>>> ir. ing. Minto van der Sluis >>>> Software innovator / renovator >>>> Xup BV >>>> >>>> Mobiel: +31 (0) 626 014541 >>>> >>>> >>>> >>> >> > --001a1134640cab905c04ecb3a516--