de.fuberlin.wiwiss.d2rq.algebra
Class RelationImpl

java.lang.Object
  extended by de.fuberlin.wiwiss.d2rq.algebra.Relation
      extended by de.fuberlin.wiwiss.d2rq.algebra.RelationImpl
All Implemented Interfaces:
RelationalOperators

public class RelationImpl
extends Relation


Field Summary
 
Fields inherited from class de.fuberlin.wiwiss.d2rq.algebra.Relation
EMPTY, NO_LIMIT, TRUE
 
Fields inherited from interface de.fuberlin.wiwiss.d2rq.algebra.RelationalOperators
DUMMY
 
Constructor Summary
RelationImpl(ConnectedDB database, AliasMap aliases, Expression condition, Expression softCondition, Set<Join> joinConditions, Set<ProjectionSpec> projections, boolean isUnique, List<OrderSpec> orderSpecs, int limit, int limitInverse)
           
 
Method Summary
 AliasMap aliases()
          The tables that are used to set up this relation, both in their aliased form, and with their original physical names.
 Expression condition()
          An expression that must be satisfied for all tuples in the relation.
 ConnectedDB database()
           
 boolean isUnique()
           
 Set<Join> joinConditions()
          Returns the join conditions that must hold between the tables in the relation.
 int limit()
          The limit clause for the SQL result set
 int limitInverse()
          The limit clause for the SQL result set describing the inverse relation
 List<OrderSpec> orderSpecs()
          The expressions (and ascending/descending flag) used for ordering the relation.
 Relation project(Set<? extends ProjectionSpec> projectionSpecs)
          Applies the projection operator to this relation.
 Set<ProjectionSpec> projections()
          The attributes or expressions that the relation is projected to.
 Relation renameColumns(ColumnRenamer renames)
          Applies the rename operator to this relation.
 Relation select(Expression selectCondition)
          Applies the selection operator to this relation.
 Expression softCondition()
          An expression satisfied by all tuples in the relation.
 String toString()
           
 
Methods inherited from class de.fuberlin.wiwiss.d2rq.algebra.Relation
allKnownAttributes, combineLimits, createSimpleRelation, isTrivial, tables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RelationImpl

public RelationImpl(ConnectedDB database,
                    AliasMap aliases,
                    Expression condition,
                    Expression softCondition,
                    Set<Join> joinConditions,
                    Set<ProjectionSpec> projections,
                    boolean isUnique,
                    List<OrderSpec> orderSpecs,
                    int limit,
                    int limitInverse)
Method Detail

database

public ConnectedDB database()
Specified by:
database in class Relation

aliases

public AliasMap aliases()
Description copied from class: Relation
The tables that are used to set up this relation, both in their aliased form, and with their original physical names.

Specified by:
aliases in class Relation
Returns:
All table aliases required by this relation

condition

public Expression condition()
Description copied from class: Relation
An expression that must be satisfied for all tuples in the relation.

Specified by:
condition in class Relation
Returns:
An expression; Expression.TRUE indicates no condition

softCondition

public Expression softCondition()
Description copied from class: Relation
An expression satisfied by all tuples in the relation. This is a necessary but not sufficient condition; it is descriptive and not prescriptive. Replacing the condition with Expression.TRUE does not change the contents of the relation. It is thus just an optional condition that can be used for optimization, but can be dropped or ignored if convenient. Typically, there is other Java code that ensures the condition regardless of whether it is present here or not. We use this in particular for adding IS NOT NULL constraints on all nullable columns that need to have a non-NULL value to form a triple or binding.

Specified by:
softCondition in class Relation
Returns:
An expression; Expression.TRUE indicates no soft condition

joinConditions

public Set<Join> joinConditions()
Description copied from class: Relation
Returns the join conditions that must hold between the tables in the relation.

Specified by:
joinConditions in class Relation
Returns:
A set of Joins

projections

public Set<ProjectionSpec> projections()
Description copied from class: Relation
The attributes or expressions that the relation is projected to.

Specified by:
projections in class Relation
Returns:
A set of ProjectionSpecs

isUnique

public boolean isUnique()
Specified by:
isUnique in class Relation

limit

public int limit()
Description copied from class: Relation
The limit clause for the SQL result set

Specified by:
limit in class Relation
Returns:
number of records to return

limitInverse

public int limitInverse()
Description copied from class: Relation
The limit clause for the SQL result set describing the inverse relation

Specified by:
limitInverse in class Relation
Returns:
number of records to return

orderSpecs

public List<OrderSpec> orderSpecs()
Description copied from class: Relation
The expressions (and ascending/descending flag) used for ordering the relation.

Specified by:
orderSpecs in class Relation

select

public Relation select(Expression selectCondition)
Description copied from interface: RelationalOperators

Applies the selection operator to this relation. The new relation will contain only the tuples for which the expression evaluates to true.

Selection on attributes that don't exist in the relation are considered to be always false and will cause an empty relation.

Parameters:
selectCondition - A boolean expression
Returns:
A relation whose tuples satisfy the condition

renameColumns

public Relation renameColumns(ColumnRenamer renames)
Description copied from interface: RelationalOperators

Applies the rename operator to this relation.

Renames of attributes that don't exist in the relation are ignored.

Parameters:
renames - A map from original to replacement names
Returns:
A relation in which all occurrences of the old names have been replaced with the new ones

project

public Relation project(Set<? extends ProjectionSpec> projectionSpecs)
Description copied from interface: RelationalOperators

Applies the projection operator to this relation.

The new relation will contain only the attributes given as the argument.

Parameters:
projectionSpecs - A set of ProjectionSpec instances
Returns:
A relation having the specified attributes

toString

public String toString()
Overrides:
toString in class Object