thanks Andy and Rob.
I was able to store the NQuads file inside the TDB. below is my code:
String directory = "/Users/adeebnoor/Downloads/new";
Dataset dataset = TDBFactory.createDataset(directory);
String source = "/Users/adeebnoor/Downloads/relationships.nq";
RDFDataMgr.read(dataset, source) ;
However, I still got zero result of my SPARQL:
String q = "SELECT ?s { ?s ?r ?o . } limit 10" ;
Query query = QueryFactory.create(q);
QueryExecution run = QueryExecutionFactory.create(query, dataset);
ResultSet results = run.execSelect();
ResultSetFormatter.out(System.out, results, query);
run.close();
dataset.close();
What should I do ?
Thanks
On Tue, Jan 21, 2014 at 12:52 PM, Rob Vesse <[email protected]> wrote:
> The code you are using only reads the default graph as the warning message
> implies
>
> If you wish to read quad formats use the newer RDFDataMgr APIs instead
> (see http://jena.apache.org/documentation/io/rdf-input.html for an
> overview), specifically for your case you want to do the following:
>
> RDFDataMgr.read(dataset, source);
>
> Your code is only a fragment but if you aren't already I suggest using the
> TDB transaction APIs
> (http://jena.apache.org/documentation/tdb/tdb_transactions.html) to wrap
> this operation in a write transaction remembering to commit() after the
> read() call.
>
> Rob
>
> On 21/01/2014 11:13, "Adeeb Noor" <[email protected]> wrote:
>
> >I have a NQuads file that I want to store it inside the tdb. Here is the
> >code:
> >
> >String directory =
> >"/Users/adeebnoor/Documents/uploadDatasets/dataSetsTDB/new";
> >
> > Dataset dataset = TDBFactory.createDataset(directory);
> >
> >Model tdb = dataset.getDefaultModel();
> >
> > String source =
> >"/Users/adeebnoor/Documents/uploadDatasets/dataSource/drugbank_target_ids.
> >nq"
> >;
> >
> > FileManager.get().readModel(tdb, source);
> >
> > System.out.println("Done");
> >when I run the code above , I got this warning:
> >
> >12:05:58 WARN riot :: Only triples or default graph
> >data expected : named graph data ignored
> >
> >and when I tried to query the tdb, the result is empty.
> >
> >Am I doing something wrong here ? or is there another way to handle
> >the NQuads format.
> >
> >thanks
> >
> >--
> >Adeeb Noor
> >Ph.D. Candidate
> >Dept of Computer Science
> >University of Colorado at Boulder
> >Cell: 571-484-3303
> >Email: [email protected]
>
>
>
>
>
--
Adeeb Noor
Ph.D. Candidate
Dept of Computer Science
University of Colorado at Boulder
Cell: 571-484-3303
Email: [email protected]