|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fuberlin.wiwiss.d2rq.find.TripleQuery
Encapsulates a query for a triple. Three elements are necessary for
constructing a TripleQuery: a PropertyBridge
, a subject
node, and an object node. Both nodes may be wildcard nodes ({{Node.ANY}}).
The TripleQuery determines which database columns, database joins
and database conditions must be used to find the triple, and builds
Jena triples from SQL result rows. It also has logic to determine if
it can be combined with other TripleQuery instances into a single
SQL statement.
TODO: The logic for removing unnecessary joins is ugly and probably
the wrong place; especially getReplacedColumns()
seems awkward
History:
08-03-2004: Initial version of this class.
Field Summary | |
private java.lang.String |
aTable
|
private PropertyBridge |
bridge
|
private java.util.Map |
columnValues
|
private java.util.Set |
joins
|
private java.util.Set |
objectColumns
|
private NodeMaker |
objectMaker
|
private NodeMaker |
predicateMaker
|
private java.util.Map |
replacedColumns
|
private java.util.Set |
selectColumns
|
private java.util.Set |
subjectColumns
|
private NodeMaker |
subjectMaker
|
Constructor Summary | |
TripleQuery(PropertyBridge bridge,
com.hp.hpl.jena.graph.Node subject,
com.hp.hpl.jena.graph.Node predicate,
com.hp.hpl.jena.graph.Node object)
Constructs a new TripleQuery. |
Method Summary | |
private void |
eliminateColumns(Join join,
java.lang.String tableName)
If we have determined that a table can be dropped, then we have to rewrite all references to columns in that table to the columns on the other side of the join. |
private java.util.Set |
getAllJoinTables()
|
java.lang.String |
getATable()
Returns the name of an arbitrary database table that is accessed by this query. |
java.util.Map |
getColumnValues()
|
java.util.Set |
getConditions()
|
Database |
getDatabase()
|
java.util.Set |
getJoins()
|
NodeMaker |
getNodeMaker(int i)
|
PropertyBridge |
getPropertyBridge()
|
java.util.Map |
getReplacedColumns()
Returns a map from old Column s to new columns. |
java.util.Set |
getSelectColumns()
|
private Join |
getSingleJoinReferencingTable(java.lang.String table)
Gets a join that references a table, but only if there is exactly one join that references that table. |
boolean |
isCombinable(TripleQuery other)
Checks if an other query can be combined with this one into a single SQL statement. |
private boolean |
isOptionalTable(java.lang.String table,
Join join)
Checks if a table can be dropped. |
com.hp.hpl.jena.graph.Triple |
makeTriple(java.lang.String[] row,
java.util.Map columnNameNumberMap)
Creates a triple from a database result row. |
boolean |
mightContainDuplicates()
|
private void |
removeOptionalJoins()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private PropertyBridge bridge
private java.util.Set joins
private java.util.Map columnValues
private java.util.Set selectColumns
private java.lang.String aTable
private java.util.Set subjectColumns
private java.util.Set objectColumns
private NodeMaker subjectMaker
private NodeMaker predicateMaker
private NodeMaker objectMaker
private java.util.Map replacedColumns
Constructor Detail |
public TripleQuery(PropertyBridge bridge, com.hp.hpl.jena.graph.Node subject, com.hp.hpl.jena.graph.Node predicate, com.hp.hpl.jena.graph.Node object)
bridge
- We look for triples matching this property bridgesubject
- the subject node, may be {{Node.ANY}}object
- the object node, may be {{Node.ANY}}Method Detail |
public NodeMaker getNodeMaker(int i)
public PropertyBridge getPropertyBridge()
public java.util.Set getJoins()
public java.util.Set getConditions()
public java.util.Map getColumnValues()
public java.util.Set getSelectColumns()
public Database getDatabase()
public boolean mightContainDuplicates()
public java.lang.String getATable()
public boolean isCombinable(TripleQuery other)
other
- a query to be compared with this one
public java.util.Map getReplacedColumns()
Column
s to new columns. The makeTriple(java.lang.String[], java.util.Map)
method expects to find the old column names in the
columnNameNumberMap, but the new columns are returned by
the getSelectColumns()
methods. Clients of this class
must account for this when creating the columnNameNumberMap.
public com.hp.hpl.jena.graph.Triple makeTriple(java.lang.String[] row, java.util.Map columnNameNumberMap)
row
- a database result rowcolumnNameNumberMap
- a map from column names to Integer indices into the row array
private void removeOptionalJoins()
private java.util.Set getAllJoinTables()
private Join getSingleJoinReferencingTable(java.lang.String table)
private boolean isOptionalTable(java.lang.String table, Join join)
table
- a table namejoin
- the only join referencing this table
private void eliminateColumns(Join join, java.lang.String tableName)
join
- tableName
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |