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


java.lang.Object
   org.apache.derby.impl.store.access.btree.OpenBTree
      org.apache.derby.impl.store.access.btree.BTreeCostController

All known Subclasses:   org.apache.derby.impl.store.access.btree.index.B2ICostController,
BTreeCostController
public class BTreeCostController extends OpenBTree implements StoreCostController(Code)
The StoreCostController interface provides methods that an access client (most likely the system optimizer) can use to get store's estimated cost of various operations on the conglomerate the StoreCostController was opened for.

It is likely that the implementation of StoreCostController will open the conglomerate and will leave the conglomerate open until the StoreCostController is closed. This represents a significant amount of work, so the caller if possible should attempt to open the StoreCostController once per unit of work and rather than close and reopen the controller. For instance if the optimizer needs to cost 2 different scans against a single conglomerate, it should use one instance of the StoreCostController.

The locking behavior of the implementation of a StoreCostController is undefined, it may or may not get locks on the underlying conglomerate. It may or may not hold locks until end of transaction. An optimal implementation will not get any locks on the underlying conglomerate, thus allowing concurrent access to the table by a executing query while another query is optimizing.


See Also:   TransactionController.openStoreCost



Field Summary
 Conglomerateinit_conglomerate
    
 Transactioninit_rawtran
    
 TransactionManagerinit_xact_manager
    
 longnum_pages
     Only lookup these estimates from raw store once.
 longnum_rows
    
 longpage_size
    
 inttree_height
    

Constructor Summary
public  BTreeCostController()
    

Method Summary
public  voidclose()
     Close the controller.

Close the open controller.

public  doublegetFetchFromFullKeyCost(FormatableBitSet validColumns, int access_type)
     Return the cost of exact key lookup.

Return the estimated cost of calling ScanController.fetch() on the current conglomerate, with start and stop positions set such that an exact match is expected.

This call returns the cost of a fetchNext() performed on a scan which has been positioned with a start position which specifies exact match on all keys in the row.

Example:

In the case of a btree this call can be used to determine the cost of doing an exact probe into btree, giving all key columns.

public  doublegetFetchFromRowLocationCost(FormatableBitSet validColumns, int access_type)
     Return the cost of calling ConglomerateController.fetch().

Return the estimated cost of calling ConglomerateController.fetch() on the current conglomerate.

public  voidgetScanCost(int scan_type, long row_count, int group_size, boolean forUpdate, FormatableBitSet scanColumnList, DataValueDescriptor[] template, DataValueDescriptor[] startKeyValue, int startSearchOperator, DataValueDescriptor[] stopKeyValue, int stopSearchOperator, boolean reopen_scan, int access_type, StoreCostResult cost_result)
     Calculate the cost of a scan.

Cause this object to calculate the cost of performing the described scan.

public  voidinit(TransactionManager xact_manager, BTree conglomerate, Transaction rawtran)
     Initialize the cost controller.
public  RowLocationnewRowLocationTemplate()
     Return an "empty" row location object of the correct type.

Field Detail
init_conglomerate
Conglomerate init_conglomerate(Code)



init_rawtran
Transaction init_rawtran(Code)



init_xact_manager
TransactionManager init_xact_manager(Code)



num_pages
long num_pages(Code)
Only lookup these estimates from raw store once.



num_rows
long num_rows(Code)



page_size
long page_size(Code)



tree_height
int tree_height(Code)




Constructor Detail
BTreeCostController
public BTreeCostController()(Code)




Method Detail
close
public void close() throws StandardException(Code)
Close the controller.

Close the open controller. This method always succeeds, and never throws any exceptions. Callers must not use the StoreCostController Cost controller after closing it; they are strongly advised to clear out the scan controller reference after closing.




getFetchFromFullKeyCost
public double getFetchFromFullKeyCost(FormatableBitSet validColumns, int access_type) throws StandardException(Code)
Return the cost of exact key lookup.

Return the estimated cost of calling ScanController.fetch() on the current conglomerate, with start and stop positions set such that an exact match is expected.

This call returns the cost of a fetchNext() performed on a scan which has been positioned with a start position which specifies exact match on all keys in the row.

Example:

In the case of a btree this call can be used to determine the cost of doing an exact probe into btree, giving all key columns. This cost can be used if the client knows it will be doing an exact key probe but does not have the key's at optimize time to use to make a call to getScanCost()


Parameters:
  validColumns - A description of which columns to return fromrow on the page into "templateRow." templateRow,and validColumns work together todescribe the row to be returned by the fetch - see RowUtil for description of how these three parameters work together to describe a fetched "row".
Parameters:
  access_type - Describe the type of access the query will beperforming to the ScanController. STORECOST_CLUSTERED - The location of one scanis likely clustered "close" to the previous scan. For instance if the query plan wereto used repeated "reopenScan()'s" to probefor the next key in an index, then this flagshould be be specified. If this flag is not set then each scan will be costed independantof any other predicted scan access. The cost of the fetch.
