2 * Copyright (c) 1996-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _BTREESCANNER_H_
26 #define _BTREESCANNER_H_
30 #include "FileMgrInternal.h"
31 #include "BTreesPrivate.h"
33 // amount of time we are allowed to process a catalog search (in ยต secs)
34 // NOTE - code assumes kMaxMicroSecsInKernel is less than 1,000,000
35 // jertodo - what should we set this to?
36 enum { kMaxMicroSecsInKernel
= (1000 * 100) }; // 1 tenth of a second
38 // btree node scanner buffer size. at 32K we get 8 nodes. this is the size used
40 enum { kCatSearchBufferSize
= (32 * 1024) };
44 * ============ W A R N I N G ! ============
45 * DO NOT INCREASE THE SIZE OF THIS STRUCT!
46 * It must be less than or equal to the size of
47 * the opaque searchstate struct (in sys/attr.h).
49 /* Private description used in hfs_search */
52 u_int32_t writeCount
; /* The BTree's write count (to see if the catalog writeCount */
53 /* changed since the last search). If 0, the rest */
54 /* of the record is invalid, start from beginning. */
55 u_int32_t nextNode
; /* node number to resume search */
56 u_int32_t nextRecord
; /* record number to resume search */
57 u_int32_t recordsFound
; /* number of leaf records seen so far */
59 typedef struct CatPosition CatPosition
;
63 BTScanState - This structure is used to keep track of the current state
64 of a BTree scan. It contains both the dynamic state information (like
65 the current node number and record number) and information that is static
66 for the duration of a scan (such as buffer pointers).
68 NOTE: recordNum may equal or exceed the number of records in the node
69 number nodeNum. If so, then the next attempt to get a record will move
74 // The following fields are set up once at initialization time.
75 // They are not changed during a scan.
77 struct buf
* bufferPtr
;
78 BTreeControlBlock
* btcb
;
80 // The following fields are the dynamic state of the current scan.
81 u_int32_t nodeNum
; // zero is first node
82 u_int32_t recordNum
; // zero is first record
83 BTNodeDescriptor
* currentNodePtr
; // points to current node within buffer
84 u_int32_t nodesLeftInBuffer
; // number of valid nodes still in the buffer
85 u_int32_t recordsFound
; // number of leaf records seen so far
86 struct timeval startTime
; // time we started catalog search
88 typedef struct BTScanState BTScanState
;
91 /* *********************** PROTOTYPES *********************** */
93 int BTScanInitialize( const FCB
* btreeFile
,
94 u_int32_t startingNode
,
95 u_int32_t startingRecord
,
96 u_int32_t recordsFound
,
98 BTScanState
* scanState
);
100 int BTScanNextRecord( BTScanState
* scanState
,
104 u_int32_t
* dataSize
);
106 int BTScanTerminate( BTScanState
* scanState
,
107 u_int32_t
* startingNode
,
108 u_int32_t
* startingRecord
,
109 u_int32_t
* recordsFound
);
111 #endif /* !_BTREESCANNER_H_ */