You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Site Guo <gu...@hotmail.com> on 2013/04/14 16:36:11 UTC

How to list models in a dataset?

Is there an API function that lists all models (graphs) within a given dataset? 

There is a function listNames() in Dataset. I am not sure if it is used to return all named graphs. When I tried to use it like this:

Iterator<String> models = ds.listNames(); //ds is a dataset object that has been created and connected.
while (models.hasNext())
{ 
     System.out.println(models.next());
}

 Java gave me the following error:


Exception in thread "main" java.lang.NullPointerException
    at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:94)
    at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:90)
    at com.hp.hpl.jena.util.iterator.MapFilterIterator.hasNext(MapFilterIterator.java:55)

I am using TDB.

Could anyone help me figure that out ?
Thanks in advance.

Site (Victor) Guo

 		 	   		  

RE: How to list models in a dataset?

Posted by Site Guo <gu...@hotmail.com>.
Andy,
    I found the TDB transaction documentation on jena website, followed it and it works now. Thank you.

Site (Victor) Guo


> From: guosite@hotmail.com
> To: users@jena.apache.org
> Subject: RE: How to list models in a dataset?
> Date: Sun, 14 Apr 2013 12:00:04 -0500
> 
> I'm running 2.10.0
> I think you are right. When I change the dataset to another newly created one it works.
> 
> How am I supposed to sync the TDB before exiting JVM?
> 
> Site (Victor) Guo
> 
> 
> 
> > Date: Sun, 14 Apr 2013 17:55:35 +0100
> > From: andy@apache.org
> > To: users@jena.apache.org
> > Subject: Re: How to list models in a dataset?
> > 
> > On 14/04/13 15:36, Site Guo wrote:
> > > Is there an API function that lists all models (graphs) within a given dataset?
> > >
> > > There is a function listNames() in Dataset. I am not sure if it is used to return all named graphs. When I tried to use it like this:
> > >
> > > Iterator<String> models = ds.listNames(); //ds is a dataset object that has been created and connected.
> > > while (models.hasNext())
> > > {
> > >       System.out.println(models.next());
> > > }
> > >
> > >   Java gave me the following error:
> > >
> > >
> > > Exception in thread "main" java.lang.NullPointerException
> > >      at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:94)
> > >      at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:90)
> > >      at com.hp.hpl.jena.util.iterator.MapFilterIterator.hasNext(MapFilterIterator.java:55)
> > >
> > > I am using TDB.
> > >
> > > Could anyone help me figure that out ?
> > > Thanks in advance.
> > 
> > Hi,
> > 
> > I checked it works for me (Jena 2.10.1 development, TDB 0.10.1 development).
> > 
> > A way this can occur is a corrupted database by non-transactional use 
> > then exiting the JVM without sync'ing the database.
> > 
> > Which version are you running>
> > 
> > 	Andy
> > 
> > >
> > > Site (Victor) Guo
> > >
> > >   		 	   		
> > >
> > 
>  		 	   		  
 		 	   		  

RE: How to list models in a dataset?

Posted by Site Guo <gu...@hotmail.com>.
I'm running 2.10.0
I think you are right. When I change the dataset to another newly created one it works.

How am I supposed to sync the TDB before exiting JVM?

Site (Victor) Guo



> Date: Sun, 14 Apr 2013 17:55:35 +0100
> From: andy@apache.org
> To: users@jena.apache.org
> Subject: Re: How to list models in a dataset?
> 
> On 14/04/13 15:36, Site Guo wrote:
> > Is there an API function that lists all models (graphs) within a given dataset?
> >
> > There is a function listNames() in Dataset. I am not sure if it is used to return all named graphs. When I tried to use it like this:
> >
> > Iterator<String> models = ds.listNames(); //ds is a dataset object that has been created and connected.
> > while (models.hasNext())
> > {
> >       System.out.println(models.next());
> > }
> >
> >   Java gave me the following error:
> >
> >
> > Exception in thread "main" java.lang.NullPointerException
> >      at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:94)
> >      at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:90)
> >      at com.hp.hpl.jena.util.iterator.MapFilterIterator.hasNext(MapFilterIterator.java:55)
> >
> > I am using TDB.
> >
> > Could anyone help me figure that out ?
> > Thanks in advance.
> 
> Hi,
> 
> I checked it works for me (Jena 2.10.1 development, TDB 0.10.1 development).
> 
> A way this can occur is a corrupted database by non-transactional use 
> then exiting the JVM without sync'ing the database.
> 
> Which version are you running>
> 
> 	Andy
> 
> >
> > Site (Victor) Guo
> >
> >   		 	   		
> >
> 
 		 	   		  

Re: How to list models in a dataset?

Posted by Andy Seaborne <an...@apache.org>.
On 14/04/13 15:36, Site Guo wrote:
> Is there an API function that lists all models (graphs) within a given dataset?
>
> There is a function listNames() in Dataset. I am not sure if it is used to return all named graphs. When I tried to use it like this:
>
> Iterator<String> models = ds.listNames(); //ds is a dataset object that has been created and connected.
> while (models.hasNext())
> {
>       System.out.println(models.next());
> }
>
>   Java gave me the following error:
>
>
> Exception in thread "main" java.lang.NullPointerException
>      at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:94)
>      at com.hp.hpl.jena.sparql.util.NodeUtils$1.accept(NodeUtils.java:90)
>      at com.hp.hpl.jena.util.iterator.MapFilterIterator.hasNext(MapFilterIterator.java:55)
>
> I am using TDB.
>
> Could anyone help me figure that out ?
> Thanks in advance.

Hi,

I checked it works for me (Jena 2.10.1 development, TDB 0.10.1 development).

A way this can occur is a corrupted database by non-transactional use 
then exiting the JVM without sync'ing the database.

Which version are you running>

	Andy

>
> Site (Victor) Guo
>
>   		 	   		
>