exception:
  StandardException - Standard exception policy.
See Also:   RowUtil




getFetchFromRowLocationCost
public double getFetchFromRowLocationCost(FormatableBitSet validColumns, int access_type) throws StandardException(Code)
Return the cost of calling ConglomerateController.fetch().

Return the estimated cost of calling ConglomerateController.fetch() on the current conglomerate. This gives the cost of finding a record in the conglomerate given the exact RowLocation of the record in question.

The validColumns parameter describes what kind of row is being fetched, ie. it may be cheaper to fetch a partial row than a complete row.


Parameters:
  validColumns - A description of which columns to return fromrow on the page into "templateRow." templateRow,and validColumns work together todescribe the row to be returned by the fetch - see RowUtil for description of how these three parameters work together to describe a fetched "row".
Parameters:
  access_type - Describe the type of access the query will beperforming to the ConglomerateController. STORECOST_CLUSTERED - The location of one fetchis likely clustered "close" to the next fetch. For instance if the query plan wereto sort the RowLocations of a heap and thenuse those RowLocations sequentially to probe into the heap, then this flag shouldbe specified. If this flag is not set thenaccess to the table is assumed to berandom - ie. the type of access one gets if you scan an index and probe each rowin turn into the base table is "random". The cost of the fetch.
exception:
  StandardException - Standard exception policy.
See Also:   RowUtil




getScanCost
public void getScanCost(int scan_type, long row_count, int group_size, boolean forUpdate, FormatableBitSet scanColumnList, DataValueDescriptor[] template, DataValueDescriptor[] startKeyValue, int startSearchOperator, DataValueDescriptor[] stopKeyValue, int stopSearchOperator, boolean reopen_scan, int access_type, StoreCostResult cost_result) throws StandardException(Code)
Calculate the cost of a scan.

Cause this object to calculate the cost of performing the described scan. The interface is setup such that first a call is made to calcualteScanCost(), and then subsequent calls to accessor routines are made to get various pieces of information about the cost of the scan.

For the purposes of costing this routine is going to assume that a page will remain in cache between the time one next()/fetchNext() call and a subsequent next()/fetchNext() call is made within a scan.

The result of costing the scan is placed in the "cost_result". The cost of the scan is stored by calling cost_result.setEstimatedCost(cost). The estimated row count is stored by calling cost_result.setEstimatedRowCount(row_count).

The estimated cost of the scan assumes the caller will execute a fetchNext() loop for every row that qualifies between start and stop position. Note that this cost is different than execution a next(),fetch() loop; or if the scan is going to be terminated by client prior to reaching the stop condition.

The estimated number of rows returned from the scan assumes the caller will execute a fetchNext() loop for every row that qualifies between start and stop position.


Parameters:
  scan_type - The type of scan that will be executed. Thereare currently 2 types:STORECOST_SCAN_NORMAL - scans will be executedusing the standard next/fetch, where each fetchcan retrieve 1 or many rows (if fetchNextGroup()interface is used).STORECOST_SCAN_SET - The entire result set willbe retrieved using the the fetchSet() interface.
Parameters:
  row_count - Estimated total row count of the table. The current system tracks row counts in heaps betterthan btree's (btree's have "rows" which are notuser rows - branch rows, control rows), so if available the client shouldpass in the base table's row count into thisroutine to be used as the index's row count.If the caller has no idea, pass in -1.
Parameters:
  group_size - The number of rows to be returned by a singlefetch call for STORECOST_SCAN_NORMAL scans.
Parameters:
  forUpdate - Should be true if the caller intends to update through the scan.
Parameters:
  scanColumnList - A description of which columns to return from every fetch in the scan. template, and scanColumnList work togetherto describe the row to be returned by the scan - see RowUtil for description of how these three parameters work together to describe a "row".
Parameters:
  template - A prototypical row which the scan may use tomaintain its position in the conglomerate. Not all access method scan types will require this, if they don't it's ok to pass in null.In order to scan a conglomerate one must allocate 2 separate "row" templates. The "row" template passed into openScan is for the privateuse of the scan itself, and no access to itshould be made by the caller while the scan is still open. Because of this the scanner must allocate another "row" template to hold the values returned from fetch(). Note that this template must be for the full row, whether a partial row scan is being executed or not.
Parameters:
  startKeyValue - An indexable row which holds a (partial) key value which, in combination with the startSearchOperator, defines the starting position of the scan. If null, the startingposition of the scan is the first row of the conglomerate. The startKeyValue must onlyreference columns included in the scanColumnList.
Parameters:
  startSearchOperator - an operator which defines how the startKeyValueis to be searched for. If startSearchOperation is ScanController.GE, the scan starts on the first row which is greater than or equal to the startKeyValue. If startSearchOperation is ScanController.GT, the scan starts on the firstrow whose key is greater than startKeyValue. ThestartSearchOperation parameter is ignored if thestartKeyValue parameter is null.
