2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1996-2001
5
* Sleepycat Software. All rights reserved.
10
static const char revid[] = "$Id: hash_conv.c,v 11.6 2001/01/25 18:22:47 bostic Exp $";
13
#ifndef NO_SYSTEM_INCLUDES
14
#include <sys/types.h>
24
* Convert host-specific page layout from the host-independent format
27
* PUBLIC: int __ham_pgin __P((DB_ENV *, db_pgno_t, void *, DBT *));
30
__ham_pgin(dbenv, pg, pp, cookie)
40
pginfo = (DB_PGINFO *)cookie->data;
43
* The hash access method does blind reads of pages, causing them
44
* to be created. If the type field isn't set it's one of them,
45
* initialize the rest of the page and return.
47
if (h->type != P_HASHMETA && h->pgno == PGNO_INVALID) {
48
P_INIT(pp, pginfo->db_pagesize,
49
pg, PGNO_INVALID, PGNO_INVALID, 0, P_HASH);
53
if (!pginfo->needswap)
56
return (h->type == P_HASHMETA ? __ham_mswap(pp) :
57
__db_byteswap(dbenv, pg, pp, pginfo->db_pagesize, 1));
62
* Convert host-specific page layout to the host-independent format
65
* PUBLIC: int __ham_pgout __P((DB_ENV *, db_pgno_t, void *, DBT *));
68
__ham_pgout(dbenv, pg, pp, cookie)
77
pginfo = (DB_PGINFO *)cookie->data;
78
if (!pginfo->needswap)
82
return (h->type == P_HASHMETA ? __ham_mswap(pp) :
83
__db_byteswap(dbenv, pg, pp, pginfo->db_pagesize, 0));
88
* Swap the bytes on the hash metadata page.
90
* PUBLIC: int __ham_mswap __P((void *));
101
p = (u_int8_t *)pg + sizeof(DBMETA);
103
SWAP32(p); /* max_bucket */
104
SWAP32(p); /* high_mask */
105
SWAP32(p); /* low_mask */
106
SWAP32(p); /* ffactor */
107
SWAP32(p); /* nelem */
108
SWAP32(p); /* h_charkey */
109
for (i = 0; i < NCACHED; ++i)
110
SWAP32(p); /* spares */