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


java.lang.Object
   org.apache.derby.iapi.store.access.BackingStoreHashtable

All known Subclasses:   org.apache.derby.impl.store.access.BackingStoreHashTableFromScan,
BackingStoreHashtable
public class BackingStoreHashtable (Code)
A BackingStoreHashtable is a utility class which will store a set of rows into an in memory hash table, or overflow the hash table to a tempory on disk structure.

All rows must contain the same number of columns, and the column at position N of all the rows must have the same format id. If the BackingStoreHashtable needs to be overflowed to disk, then an arbitrary row will be chosen and used as a template for creating the underlying overflow container.

The hash table will be built logically as follows (actual implementation may differ). The important points are that the hash value is the standard java hash value on the row[key_column_numbers[0], if key_column_numbers.length is 1, or row[key_column_numbers[0, 1, ...]] if key_column_numbers.length > 1, and that duplicate detection is done by the standard java duplicate detection provided by java.util.Hashtable.

import java.util.Hashtable; hash_table = new Hashtable(); Object[] row; boolean needsToClone = rowSource.needsToClone(); while((row = rowSource.getNextRowFromRowSource()) != null) { if (needsToClone) row = clone_row_from_row(row); Object key = KeyHasher.buildHashKey(row, key_column_numbers); if ((duplicate_value = hash_table.put(key, row)) != null) { Vector row_vec; // inserted a duplicate if ((duplicate_value instanceof vector)) { row_vec = (Vector) duplicate_value; } else { // allocate vector to hold duplicates row_vec = new Vector(2); // insert original row into vector row_vec.addElement(duplicate_value); // put the vector as the data rather than the row hash_table.put(key, row_vec); } // insert new row into vector row_vec.addElement(row); } }




Constructor Summary
public  BackingStoreHashtable(TransactionController tc, RowSource row_source, int[] key_column_numbers, boolean remove_duplicates, long estimated_rowcnt, long max_inmemory_rowcnt, int initialCapacity, float loadFactor, boolean skipNullKeyColumns, boolean keepAfterCommit)
     Create the BackingStoreHashtable from a row source.

This routine drains the RowSource.


Method Summary
static  Object[]cloneRow(Object[] old_row)
     Return a cloned copy of the row.
public  voidclose()
     Close the BackingStoreHashtable.

Perform any necessary cleanup after finishing with the hashtable.

public  Enumerationelements()
     Return an Enumeration that can be used to scan entire table.
public  Objectget(Object key)
     get data associated with given key.

There are 2 different types of objects returned from this routine.

In both cases, the key value is either the object stored in row[key_column_numbers[0]], if key_column_numbers.length is 1, otherwise it is a KeyHasher containing the objects stored in row[key_column_numbers[0, 1, ...]]. For every qualifying unique row value an entry is placed into the Hashtable.

For row values with duplicates, the value of the data is a Vector of rows.

The caller will have to call "instanceof" on the data value object if duplicates are expected, to determine if the data value of the Hashtable entry is a row or is a Vector of rows.

The BackingStoreHashtable "owns" the objects returned from the get() routine.

public  voidgetAllRuntimeStats(Properties prop)
     Return runtime stats to caller by adding them to prop.
public  booleanput(boolean needsToClone, Object[] row)
     Put a row into the hash table.

The in memory hash table will need to keep a reference to the row after the put call has returned.

public  Objectremove(Object key)
     remove a row from the hash table.
public  voidsetAuxillaryRuntimeStats(Properties prop)
     Set the auxillary runtime stats.

getRuntimeStats() will return both the auxillary stats and any BackingStoreHashtable() specific stats.

static  DataValueDescriptor[]shallowCloneRow(DataValueDescriptor[] old_row)
    
public  intsize()
     Return number of unique rows in the hash table.


Constructor Detail
BackingStoreHashtable
public BackingStoreHashtable(TransactionController tc, RowSource row_source, int[] key_column_numbers, boolean remove_duplicates, long estimated_rowcnt, long max_inmemory_rowcnt, int initialCapacity, float loadFactor, boolean skipNullKeyColumns, boolean keepAfterCommit) throws StandardException(Code)
Create the BackingStoreHashtable from a row source.

This routine drains the RowSource. The performance characteristics depends on the number of rows inserted and the parameters to the constructor.

If the number of rows is <= "max_inmemory_rowcnt", then the rows are inserted into a java.util.Hashtable. In this case no TransactionController is necessary, a "null" tc is valid.

If the number of rows is > "max_inmemory_rowcnt", then the rows will be all placed in some sort of Access temporary file on disk. This case requires a valid TransactionController.
Parameters:
  tc - An open TransactionController to be used if thehash table needs to overflow to disk.
Parameters:
  row_source - RowSource to read rows from.
Parameters:
  key_column_numbers - The column numbers of the columns in thescan result row to be the key to the Hashtable."0" is the first column in the scan resultrow (which may be different than the firstrow in the table of the scan).
Parameters:
  remove_duplicates - Should the Hashtable automatically removeduplicates, or should it create the Vector ofduplicates?
Parameters:
  estimated_rowcnt - The estimated number of rows in the hash table.Pass in -1 if there is no estimate.
Parameters:
  max_inmemory_rowcnt - The maximum number of rows to insert into the inmemory Hash table before overflowing to disk.Pass in -1 if there is no maximum.
Parameters:
  initialCapacity - If not "-1" used to initialize the java Hashtable.
Parameters:
  loadFactor - If not "-1" used to initialize the java Hashtable.
Parameters:
  skipNullKeyColumns - Skip rows with a null key column, if true.
Parameters:
  keepAfterCommit - If true the hash table is kept after a commit,if false the hash table is dropped on the next commit.
exception:
  StandardException - Standard exception policy.





Method Detail
cloneRow
static Object[] cloneRow(Object[] old_row) throws StandardException(Code)
Return a cloned copy of the row. The cloned row row to use.
exception:
  StandardException - Standard exception policy.



close
public void close() throws StandardException(Code)
Close the BackingStoreHashtable.

Perform any necessary cleanup after finishing with the hashtable. Will deallocate/dereference objects as necessary. If the table has gone to disk this will drop any on disk files used to support the hash table.


exception:
  StandardException - Standard exception policy.




elements
public Enumeration elements() throws StandardException(Code)
Return an Enumeration that can be used to scan entire table.

RESOLVE - is it worth it to support this routine when we have a disk overflow hash table? The Enumeration.
exception:
  StandardException - Standard exception policy.




get
public Object get(Object key) throws StandardException(Code)
get data associated with given key.

There are 2 different types of objects returned from this routine.

In both cases, the key value is either the object stored in row[key_column_numbers[0]], if key_column_numbers.length is 1, otherwise it is a KeyHasher containing the objects stored in row[key_column_numbers[0, 1, ...]]. For every qualifying unique row value an entry is placed into the Hashtable.

For row values with duplicates, the value of the data is a Vector of rows.

The caller will have to call "instanceof" on the data value object if duplicates are expected, to determine if the data value of the Hashtable entry is a row or is a Vector of rows.

The BackingStoreHashtable "owns" the objects returned from the get() routine. They remain valid until the next access to the BackingStoreHashtable. If the client needs to keep references to these objects, it should clone copies of the objects. A valid BackingStoreHashtable can place all rows into a disk based conglomerate, declare a row buffer and then reuse that row buffer for every get() call. The value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.
Parameters:
  key - The key to hash on.
exception:
  StandardException - Standard exception policy.




getAllRuntimeStats
public void getAllRuntimeStats(Properties prop) throws StandardException(Code)
Return runtime stats to caller by adding them to prop.


Parameters:
  prop - The set of properties to append to.
exception:
  StandardException - Standard exception policy.




put
public boolean put(boolean needsToClone, Object[] row) throws StandardException(Code)
Put a row into the hash table.

The in memory hash table will need to keep a reference to the row after the put call has returned. If "needsToClone" is true then the hash table will make a copy of the row and put that, else if "needsToClone" is false then the hash table will keep a reference to the row passed in and no copy will be made.

If rouine returns false, then no reference is kept to the duplicate row which was rejected (thus allowing caller to reuse the object).
Parameters:
  needsToClone - does this routine have to make a copy of the row,in order to keep a reference to it after return?
Parameters:
  row - The row to insert into the table. true if row was inserted into the hash table. Returnsfalse if the BackingStoreHashtable is eliminating duplicates, and the row being inserted is a duplicate,or if we are skipping rows with 1 or more null key columnsand we find a null key column.
exception:
  StandardException - Standard exception policy.




remove
public Object remove(Object key) throws StandardException(Code)
remove a row from the hash table.

a remove of a duplicate removes the entire duplicate list.
Parameters:
  key - The key of the row to remove.
exception:
  StandardException - Standard exception policy.




setAuxillaryRuntimeStats
public void setAuxillaryRuntimeStats(Properties prop) throws StandardException(Code)
Set the auxillary runtime stats.

getRuntimeStats() will return both the auxillary stats and any BackingStoreHashtable() specific stats. Note that each call to setAuxillaryRuntimeStats() overwrites the Property set that was set previously.
Parameters:
  prop - The set of properties to append from.
exception:
  StandardException - Standard exception policy.




shallowCloneRow
static DataValueDescriptor[] shallowCloneRow(DataValueDescriptor[] old_row) throws StandardException(Code)
Return a shallow cloned row The cloned row row to use.
exception:
  StandardException - Standard exception policy.



size
public int size() throws StandardException(Code)
Return number of unique rows in the hash table.

The number of unique rows in the hash table.
exception:
  StandardException - Standard exception policy.




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.