• Non ci sono risultati.

Organizations for key search

N/A
N/A
Protected

Academic year: 2022

Condividi "Organizations for key search"

Copied!
17
0
0

Testo completo

(1)

Organizations for key search

• Goal: Quick search for a record of a table with a given key value

We are here

(2)

Organizations for key search

• Definition. An organization is called primary if it determines the way records are physically stored, otherwise it is called secondary.

PRIMARY SECONDARY

(3)

Static and dynamic organizations

• Static:

– After insertions or deletions may need a reorganization

• Dynamic:

– Gradually evolves with insertion and deletions

(4)

Static hashing organizations

• Assumption: N records, with same and fixed size, stored in M pages of capacity c.

• Design Parameters

– Page capacity (c) – Loading factor

(d = N/(M×c)) – Hash function H

– Overflow management

k

H(k)

0 1 2 c-1

0 1 2 c-1

0 1 2 c-1

Primary Area

Overflow Area

Overflow Manager 0

1

M-1

(5)

Hash function

• Produces addresses uniformly distributed in the interval (0,M-1)

• The typical hash function, with M prime:

• H(k) = f(k) mod M

• Two keys produce a collision if H(k1) = H(k2)

• If the number of collisions is greater than the page capacity, there is an overflow. Overflows increase the search cost.

(6)

Overflow management

• Open overflow:

– Overflow records are put in the first available page

• Chained overflow:

– Overflow records are put in a separate area, and chained together (by page or by record)

(7)

Loading factor

High loading factor reduces primary area size but

increases the probability of overflow

Loading Factor

Average number of accesses

Open addressing

Coalesced lists

Lists in separate area

(8)

Page capacity

• If page capacity increases,

overflows decrease

• Hashing is

convenient with a large page

capacity (>=10)

(9)

Performance

• With few overflows:

– Excellent performance for equality search – Range search?

• With many overflows:

– Reorganization is needeed

(10)

Dynamic hashing organizations

• With auxiliary data structures:

– Virtual hash

– Extendible hash

• Without auxiliary data structures:

– Linear hash – Spiral hash

(11)

Virtual hash

Hj(3820)= 5

Start with Hj(k) = k mod (2j M), j = 0

Hj+1(k) = Hj(k) + 2j M Hj+1(k) = Hj(k)

(12)

Virtual hash

PageSearch (r , k):

if B(Hr(k)) = 1 then Hr(k)

else PageSearch (r – 1, k)

(13)

Extendible hash

• Idea: substitute B with an index with references to pages, and double the index

• The index is smaller than primary area, and can be compressed with several techniques

Hash table Data Pages

(14)

Linear hash

Start with M pages and H0(k) = k mod M Hi(k) = k mod (2i x M)

(15)

Linear hash

function SearchPage(p, k: integer): integer;

begin

if Hi(k) < p

then SearchPage := Hi+1(k) else SearchPage := Hi(k) end

H0(k) = k mod M

Hi(k) = k mod 2i x M

(16)

Spiral hash

• With Linear Hash, unsplitted pages are crammed

• Better a spiral data area

• The hashing function is

uneven. The load is high at the beginning of the

address space and tapers off towards the end.

(17)

Summary

• Hash organizations are simple to implement

• Static

– When is well designed (80% page occupancy), a record is retrieved with ~1 page access

– Hard to keep 80% when size changes

• Dynamic

– Complex but well behaved (spiral hashing)

• Problem:

– for range search they are useless !

.

Riferimenti

Documenti correlati

Moreover, higher magnification images further demonstrated the hyperinnervation of serotonergic fibers in Tph2::eGFP (FRT)/(FRT-neo-FRT) -/- mice and showed that

Hence the necessity and opportunity to develop new kinds of amplifi- cating systems, based on other principles than those of classical physics, to move further in the process of

Solution proposed by Roberto Tauraso, Dipartimento di Matematica, Universit`a di Roma “Tor Vergata”, via della Ricerca Scientifica, 00133 Roma,

Solution proposed by Roberto Tauraso, Dipartimento di Matematica, Universit`a di Roma “Tor Vergata”, via della Ricerca Scientifica, 00133 Roma,

Since our proofs mainly rely on various properties of Ramanujan’s theta functions and dissections of certain q-products, we end this section by defining a t-dissection and

of the tangent bundle w;th the fibre of dimens;on n... l) ho1d in the more genera1 situation of an almost mu1tifo1iated riemannian structures on a manifo1d, l.e.. are not

The disclosed displacements are the result of deformation of the bolt material in the elastic and plastic range as well as the properties of the bonding materials used (cement,

Enhancement, 3-D Virtual Objects, Accessibility/Open Access, Open Data, Cultural Heritage Availability, Heritage at Risk, Heritage Protection, Virtual Restoration