Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: dbms_utility.get_hash_value
I would just like to point out that Oracle has something known as a hash
cluster that might be of use/benefit as the data store with solving the end
customer problem.
HTH -- Mark D Powell --
-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org]On Behalf Of Connor McDonald
Sent: Wednesday, October 20, 2004 7:53 PM
To: oracle-l_at_freelists.org
Subject: Re: dbms_utility.get_hash_value
Well, hashing does imply that uniqueness is an 'aim' not a 'guarantee'.
Here's a little routine that demos a hash table of size 'n', and put
collisions at indices
starting at 'n+1' with a simple linked list arrangement. Not pretty but
reasonably effective
SQL> set serverout on size 999999
SQL> declare
2 type ENTRY is record (
3 val varchar2(30), 4 nxt number );
18 from all_objects where rownum < 1000 ) loop 19 hv := dbms_utility.get_hash_value(i.object_name,1,hash_size); 20 if h.exists(hv) then 21 overflow := overflow + 1; 22 loop 23 if h(hv).nxt = -1 then 24 h(overflow+hash_size).val := i.object_name; 25 h(overflow+hash_size).nxt := -1; 26 h(hv).nxt := overflow+hash_size; 27 exit; 28 else 29 hv := h(hv).nxt; 30 end if; 31 end loop; 32 else 33 h(hv).val := i.object_name; 34 h(hv).nxt := -1; 35 end if;
39 if h.exists(i) then 40 dbms_output.put_line('IDX: '||lpad(i,6)); 41 hv := i; 42 loop 43 exit when h(hv).nxt = -1; 44 dbms_output.put_line('- '||h(hv).nxt); 45 hv := h(hv).nxt; 46 end loop; 47 else 48 dbms_output.put_line('IDX: '||lpad(i,6)||' empty'); 49 end if;
IDX: 1 IDX: 2 - 899
IDX: 3 IDX: 4 - 1037 IDX: 5 - 954 IDX: 6
IDX: 7 empty IDX: 8 IDX: 9 - 961 IDX: 10 empty IDX: 11 IDX: 12 - 1107 IDX: 13 empty IDX: 14
IDX: 17 empty IDX: 18 empty IDX: 19 empty IDX: 20 empty IDX: 21 empty IDX: 22 IDX: 23
IDX: 790 IDX: 791 empty IDX: 792 IDX: 793 IDX: 794 empty IDX: 795 empty IDX: 796 empty IDX: 797 empty IDX: 798
-- http://www.freelists.org/webpage/oracle-lReceived on Thu Oct 21 2004 - 10:09:36 CDT
![]() |
![]() |