You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Qiaser Mehmood <qm...@yahoo.com.INVALID> on 2014/09/22 03:39:00 UTC

Merge two OpBGP values jena

Could any one please guide me to concat or merge  OpBGP class objects values 

Let's say 

opBGP1= (bgp (triple ?drugbankDrug <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/structure> ?structure))

opBGP2= (bgp (triple ?drugbankDrug <http://www4.wiwiss.fu-berlin.de/drugbank/resource/smilesStringCanonical/structure> ?smlCon))

Op op= opBGP1+opBGP2

OR

Op op1=opBGP1
Op op2= opBGP2

Op op3= op1+op2
 

Thanks,

Re: Merge two OpBGP values jena

Posted by Claude Warren <cl...@xenei.com>.
It depends on what you mean by merge.

you could create a new BGP with both triples (that would be a logical and),
you could create a join of the 2 bgps
you could union the 2 bbps
you could wrap one of the BGP in an Optional and then do the union or join
you could wrap the both BGP in Opional and then do the union or join

Depends on what you are trying to achieve.

Claude

On Mon, Sep 22, 2014 at 2:39 AM, Qiaser Mehmood <qm...@yahoo.com.invalid>
wrote:

> Could any one please guide me to concat or merge  OpBGP class objects
> values
>
> Let's say
>
> opBGP1= (bgp (triple ?drugbankDrug <
> http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/structure>
> ?structure))
>
> opBGP2= (bgp (triple ?drugbankDrug <
> http://www4.wiwiss.fu-berlin.de/drugbank/resource/smilesStringCanonical/structure>
> ?smlCon))
>
> Op op= opBGP1+opBGP2
>
> OR
>
> Op op1=opBGP1
> Op op2= opBGP2
>
> Op op3= op1+op2
>
>
> Thanks,




-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Re: Merge two OpBGP values jena

Posted by Andy Seaborne <an...@apache.org>.
Create a new combined basic pattern.

It is much better to regard Ops as immutable once built because they get 
put in datastructures (where .equals matters)

So if op1 and op2 are already in some datastructure somewhere:

     BasicPattern bp3 = new BasicPattern() ;
     bp3.addAll(op1.getPattern()) ;
     bp3.addAll(op2.getPattern()) ;
     OpBGP op3 = new OpBGP(bp3) ;

	Andy

On 22/09/14 02:39, Qiaser Mehmood wrote:
> Could any one please guide me to concat or merge  OpBGP class objects values
>
> Let's say
>
> opBGP1= (bgp (triple ?drugbankDrug <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/structure> ?structure))
>
> opBGP2= (bgp (triple ?drugbankDrug <http://www4.wiwiss.fu-berlin.de/drugbank/resource/smilesStringCanonical/structure> ?smlCon))
>
> Op op= opBGP1+opBGP2
>
> OR
>
> Op op1=opBGP1
> Op op2= opBGP2
>
> Op op3= op1+op2
>
>
> Thanks,
>


Re: Merge two OpBGP values jena

Posted by Rob Vesse <rv...@dotnetrdf.org>.
You can use TransformMergeBGPs
(https://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/sparql/a
lgebra/optimize/TransformMergeBGPs.html)

e.g.

Op join = OpJoin.create(opBGP1, opBGP2);
join = Transformer.transform(join, new TransformMergeBGPs());

Or you can do it manually by simply constructing a new OpBGP

BasicPattern bp = new BasicPattern();
bp.addAll(opBGP1.getPattern());
bp.addAll(opBGP2.getPattern());
Op op = new OpBGP(bp);

Hope this helps,

Rob

On 22/09/2014 02:39, "Qiaser Mehmood" <qm...@yahoo.com.INVALID> wrote:

>Could any one please guide me to concat or merge  OpBGP class objects
>values 
>
>Let's say 
>
>opBGP1= (bgp (triple ?drugbankDrug
><http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/structure>
>?structure))
>
>opBGP2= (bgp (triple ?drugbankDrug
><http://www4.wiwiss.fu-berlin.de/drugbank/resource/smilesStringCanonical/s
>tructure> ?smlCon))
>
>Op op= opBGP1+opBGP2
>
>OR
>
>Op op1=opBGP1
>Op op2= opBGP2
>
>Op op3= op1+op2
> 
>
>Thanks,