org.jrdf.query.relation.operation.mem.join.natural
Class NaturalJoinEngine

java.lang.Object
  extended by org.jrdf.query.relation.operation.mem.join.natural.NaturalJoinEngine
All Implemented Interfaces:
TupleEngine

public class NaturalJoinEngine
extends Object
implements TupleEngine

Combines two relations attributes if they have common tuple values. The same as AND in Algebra A.

The general algorithm is: 1. Find all matching attributes on two relations. 2. OuterUnionImpl the attributes and tuples together. 3. Remove any attributes that are not common between the two.

For example: Relation 1 has the following statements: <1, a, foo>, <1, b, bar>, <1, c, bar>, <1, c, baz> Relation 2 has the following statements: <2, b, foo>, <2, c, bar>, <2, f, bar>, <2, g, bar>, <2, c, baz>, <2, f, baz>

After process: <2, b, bar>, <2, c, bar>, <1, c, bar>, <1, f, bar>, <1, f, bar>, <2, c, baz>, <1, c, baz>, <1, f, baz> Removed: <2, a, foo>, <1, a, foo>


Constructor Summary
NaturalJoinEngine(TupleFactory tupleFactory, AttributeValuePairComparator avpComparator, RelationHelper relationHelper)
           
 
Method Summary
 SortedSet<Attribute> getHeading(Relation relation1, Relation relation2)
           
 void process(SortedSet<Attribute> headings, SortedSet<AttributeValuePair> avps1, SortedSet<AttributeValuePair> avps2, SortedSet<Tuple> result)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NaturalJoinEngine

public NaturalJoinEngine(TupleFactory tupleFactory,
                         AttributeValuePairComparator avpComparator,
                         RelationHelper relationHelper)
Method Detail

getHeading

public SortedSet<Attribute> getHeading(Relation relation1,
                                       Relation relation2)
Specified by:
getHeading in interface TupleEngine

process

public void process(SortedSet<Attribute> headings,
                    SortedSet<AttributeValuePair> avps1,
                    SortedSet<AttributeValuePair> avps2,
                    SortedSet<Tuple> result)
Specified by:
process in interface TupleEngine