com.hp.hpl.jena.graph.query
Class SimpleTripleSorter

java.lang.Object
  extended by com.hp.hpl.jena.graph.query.SimpleTripleSorter
All Implemented Interfaces:
TripleSorter

public class SimpleTripleSorter
extends java.lang.Object
implements TripleSorter

A TripleSorter for "optimising" queries. The triples of the query are permuted by moving the "lightest" triples to earlier positions. Within each region of the same lightness, triples the bind the most variables to their right are preferred. Otherwise the order is preserved.

The notion of "lightness" makes more concrete triples lighter than less concrete ones, and variables lighter than ANY. Variables that have been bound by the time their containing triple is processed weigh just a little.

The notion of "bind the most" is just the sum of occurances of the variables in the triple in the other triples.

No weighting is applied to predicate position, and no knowledge about the graph being queried is required.

Author:
kers

Field Summary
 
Fields inherited from interface com.hp.hpl.jena.graph.query.TripleSorter
dontSort
 
Constructor Summary
SimpleTripleSorter()
          A public SimpleTripleSorter needs no arguments (we imagine more sophisticated ones might).
 
Method Summary
 Triple[] sort(Triple[] ts)
          Sort the triple array so that more-bound triples come before less-bound triples.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTripleSorter

public SimpleTripleSorter()
A public SimpleTripleSorter needs no arguments (we imagine more sophisticated ones might).

Method Detail

sort

public Triple[] sort(Triple[] ts)
Sort the triple array so that more-bound triples come before less-bound triples. Preserve the order of the elements unless they have to move. Return a new permuted copy of the original array. The work is done by a new instance of SimpleTripleSorter specialised to this triple array (and with helpful state).

Specified by:
sort in interface TripleSorter


Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP