Lucene++ - a full-featured, c++ search engine
API Documentation

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ByteBlockPool.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6
7 #ifndef BYTEBLOCKPOOL_H
8 #define BYTEBLOCKPOOL_H
9
10 #include "LuceneObject.h"
11
12 namespace Lucene
13 {
23 class ByteBlockPool : public LuceneObject
24 {
25 public:
26 ByteBlockPool(ByteBlockPoolAllocatorBasePtr allocator, bool trackAllocations);
27 virtual ~ByteBlockPool();
28
29 LUCENE_CLASS(ByteBlockPool);
30
31 public:
32 Collection<ByteArray> buffers;
33 int32_t bufferUpto; // Which buffer we are up to
34 int32_t byteUpto; // Where we are in head buffer
35
36 ByteArray buffer;
37 int32_t byteOffset;
38
39 static const int32_t nextLevelArray[];
40 static const int32_t levelSizeArray[];
41
42 protected:
43 bool trackAllocations;
44 ByteBlockPoolAllocatorBasePtr allocator;
45
46 public:
47 static int32_t FIRST_LEVEL_SIZE();
48
49 void reset();
50 void nextBuffer();
51 int32_t newSlice(int32_t size);
52 int32_t allocSlice(ByteArray slice, int32_t upto);
53 };
54
55 class ByteBlockPoolAllocatorBase : public LuceneObject
56 {
57 public:
58 virtual ~ByteBlockPoolAllocatorBase();
59
60 LUCENE_CLASS(ByteBlockPoolAllocatorBase);
61
62 public:
63 virtual void recycleByteBlocks(Collection<ByteArray> blocks, int32_t start, int32_t end) = 0;
64 virtual void recycleByteBlocks(Collection<ByteArray> blocks) = 0;
65 virtual ByteArray getByteBlock(bool trackAllocations) = 0;
66 };
67 }
68
69 #endif

clucene.sourceforge.net