One way woudl be to directly add the data into TDB rather than into an
in-memory model, then copy that model into TDB.  That reduces the
numbers of copies by one.  So start the transaction at the top and
where you have getRdfModel(), use the TDL model.

getNamedmodel does not load the data into memory.

.add(...); causes the transaction mechanism to use memory.



On 6 May 2014 09:55, Rob Vesse <rve...@dotnetrdf.org> wrote:
> Use the asDatasetGraph() method to get a lower level view of the dataset -
> https://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/sparql/co
> re/DatasetGraph.html
>
> You can then use one of the add() methods to insert the data.
>
> If the data is to be appended to the existing graph then you need to use
> the add(Quad) or the add(Node, Node, Node, Node) method.  If the data is
> to replace the existing named graph you can use the addGraph(Node, Graph)
> method instead.
>
> Rob
>
> On 06/05/2014 03:10, "Ganesh kumar" <ganeshkumar1...@gmail.com> wrote:
>
>>Hi All,
>>
>>I am trying to insert triples into Jena TDB (triples are added into simple
>>models and then inserted).
>>The models are built at runtime for a particular group of triples, and
>>then
>>it needs to be persisted into Jena TDB.
>>
>>
>>Pseudocode:
>>
>>Resource node = getRdfModel().createResource(nodeStr);
>>
>>for (Entry<String, Object> entry : attributes.entrySet()) {
>>String attributeName = entry.getKey();
>>
>>attributeName = processAttributes(attributeName);
>>propertyStr = buildURI(attributeName, source, elementType.property,
>>nodeStr);
>>String val = processValue(entry);
>>
>>node.addProperty(getRdfModel().createProperty(propertyStr),
>>getRdfModel().createLiteral(val));
>>}
>> dataset.begin(ReadWrite.WRITE);
>>try {
>>
>>// TODO: This insert is not really effecient. The getnamed model loads the
>>data from the TDB into memory which is making the insert slow. Is there a
>>effecient way of inserting the data to TDB like a cursor with less memory
>>usage ?
>>                       dataset.getNamedModel(source).add(getRdfModel());
>>dataset.commit();
>>//After commit the getRDFModel() will be reseted.
>>
>>} finally {
>>dataset.end();
>>}
>>
>>Problem:
>>
>>When I call the getNamedmodel function, it loads the data from TDB which
>>is
>>quite large. Is there a way to insert the data without loading the data
>>into main memory ?
>>
>>or any other effecient way of inserting data using Jena api?
>>This is a data migration study project, so more data will keep flowing in.
>>
>>
>>Thanks in advance for your help & guidance.
>>
>>Thanks
>>Ganesh
>
>
>
>

Reply via email to