plsql-hashtable Code
Status: Beta
Brought to you by:
jkrogsboell
File | Date | Author | Commit |
---|---|---|---|
README | 2009-07-19 | jkrogsboell | [r7] Added README file |
alt-hashtable.typ | 2009-07-19 | jkrogsboell | [r7] Added README file |
alt-install.sql | 2009-07-19 | jkrogsboell | [r7] Added README file |
hashtable.typ | 2009-07-19 | jkrogsboell | [r7] Added README file |
install.sql | 2009-07-19 | jkrogsboell | [r7] Added README file |
test.sql | 2009-07-19 | jkrogsboell | [r7] Added README file |
README for plsql-hashtable ABOUT: When you are developing oracle object one very useful datatype is not available, that is assosiative arrays. Assosiative arrays is hashtables for oracle-plsql, but can only be used within plsql structures. Another limitation of assosiative arrays is that the index key should be either varchar2(30) or pls_integer. Do you find yourself programming only within plsql-packages, never with Object types, and is the structure never to be stored on the database, then stick to assositive arrays - it's native plsql and it's very fast. Do you, on the other hand: 1. need a hashtable in an Object type 2. need a different index than varchar2 or pls_integer 3. need to store the collection into the database 4. need hashtables with multiple key types and value types Then by all means, use this code. INSTALLATION NOTES: Run either the install.sql or alt-install.sql file on your database schema. WARNING: Any object, package, procedure, function or table with the following names will be dropped: HASHTABLE, HASH_BUCKET_ARRAY, HASH_BUCKET, HASH_ENTRY API DESCRIPTION: The object "hashtable" is initialized through the "hashtable()" constructor. The interaction is done with these five methods: put(key anydata, value anydata) get(key anydata) return anydata remove(key anydata) exist(key anydata) return boolean count return number To use a type in the hashtable, the methods "hash(key anydata)" and "equals(key1 anydata, key2 anydata)" must be modified to handle the key type. Overloaded methods to store varchar2 and number as key-value pairs has been implemented as an example. The implementation is located at the end of the hashtable body. USAGE: See the file "test.sql". SPECIALIZED EXAMPLE: Conversion to anydata and extra method call's are computational expensive. A specialized version of the hashtable is much faster. The only changes that you would need to make are in the HASH_ENTRY type and the method variable types in the HASHTABLE type. Read alt-hashtable.typ to see how. CHANGE LOG: 0.2 Changes: add : Install script add : Test SQL of insert add : Added alternative specialized hashtable as an example. Is doing fewer conversions and is faster. rewrite: Realized that buckets was linked lists - changed type to VARRAY(100). Result - faster structure (should be constant access), but array doubling doesn't work anymore. Bucket reorder no longer needed as VARRAY retain the order of elements. bug fix: Array not properly initialised when doing array doubling. Obsolete when VARRAY was introduced. problem: Arrays doubling is not possible when using VARRAY. 0.1 Initial release: Content: one single sql file with four types.