index
Class HashIndex

java.lang.Object
  extended by index.HashIndex
All Implemented Interfaces:
GlobalConst

public class HashIndex
extends java.lang.Object
implements GlobalConst

Minibase Hash Index

This unclustered index implements static hashing as described on pages 371 to 373 of the textbook (3rd edition).


Field Summary
 
Fields inherited from interface global.GlobalConst
EMPTY_SLOT, FIRST_PAGEID, INVALID_PAGEID, MAX_COLSIZE, MAX_TUPSIZE, NAME_MAXLEN, PAGE_SIZE, PIN_DISKIO, PIN_MEMCPY, UNPIN_CLEAN, UNPIN_DIRTY
 
Constructor Summary
HashIndex(java.lang.String fileName)
          Opens an index file given its name, or creates a new index file if the name doesn't exist; a null name produces a temporary index file which requires no disk manager entry.
 
Method Summary
 void deleteEntry(SearchKey key, RID rid)
          Deletes the specified entry from the index file.
 void deleteFile()
          Deletes the index file from the database, freeing all of its pages.
 void insertEntry(SearchKey key, RID rid)
          Inserts a new entry into the index file.
 BucketScan openScan()
          Initiates a scan of the entire index file in bucket order.
 HashScan openScan(SearchKey key)
          Initiates an equality scan of the index file.
 void printSummary()
          Prints a high-level view of the directory, namely which buckets are allocated and how many entries are stored in each one.
 java.lang.String toString()
          Returns the name of the index file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HashIndex

public HashIndex(java.lang.String fileName)
Opens an index file given its name, or creates a new index file if the name doesn't exist; a null name produces a temporary index file which requires no disk manager entry.

Method Detail

deleteFile

public void deleteFile()
Deletes the index file from the database, freeing all of its pages.


insertEntry

public void insertEntry(SearchKey key,
                        RID rid)
Inserts a new entry into the index file.

Throws:
java.lang.IllegalArgumentException - if the entry is too large

deleteEntry

public void deleteEntry(SearchKey key,
                        RID rid)
Deletes the specified entry from the index file.

Throws:
java.lang.IllegalArgumentException - if the entry doesn't exist

openScan

public BucketScan openScan()
Initiates a scan of the entire index file in bucket order.


openScan

public HashScan openScan(SearchKey key)
Initiates an equality scan of the index file.


toString

public java.lang.String toString()
Returns the name of the index file.

Overrides:
toString in class java.lang.Object

printSummary

public void printSummary()
Prints a high-level view of the directory, namely which buckets are allocated and how many entries are stored in each one. Sample output:
 IX_Customers
 ------------
 0000000 : 35
 0000001 : 39
 0000010 : 27
 ...
 1111111 : 42
 ------------
 Total : 1500