Java Doc for MergeSort.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » access » sort » 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 » Database DBMS » db derby 10.2 » org.apache.derby.impl.store.access.sort 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.derby.impl.store.access.sort.MergeSort

MergeSort
final public class MergeSort implements Sort(Code)
A sort implementation which does the sort in-memory if it can, but which can do an external merge sort so that it can sort an arbitrary number of rows.


Field Summary
final static  intSTATE_CLOSED
    
final static  intSTATE_DONE_INSERTING
    
final static  intSTATE_DONE_SCANNING
    
final static  intSTATE_INITIALIZED
    
final static  intSTATE_INSERTING
    
final static  intSTATE_SCANNING
    
protected  booleanalreadyInOrder
     Whether the rows are expected to be in order on insert, as passed in on create.
protected  ColumnOrderingcolumnOrdering
     The column ordering as passed in on create.
protected  booleancolumnOrderingAscendingMap
    
protected  intcolumnOrderingMap
     A lookup table to speed up lookup of a column associated with the i'th column to compare.
protected  MergeInserterinserter
     The inserter that's being used to insert rows into the sort.
protected  VectormergeRuns
     A vector of merge runs, produced by the MergeInserter.
static  Propertiesproperties
    
protected  Scanscan
     The scan that's being used to return rows from the sort.
protected  SortBuffersortBuffer
     An ordered set of the leftover rows that didn't go in the last merge run (might be all the rows if there are no merge runs).
protected  intsortBufferMax
     The maximum number of entries a sort buffer can hold.
protected  intsortBufferMin
     The minimum number of entries a sort buffer can hold.
protected  SortObserversortObserver
     The sort observer.
protected  intstate
     Maintains the current state of the sort as defined in the preceding values.
protected  DataValueDescriptor[]template
     The template as passed in on create.


Method Summary
protected  booleancheckColumnOrdering(DataValueDescriptor[] template, ColumnOrdering columnOrdering)
     Check the column ordering against the template, making sure that each column is present in the template, implements Orderable, and is not mentioned more than once.
 voidcheckColumnTypes(DataValueDescriptor[] row)
     Check that the columns in the row agree with the columns in the template, both in number and in type.
 intcompare(DataValueDescriptor[] r1, DataValueDescriptor[] r2)
    
 longcreateMergeRun(TransactionManager tran, SortBuffer sortBuffer)
     Remove all the rows from the sort buffer and store them in a temporary conglomerate.
 voiddoneInserting(MergeInserter inserter, SortBuffer sortBuffer, Vector mergeRuns)
     An inserter is closing.
 voiddoneScanning(Scan scan, SortBuffer sortBuffer)
    
 voiddoneScanning(Scan scan, SortBuffer sortBuffer, Vector mergeRuns)
    
public  voiddrop(TransactionController tran)
     Drop the sort.
 voiddropMergeRuns(TransactionManager tran)
     Get rid of the merge runs, if there are any.
public  voidinitialize(DataValueDescriptor[] template, ColumnOrdering columnOrdering, SortObserver sortObserver, boolean alreadyInOrder, long estimatedRows, int sortBufferMax)
     Go from the CLOSED to the INITIALIZED state.
public  SortControlleropen(TransactionManager tran)
     Open a sort controller.
public  ScanControllerRowSourceopenSortRowSource(TransactionManager tran)
     Open a row source to get rows out of the sorter.
public  ScanControlleropenSortScan(TransactionManager tran, boolean hold)
     Open a scan controller.

Field Detail
STATE_CLOSED
final static int STATE_CLOSED(Code)



STATE_DONE_INSERTING
final static int STATE_DONE_INSERTING(Code)



STATE_DONE_SCANNING
final static int STATE_DONE_SCANNING(Code)



STATE_INITIALIZED
final static int STATE_INITIALIZED(Code)



STATE_INSERTING
final static int STATE_INSERTING(Code)



STATE_SCANNING
final static int STATE_SCANNING(Code)



alreadyInOrder
protected boolean alreadyInOrder(Code)
Whether the rows are expected to be in order on insert, as passed in on create.



