Return-Path: Delivered-To: apmail-incubator-jena-users-archive@minotaur.apache.org Received: (qmail 39389 invoked from network); 2 Feb 2011 20:04:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Feb 2011 20:04:15 -0000 Received: (qmail 64622 invoked by uid 500); 2 Feb 2011 20:04:15 -0000 Delivered-To: apmail-incubator-jena-users-archive@incubator.apache.org Received: (qmail 64572 invoked by uid 500); 2 Feb 2011 20:04:15 -0000 Mailing-List: contact jena-users-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jena-users@incubator.apache.org Delivered-To: mailing list jena-users@incubator.apache.org Received: (qmail 64562 invoked by uid 99); 2 Feb 2011 20:04:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Feb 2011 20:04:15 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [83.222.232.117] (HELO echo.justhostme.co.uk) (83.222.232.117) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Feb 2011 20:04:06 +0000 Received: from cpc2-aztw23-2-0-cust840.aztw.cable.virginmedia.com ([94.171.235.73] helo=[192.168.1.10]) by echo.justhostme.co.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Pkivc-000428-J5 for jena-users@incubator.apache.org; Wed, 02 Feb 2011 20:03:48 +0000 Message-ID: <4D49B89E.3010105@epimorphics.com> Date: Wed, 02 Feb 2011 20:03:42 +0000 From: Andy Seaborne User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: jena-users@incubator.apache.org Subject: Re: ARQ query on DataSources References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - echo.justhostme.co.uk X-AntiAbuse: Original Domain - incubator.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - epimorphics.com X-Virus-Checked: Checked by ClamAV on apache.org Stuart, I can't see what might be going wrong from your code - could you show how the DataSource was created in the first place and how data got into it? Ideally, a complete, minimal example that I can run at my end. (and the version of software would also be good). What is quite odd is that: > images.addNamedModel(id, mk.createDefaultModel().read(new > ByteArrayInputStream(bytes.toString().getBytes()),"")); > images.addNamedModel(id, image); which adds the data twice once as a new model and once as the original data, in fact replaces the new with the original. addNamedModel is replace if the name is already in use. What is the query? Andy On 02/02/11 16:31, Stuart Kenny wrote: > Hi, I've been stuck trying to query a DataSource for the last few > days. The DataSource is being used as a store of models. One class > adds Models to the DataSource using addNamedModel, and a separate > class is meant to answer queries on this DataSource. When I try to > execute a query however I get no results: > > > Query query = QueryFactory.create(queryString); > QueryExecution qe = QueryExecutionFactory.create(query, getImages()); > ResultSet results = qe.execSelect(); > > where getImages() returns the DataSource being used as a Model store. > > Crazily if I create a new DataSource and then iterate through the > models, writing them out and then reading them back in, the query > works on this new DataSource: > > ModelMaker mk = ModelFactory.createMemModelMaker(); > DataSource images = DatasetFactory.create(mk.createDefaultModel()); > > for ( Iterator imagesIter = getImages().listNames(); > imagesIter.hasNext(); ){ > String id = imagesIter.next(); > Model image = getImages().getNamedModel(id); > ByteArrayOutputStream bytes = new ByteArrayOutputStream(); > BufferedOutputStream out = new BufferedOutputStream(bytes); > image.getWriter().write(image, out, ""); > images.addNamedModel(id, mk.createDefaultModel().read(new > ByteArrayInputStream(bytes.toString().getBytes()),"")); > images.addNamedModel(id, image); > } > > Query query = QueryFactory.create(queryString); > QueryExecution qe = QueryExecutionFactory.create(query, images); > ResultSet results = qe.execSelect(); > > Just adding the models isn't enough, I have to write and read to new > Models to get it to work! > > I can't really write all the models out and then re-read them to get a > query to succeed. Presumably using a DataSource in this way is > incorrect. I'm new to this so I'm obviously doing something > fundamentally wrong. > > Would be very grateful for any help. > > Thanks.