Java Doc for SimpleTripleSorter.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » graph » query » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.graph.query 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.hp.hpl.jena.graph.query.SimpleTripleSorter

SimpleTripleSorter
public class SimpleTripleSorter implements TripleSorter(Code)
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




Constructor Summary
public  SimpleTripleSorter()
     A public SimpleTripleSorter needs no arguments (we imagine more sophisticated ones might).
protected  SimpleTripleSorter(Triple[] triples)
     Initialise a working SimpleTripleSorter from the triple array to sort.

Method Summary
protected  voidaccept(Triple t)
     Accept a triple as the next element in the result array, note that all its variables are now bound, and remove it from the list of remaining triples.
protected  intbc(Node n, Node other)
     Answer 1 if nodes are .equals, 0 otherwise.
protected  voidbind(Triple t)
     Bind a triple by binding each of its nodes.
protected  voidbind(Node n)
    
protected  intbindingCount(Triple t)
     The binding count of a triple is the number of instances of variables in other triples it would capture if it were to be bound.
protected  intbindingCount(Triple t, Triple other)
    
protected  intbindingCount(Node n, Triple o)
    
protected  ListfindLightest(List candidates)
     Answer a list of the lightest triples in the candidate list; takes one pass over the candidates.
protected  TriplefindMostBinding(List candidates)
     Answer the first most-binding triple in the list of candidates.
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.
protected  Triple[]sort()
     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.
protected  intweight(Triple t)
     In this simple sorter, the weight of a triple is the sum of the weights of its nodes. None of the positions get weighted differently.
protected  intweight(Node n)
     In this simple sorter, concrete nodes weigh nothing.


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



SimpleTripleSorter
protected SimpleTripleSorter(Triple[] triples)(Code)
Initialise a working SimpleTripleSorter from the triple array to sort. The working copy has an empty set of bound variables and a mutable (and mutated) list of the original triple array, in the same order.




Method Detail
accept
protected void accept(Triple t)(Code)
Accept a triple as the next element in the result array, note that all its variables are now bound, and remove it from the list of remaining triples.



bc
protected int bc(Node n, Node other)(Code)
Answer 1 if nodes are .equals, 0 otherwise.



bind
protected void bind(Triple t)(Code)
Bind a triple by binding each of its nodes.



bind
protected void bind(Node n)(Code)



bindingCount
protected int bindingCount(Triple t)(Code)
The binding count of a triple is the number of instances of variables in other triples it would capture if it were to be bound.
Parameters:
  t - the triple to compute the binding count for the total binding count of t with respect to all the triples in remaining



bindingCount
protected int bindingCount(Triple t, Triple other)(Code)
Answer the binding count of t with respect to some other triple



bindingCount
protected int bindingCount(Node n, Triple o)(Code)



findLightest
protected List findLightest(List candidates)(Code)
Answer a list of the lightest triples in the candidate list; takes one pass over the candidates.
Parameters:
  candidates - the list of triples to select from the light of lightest triples [by weight], preserving order



findMostBinding
protected Triple findMostBinding(List candidates)(Code)
Answer the first most-binding triple in the list of candidates.



sort
public Triple[] sort(Triple[] ts)(Code)
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).



sort
protected Triple[] sort()(Code)
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.

The algorithm just repeatedly looks for a lightest triple, moves it into the result array, and re-weighs triples in the light of the new bindings that makes. Of several lightest triples, the first is picked [mostly so that it's easier to write the tests].




weight
protected int weight(Triple t)(Code)
In this simple sorter, the weight of a triple is the sum of the weights of its nodes. None of the positions get weighted differently. One might choose to weigh positions that were more search-intensive more heavily.
Parameters:
  t - the triple to be weighed [with respect to the bound variables] the weight of the triple, rising as the triple is more variable



weight
protected int weight(Node n)(Code)
In this simple sorter, concrete nodes weigh nothing. [This is, after all, computing rather than building.] ANYs cost the most, because they cannot be bound, and variable nodes cost a little if they are bound and a lot if they are not.

The rules are

  • any concrete node weighs nothing
  • a bound variable node weighs something, but a triple which is three bound variables must weigh less than a triple with an unbound variable
  • an ANY node weighs more than an unbound variable node but less than two unbound variable nodes

Parameters:
  n - the node to be weighed [with respect to the bound variables] the weight of the node



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.