You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Martynas Jusevičius <ma...@atomgraph.com> on 2021/02/17 18:02:06 UTC

Dataset::append method?

Hi,

how does one append one Dataset to another? I know I can do stuff like

d2.getDefaultModel().add(d1.getDefaultModel());
for (String name : d1.listNames())
    d2 = d2.addNamedModel(d1.getNamedModel(name));

but that is not very concise, and probably not very performant either?
I'm wondering why there isn't a dedicated method?


Martynas

Re: Dataset::append method?

Posted by Andy Seaborne <an...@apache.org>.

On 18/02/2021 18:17, Martynas Jusevičius wrote:
>>> I'm wondering why there isn't a dedicated method?
>>
>> Use case?
> 
> * collecting multiple Datasets into one (merging quads)
> * having a consistent API
> 
> What I'm thinking is a method for quads which corresponds to
> Model::add for triples. In that case it should be called Dataset::add,
> for consistency.

 
ds1.asDatasetGraph().find().forEachRemaining(ds2.asDatasetGraph()::add);

or for a more compact format:

import ...Iter

forEach(ds1.asDatasetGraph().find(),
         ds2.asDatasetGraph()::add);


> 
> Or is the quad-case more complicated than triples?

See previous email.

> 
>>
>>>
>>>
>>> Martynas
>>>

Re: Dataset::append method?

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
In other words -- if we can do

model1.add(model2)

per https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Model.html#add-org.apache.jena.rdf.model.Model-

why can't we do

dataset1.add(dataset2)

?

On Thu, Feb 18, 2021 at 7:17 PM Martynas Jusevičius
<ma...@atomgraph.com> wrote:
>
> > > I'm wondering why there isn't a dedicated method?
> >
> > Use case?
>
> * collecting multiple Datasets into one (merging quads)
> * having a consistent API
>
> What I'm thinking is a method for quads which corresponds to
> Model::add for triples. In that case it should be called Dataset::add,
> for consistency.
>
> Or is the quad-case more complicated than triples?
>
> >
> > >
> > >
> > > Martynas
> > >

Re: Dataset::append method?

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
> > I'm wondering why there isn't a dedicated method?
>
> Use case?

* collecting multiple Datasets into one (merging quads)
* having a consistent API

What I'm thinking is a method for quads which corresponds to
Model::add for triples. In that case it should be called Dataset::add,
for consistency.

Or is the quad-case more complicated than triples?

>
> >
> >
> > Martynas
> >

Re: Dataset::append method?

Posted by Andy Seaborne <an...@apache.org>.

On 17/02/2021 18:02, Martynas Jusevičius wrote:
> Hi,
> 
> how does one append one Dataset to another? I know I can do stuff like
> 
> d2.getDefaultModel().add(d1.getDefaultModel());
> for (String name : d1.listNames())
>      d2 = d2.addNamedModel(d1.getNamedModel(name));
> 
> but that is not very concise, and probably not very performant either?

Doesn't look too bad. Maybe if there are huge numbers of very small 
graph e.g. one triple. There is no term copying, only datastructure changes.

Of course, if the datasets share graphs then it gets "interesting".


> I'm wondering why there isn't a dedicated method?

Use case?

> 
> 
> Martynas
>