columnOrdering
protected ColumnOrdering columnOrdering(Code)
The column ordering as passed in on create. Valid when the state is INITIALIZED through SCANNING, null otherwise. May be null if there is no column ordering - this means that all rows are considered to be duplicates, and the sort will only emit a single row.



columnOrderingAscendingMap
protected boolean columnOrderingAscendingMap(Code)
A lookup table to speed up lookup of Ascending state of a column,



columnOrderingMap
protected int columnOrderingMap(Code)
A lookup table to speed up lookup of a column associated with the i'th column to compare. To find the column id to compare as the i'th column look in columnOrderingMap[i].



inserter
protected MergeInserter inserter(Code)
The inserter that's being used to insert rows into the sort. This field is only valid when the state is INSERTING.



mergeRuns
protected Vector mergeRuns(Code)
A vector of merge runs, produced by the MergeInserter. Might be null if no merge runs were produced. It is a vector of container ids.



properties
static Properties properties(Code)
Properties for mergeSort



scan
protected Scan scan(Code)
The scan that's being used to return rows from the sort. This field is only valid when the state is SCANNING.



sortBuffer
protected SortBuffer sortBuffer(Code)
An ordered set of the leftover rows that didn't go in the last merge run (might be all the rows if there are no merge runs).



sortBufferMax
protected int sortBufferMax(Code)
The maximum number of entries a sort buffer can hold.



sortBufferMin
protected int sortBufferMin(Code)
The minimum number of entries a sort buffer can hold.



sortObserver
protected SortObserver sortObserver(Code)
The sort observer. May be null. Used as a callback.



state
protected int state(Code)
Maintains the current state of the sort as defined in the preceding values. Sorts start off and end up closed.



template
protected DataValueDescriptor[] template(Code)
The template as passed in on create. Valid when the state is INITIALIZED through SCANNING, null otherwise.





Method Detail
checkColumnOrdering
protected boolean checkColumnOrdering(DataValueDescriptor[] template, ColumnOrdering columnOrdering)(Code)
Check the column ordering against the template, making sure that each column is present in the template, implements Orderable, and is not mentioned more than once. Intended to be called as part of a sanity check.



checkColumnTypes
void checkColumnTypes(DataValueDescriptor[] row) throws StandardException(Code)
Check that the columns in the row agree with the columns in the template, both in number and in type.

XXX (nat) Currently checks that the classes implementing each column are the same -- is this right?




compare
int compare(DataValueDescriptor[] r1, DataValueDescriptor[] r2) throws StandardException(Code)



createMergeRun
long createMergeRun(TransactionManager tran, SortBuffer sortBuffer) throws StandardException(Code)
Remove all the rows from the sort buffer and store them in a temporary conglomerate. The temporary conglomerate is a "merge run". Returns the container id of the merge run.



doneInserting
void doneInserting(MergeInserter inserter, SortBuffer sortBuffer, Vector mergeRuns)(Code)
An inserter is closing.



doneScanning
void doneScanning(Scan scan, SortBuffer sortBuffer)(Code)



doneScanning
void doneScanning(Scan scan, SortBuffer sortBuffer, Vector mergeRuns)(Code)



drop
public void drop(TransactionController tran) throws StandardException(Code)
Drop the sort.
See Also:   Sort.drop



dropMergeRuns
void dropMergeRuns(TransactionManager tran)(Code)
Get rid of the merge runs, if there are any. Must not cause any errors because it's called during error processing.



initialize
public void initialize(DataValueDescriptor[] template, ColumnOrdering columnOrdering, SortObserver sortObserver, boolean alreadyInOrder, long estimatedRows, int sortBufferMax) throws StandardException(Code)
Go from the CLOSED to the INITIALIZED state.



open
public SortController open(TransactionManager tran) throws StandardException(Code)
Open a sort controller.

This implementation only supports a single sort controller per sort.
See Also:   Sort.open




openSortRowSource
public ScanControllerRowSource openSortRowSource(TransactionManager tran) throws StandardException(Code)
Open a row source to get rows out of the sorter.
See Also:   Sort.openSortRowSource



openSortScan
public ScanController openSortScan(TransactionManager tran, boolean hold) throws StandardException(Code)
Open a scan controller.
See Also:   Sort.openSortScan



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)

w_w___w_.__j_a__v_a2___s__.c_o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.