1/* 2 * Copyright (c) 1996-2002 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 * 23 * @(#)BTreeScanner.h 24 */ 25 26#ifndef _BTREESCANNER_H_ 27#define _BTREESCANNER_H_ 28 29#include "BTreePrivate.h" 30 31// btree node scanner buffer size. Joe Sokol suggests 128K as a max (2002 WWDC) 32enum { kCatScanBufferSize = (128 * 1024) }; 33 34 35/* 36 BTScanState - This structure is used to keep track of the current state 37 of a BTree scan. It contains both the dynamic state information (like 38 the current node number and record number) and information that is static 39 for the duration of a scan (such as buffer pointers). 40 41 NOTE: recordNum may equal or exceed the number of records in the node 42 number nodeNum. If so, then the next attempt to get a record will move 43 to a new node number. 44*/ 45struct BTScanState 46{ 47 // The following fields are set up once at initialization time. 48 // They are not changed during a scan. 49 u_int32_t bufferSize; 50 void * bufferPtr; 51 BTreeControlBlock * btcb; 52 53 // The following fields are the dynamic state of the current scan. 54 u_int32_t nodeNum; // zero is first node 55 u_int32_t recordNum; // zero is first record 56 BTNodeDescriptor * currentNodePtr; // points to current node within buffer 57 int32_t nodesLeftInBuffer; // number of valid nodes still in the buffer 58 int64_t recordsFound; // number of leaf records seen so far 59}; 60typedef struct BTScanState BTScanState; 61 62 63/* *********************** PROTOTYPES *********************** */ 64 65int BTScanInitialize( const SFCB * btreeFile, 66 BTScanState * scanState ); 67 68int BTScanNextRecord( BTScanState * scanState, 69 void * * key, 70 void * * data, 71 u_int32_t * dataSize ); 72 73int BTScanTerminate( BTScanState * scanState ); 74 75#endif /* !_BTREESCANNER_H_ */ 76