Parameters:
  stopKeyValue - An indexable row which holds a (partial) key value which, in combination with the stopSearchOperator, defines the ending positionof the scan. If null, the ending position of thescan is the last row of the conglomerate. ThestopKeyValue must only reference columns includedin the scanColumnList.
Parameters:
  stopSearchOperator - an operator which defines how the stopKeyValueis used to determine the scan stopping position. If stopSearchOperation is ScanController.GE, thescan stops just before the first row which isgreater than or equal to the stopKeyValue. If stopSearchOperation is ScanController.GT, the scan stops just before the first row whose key is greater than startKeyValue. ThestopSearchOperation parameter is ignored if thestopKeyValue parameter is null.
Parameters:
  access_type - Describe the type of access the query will beperforming to the ScanController. STORECOST_CLUSTERED - The location of one scanis likely clustered "close" to the previous scan. For instance if the query plan wereto used repeated "reopenScan()'s" to probefor the next key in an index, then this flagshould be be specified. If this flag is not set then each scan will be costed independantof any other predicted scan access.
exception:
  StandardException - Standard exception policy.
See Also:   RowUtil




init
public void init(TransactionManager xact_manager, BTree conglomerate, Transaction rawtran) throws StandardException(Code)
Initialize the cost controller.

Save initialize parameters away, and open the underlying container.


Parameters:
  xact_manager - access manager transaction.
Parameters:
  rawtran - Raw store transaction.
exception:
  StandardException - Standard exception policy.




newRowLocationTemplate
public RowLocation newRowLocationTemplate() throws StandardException(Code)
Return an "empty" row location object of the correct type.

The empty Rowlocation.
exception:
  StandardException - Standard exception policy.




Fields inherited from org.apache.derby.impl.store.access.btree.OpenBTree
protected LogicalUndo btree_undo(Code)(Java Doc)
protected ContainerHandle container(Code)(Java Doc)
protected long err_containerid(Code)(Java Doc)
protected int init_lock_level(Code)(Java Doc)
protected TransactionManager init_open_user_scans(Code)(Java Doc)
protected OpenConglomerateScratchSpace runtime_mem(Code)(Java Doc)

Methods inherited from org.apache.derby.impl.store.access.btree.OpenBTree
public void checkConsistency() throws StandardException(Code)(Java Doc)
public void close() throws StandardException(Code)(Java Doc)
public void debugConglomerate() throws StandardException(Code)(Java Doc)
public boolean[] getColumnSortOrderInfo() throws StandardException(Code)(Java Doc)
final public BTree getConglomerate()(Code)(Java Doc)
final public ContainerHandle getContainer()(Code)(Java Doc)
public ContainerHandle getContainerHandle()(Code)(Java Doc)
public long getEstimatedRowCount() throws StandardException(Code)(Java Doc)
public int getHeight() throws StandardException(Code)(Java Doc)
final public boolean getHold()(Code)(Java Doc)
final public int getLockLevel()(Code)(Java Doc)
final public BTreeLockingPolicy getLockingPolicy()(Code)(Java Doc)
final public int getOpenMode()(Code)(Java Doc)
final public Transaction getRawTran()(Code)(Java Doc)
final public OpenConglomerateScratchSpace getRuntimeMem()(Code)(Java Doc)
public SpaceInfo getSpaceInfo() throws StandardException(Code)(Java Doc)
final public TransactionManager getXactMgr()(Code)(Java Doc)
public void init(TransactionManager open_user_scans, TransactionManager xact_manager, ContainerHandle input_container, Transaction rawtran, boolean hold, int open_mode, int lock_level, BTreeLockingPolicy btree_locking_policy, BTree conglomerate, LogicalUndo undo, DynamicCompiledOpenConglomInfo dynamic_info) throws StandardException(Code)(Java Doc)
final public boolean isClosed()(Code)(Java Doc)
void isIndexableRowConsistent(DataValueDescriptor[] row) throws StandardException(Code)(Java Doc)
public boolean isTableLocked()(Code)(Java Doc)
public RecordHandle makeRecordHandle(long page_number, int rec_id) throws StandardException(Code)(Java Doc)
public ContainerHandle reopen() throws StandardException(Code)(Java Doc)
public void setEstimatedRowCount(long count) throws StandardException(Code)(Java Doc)
final public void setLockingPolicy(BTreeLockingPolicy policy)(Code)(Java Doc)
public static boolean test_errors(OpenBTree open_btree, String debug_string, boolean release_scan_lock, BTreeLockingPolicy btree_locking_policy, LeafControlRow leaf, boolean input_latch_released) throws StandardException(Code)(Java Doc)

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___av_a__2___s._c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.