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 65FF510AFC for ; Tue, 3 Dec 2013 18:21:21 +0000 (UTC) Received: (qmail 73889 invoked by uid 500); 3 Dec 2013 18:21:21 -0000 Delivered-To: apmail-clerezza-dev-archive@clerezza.apache.org Received: (qmail 73834 invoked by uid 500); 3 Dec 2013 18:21:21 -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 73812 invoked by uid 99); 3 Dec 2013 18:21:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Dec 2013 18:21:20 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of andy.seaborne.apache@gmail.com designates 74.125.82.53 as permitted sender) Received: from [74.125.82.53] (HELO mail-wg0-f53.google.com) (74.125.82.53) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Dec 2013 18:21:16 +0000 Received: by mail-wg0-f53.google.com with SMTP id k14so11579163wgh.32 for ; Tue, 03 Dec 2013 10:20:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=40wHEEtpXfUG5IX13LITNO2x8g4d8MpMPrceCXT1yOs=; b=V4NRdgrcNTmYakVdatqxQACnSMsZi/0zFyJZYWOK7Fa3iw09ESr0IN8Hkb3ltVQ3ci fufTMogb038c2hlenvEnBsqeazPN9EZMol1pN/PLOY8kTfgLb7f5aVkfwnrhn51qnmVN BmInwFW6MPVQGW/r0ptoB0+vyChWT565mlOTqBGZ7l696E+LtI3M9+B9xXyGgbWI4DDS GuveUr1Cr5EU9LpQ5a1t12cB7DnB13+oLaZ6snNl3R9nAQTIuOT3TQWeLG1k7q4hwP1V 4RQIv7SIAy98DVH4AOVqFHP4apzElnLs53BgvSxLerMRYOypKFC4sd1cjoJY+aIao7s6 vZqQ== X-Received: by 10.180.210.232 with SMTP id mx8mr3705663wic.34.1386094854571; Tue, 03 Dec 2013 10:20:54 -0800 (PST) Received: from [192.168.0.114] (cpc37-aztw23-2-0-cust35.18-1.cable.virginm.net. [94.174.128.36]) by mx.google.com with ESMTPSA id d2sm7683571wik.11.2013.12.03.10.20.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Dec 2013 10:20:53 -0800 (PST) Message-ID: <529E2104.8050203@apache.org> Date: Tue, 03 Dec 2013 18:20:52 +0000 From: Andy Seaborne User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: dev@clerezza.apache.org Subject: Re: Problem with SingleTdbDatasetProvider References: <5271077E.5090506@xup.nl> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org On 03/12/13 15:13, Reto Bachmann-Gm�r wrote: > So here's some code to reproduced the ConcurrentModificationException > directly with jena (using transactions): > > String directory = "target/Dataset1"; > Dataset dataset = TDBFactory.createDataset(directory); > { > dataset.begin(ReadWrite.WRITE); > Model foo1 = 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 = ModelFactory.createDefaultModel(); > dataset.addNamedModel(URNXFOO2, foo2); > dataset.commit(); > dataset.end(); > } > { > dataset.begin(ReadWrite.WRITE); > Model foo1 = dataset.getNamedModel(URNXFOO1); > Model foo2 = dataset.getNamedModel(URNXFOO2); > StmtIterator iter = 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 at the same time. The code just happens to check otherwise there would be non-deterministic behaviour. (The check isn't perfect BTW.) This does it as well - and no transactions. public static void main1() throws Exception { String directory = "target/Dataset1"; String URNXFOO1 = "urn:x-foo:1" ; String URNXFOO2 = "urn:x-foo:2" ; Dataset dataset = TDBFactory.createDataset(); dataset.getNamedModel(URNXFOO1).add(RDFS.Class, RDF.type, RDFS.Class); dataset.getNamedModel(URNXFOO1).add(RDFS.Class, RDF.type, RDFS.Resource); Model foo1 = dataset.getNamedModel(URNXFOO1); Model foo2 = dataset.getNamedModel(URNXFOO2); StmtIterator iter = foo1.listStatements(); while (iter.hasNext()) { foo2.add(iter.nextStatement()); } } Andy > dataset.commit(); > dataset.end(); > } > > > On Wed, Oct 30, 2013 at 2:42 PM, Reto Bachmann-Gm�r 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 fixed >> (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�r 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 memory >>>> 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 used. >>>> >>>> Cheers, >>>> Reto >>>> >>> >>> >>> -- >>> ir. ing. Minto van der Sluis >>> Software innovator / renovator >>> Xup BV >>> >>> Mobiel: +31 (0) 626 014541 >>> >>> >> >