8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-25 02:03:03 +01:00
firebird-mirror/src/jrd/sbm.h

98 lines
2.5 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD Access Method
* MODULE: sbm.h
* DESCRIPTION: Sparse bit map block definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
2002-10-30 07:40:58 +01:00
*
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
*
* 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
*
2001-05-23 15:26:42 +02:00
*/
2001-12-24 03:51:06 +01:00
#ifndef JRD_SBM_H
#define JRD_SBM_H
#include "../jrd/jrd_blks.h"
#include "../include/fb_blk.h"
#include "../include/fb_vector.h"
2001-05-23 15:26:42 +02:00
#define BUNCH_BITS LOG2_BITS_PER_LONG
#define BUNCH SLONG
#define SEGMENT_BITS 10
2001-12-24 03:51:06 +01:00
#define BITS_BUNCH (1 << BUNCH_BITS)
2001-05-23 15:26:42 +02:00
#define BITS_SEGMENT (1 << SEGMENT_BITS)
#define BUNCH_SEGMENT BITS_SEGMENT / BITS_BUNCH
2001-12-24 03:51:06 +01:00
#define BUCKET_BITS 15
2001-05-23 15:26:42 +02:00
#define BUNCH_BUCKET (1 << (BUCKET_BITS - SEGMENT_BITS))
2001-12-24 03:51:06 +01:00
// Sparse bit map
class BitmapSegment;
class SparseBitmap : public pool_alloc<type_sbm>
2001-12-24 03:51:06 +01:00
{
public:
SparseBitmap(MemoryPool& p, int len)
2001-12-24 03:51:06 +01:00
: sbm_segments(len, p, type_sbm)
{
}
SparseBitmap* sbm_next;
2001-12-24 03:51:06 +01:00
JrdMemoryPool* sbm_pool;
UCHAR sbm_state; // State of bitmap
UCHAR sbm_type; // Root or bucket
USHORT sbm_count; // Slots allocated
USHORT sbm_used; // Slots used
USHORT sbm_high_water; // Maximum slot used
SLONG sbm_number; // Value when singular
typedef Firebird::vector<BitmapSegment*> vector_type;
2001-12-24 03:51:06 +01:00
typedef vector_type::iterator iterator;
2003-12-31 06:36:12 +01:00
typedef vector_type::const_iterator const_iterator;
2001-12-24 03:51:06 +01:00
vector_type sbm_segments;
2001-12-24 03:51:06 +01:00
};
2001-05-23 15:26:42 +02:00
/* States */
#define SBM_EMPTY 0
#define SBM_SINGULAR 1
#define SBM_PLURAL 2
/* Types */
#define SBM_BUCKET 0
#define SBM_ROOT 1
/* Bit map segment */
class BitmapSegment : public pool_alloc<type_bms>
2001-12-24 03:51:06 +01:00
{
public:
BitmapSegment* bms_next;
2001-12-24 03:51:06 +01:00
JrdMemoryPool* bms_pool;
SSHORT bms_min; // Minimum bit set in segment
SSHORT bms_max; // Maximum bit set in segment
BUNCH bms_bits[BUNCH_SEGMENT];
};
2001-05-23 15:26:42 +02:00
2001-12-24 03:51:06 +01:00
#endif // JRD_SBM_H
2003-12-31 06:36:12 +01:00