xref: /netbsd-src/lib/libc/db/hash/README (revision 100a3398b8d3c64e571cff36b46c23431b410e09)
1*100a3398Sandvar#	$NetBSD: README,v 1.6 2024/02/09 22:08:30 andvar Exp $
29f0aa214Scgd#	@(#)README	8.1 (Berkeley) 6/4/93
361f28255Scgd
461f28255ScgdThis package implements a superset of the hsearch and dbm/ndbm libraries.
561f28255Scgd
661f28255ScgdTest Programs:
761f28255Scgd	All test programs which need key/data pairs expect them entered
861f28255Scgd	with key and data on separate lines
961f28255Scgd
1061f28255Scgd	tcreat3.c
1161f28255Scgd		Takes
1261f28255Scgd			bucketsize (bsize),
1361f28255Scgd			fill factor (ffactor), and
1461f28255Scgd			initial number of elements (nelem).
1561f28255Scgd		Creates a hash table named hashtest containing the
1661f28255Scgd		keys/data pairs entered from standard in.
1761f28255Scgd	thash4.c
1861f28255Scgd		Takes
1961f28255Scgd			bucketsize (bsize),
2061f28255Scgd			fill factor (ffactor),
2161f28255Scgd			initial number of elements (nelem)
2261f28255Scgd			bytes of cache (ncached), and
2361f28255Scgd			file from which to read data  (fname)
2461f28255Scgd		Creates a table from the key/data pairs on standard in and
2561f28255Scgd		then does a read of each key/data in fname
2661f28255Scgd	tdel.c
2761f28255Scgd		Takes
2861f28255Scgd			bucketsize (bsize), and
2961f28255Scgd			fill factor (ffactor).
3061f28255Scgd			file from which to read data (fname)
3161f28255Scgd		Reads each key/data pair from fname and deletes the
3261f28255Scgd		key from the hash table hashtest
3361f28255Scgd	tseq.c
3461f28255Scgd		Reads the key/data pairs in the file hashtest and writes them
3561f28255Scgd		to standard out.
3661f28255Scgd	tread2.c
3761f28255Scgd		Takes
3861f28255Scgd			butes of cache (ncached).
3961f28255Scgd		Reads key/data pairs from standard in and looks them up
4061f28255Scgd		in the file hashtest.
4161f28255Scgd	tverify.c
4261f28255Scgd		Reads key/data pairs from standard in, looks them up
4361f28255Scgd		in the file hashtest, and verifies that the data is
4461f28255Scgd		correct.
4561f28255Scgd
4661f28255ScgdNOTES:
4761f28255Scgd
489f0aa214ScgdThe man page ../man/db.3 explains the interface to the hashing system.
4961f28255ScgdThe file hash.ps is a postscript copy of a paper explaining
5061f28255Scgdthe history, implementation, and performance of the hash package.
5161f28255Scgd
52*100a3398Sandvar"bugs" or idiosyncrasies
5361f28255Scgd
5461f28255ScgdIf you have a lot of overflows, it is possible to run out of overflow
5561f28255Scgdpages.  Currently, this will cause a message to be printed on stderr.
5661f28255ScgdEventually, this will be indicated by a return error code.
5761f28255Scgd
5861f28255ScgdIf you are using the ndbm interface and exit without flushing or closing the
5961f28255Scgdfile, you may lose updates since the package buffers all writes.  Also,
6061f28255Scgdthe db interface only creates a single database file.  To avoid overwriting
6161f28255Scgdthe user's original file, the suffix ".db" is appended to the file name
6261f28255Scgdpassed to dbm_open.  Additionally, if your code "knows" about the historic
6361f28255Scgd.dir and .pag files, it will break.
6461f28255Scgd
6561f28255ScgdThere is a fundamental difference between this package and the old hsearch.
6661f28255ScgdHsearch requires the user to maintain the keys and data in the application's
6761f28255Scgdallocated memory while hash takes care of all storage management.  The down
6861f28255Scgdside is that the byte strings passed in the ENTRY structure must be null
6961f28255Scgdterminated (both the keys and the data).
70