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

MultiLevelSkipListReader.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 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 MULTILEVELSKIPLISTREADER_H
8 #define MULTILEVELSKIPLISTREADER_H
9
10 #include "IndexInput.h"
11
12 namespace Lucene {
13
20 class MultiLevelSkipListReader : public LuceneObject {
21 public:
22 MultiLevelSkipListReader(const IndexInputPtr& skipStream, int32_t maxSkipLevels, int32_t skipInterval);
23 virtual ~MultiLevelSkipListReader();
24
25 LUCENE_CLASS(MultiLevelSkipListReader);
26
27 protected:
29 int32_t maxNumberOfSkipLevels;
30
32 int32_t numberOfSkipLevels;
33
38 int32_t numberOfLevelsToBuffer;
39
40 int32_t docCount;
41 bool haveSkipped;
42
43 Collection<IndexInputPtr> skipStream; // skipStream for each level
44 Collection<int64_t> skipPointer; // the start pointer of each skip level
45 Collection<int32_t> skipInterval; // skipInterval of each level
46 Collection<int32_t> numSkipped; // number of docs skipped per level
47
48 Collection<int32_t> skipDoc; // doc id of current skip entry per level
49 int32_t lastDoc; // doc id of last read skip entry with docId <= target
50 Collection<int64_t> childPointer; // child pointer of current skip entry per level
51 int64_t lastChildPointer; // childPointer of last read skip entry with docId <= target
52
53 bool inputIsBuffered;
54
55 public:
57 virtual int32_t getDoc();
58
61 virtual int32_t skipTo(int32_t target);
62
63 virtual void close();
64
66 virtual void init(int64_t skipPointer, int32_t df);
67
68 protected:
69 virtual bool loadNextSkip(int32_t level);
70
72 virtual void seekChild(int32_t level);
73
75 virtual void loadSkipLevels();
76
81 virtual int32_t readSkipData(int32_t level, const IndexInputPtr& skipStream) = 0;
82
84 virtual void setLastSkipData(int32_t level);
85 };
86
88 class SkipBuffer : public IndexInput {
89 public:
90 SkipBuffer(const IndexInputPtr& input, int32_t length);
91 virtual ~SkipBuffer();
92
93 LUCENE_CLASS(SkipBuffer);
94
95 protected:
96 ByteArray data;
97 int64_t pointer;
98 int32_t pos;
99
100 public:
102 virtual void close();
103
105 virtual int64_t getFilePointer();
106
108 virtual int64_t length();
109
111 virtual uint8_t readByte();
112
114 virtual void readBytes(uint8_t* b, int32_t offset, int32_t length);
115
117 virtual void seek(int64_t pos);
118 };
119
120 }
121
122 #endif
Lucene::MultiLevelSkipListReader::haveSkipped
bool haveSkipped
Definition: MultiLevelSkipListReader.h:41
Lucene::MultiLevelSkipListReader::numberOfSkipLevels
int32_t numberOfSkipLevels
number of levels in this skip list
Definition: MultiLevelSkipListReader.h:32
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::SkipBuffer::data
ByteArray data
Definition: MultiLevelSkipListReader.h:93
Lucene::MultiLevelSkipListReader::skipTo
virtual int32_t skipTo(int32_t target)
Skips entries to the first beyond the current whose document number is greater than or equal to targe...
Lucene::SkipBuffer::SkipBuffer
SkipBuffer(const IndexInputPtr &input, int32_t length)
Lucene::Collection< IndexInputPtr >
Lucene::SkipBuffer::readBytes
virtual void readBytes(uint8_t *b, int32_t offset, int32_t length)
Reads a specified number of bytes into an array at the specified offset.
Lucene::SkipBuffer::pos
int32_t pos
Definition: MultiLevelSkipListReader.h:98
Lucene::MultiLevelSkipListReader::skipInterval
Collection< int32_t > skipInterval
Definition: MultiLevelSkipListReader.h:45
Lucene::MultiLevelSkipListReader::readSkipData
virtual int32_t readSkipData(int32_t level, const IndexInputPtr &skipStream)=0
Subclasses must implement the actual skip data encoding in this method.
Lucene::MultiLevelSkipListReader::skipStream
Collection< IndexInputPtr > skipStream
Definition: MultiLevelSkipListReader.h:43
Lucene::MultiLevelSkipListReader::numSkipped
Collection< int32_t > numSkipped
Definition: MultiLevelSkipListReader.h:46
Lucene::MultiLevelSkipListReader::getDoc
virtual int32_t getDoc()
Returns the id of the doc to which the last call of skipTo(int) has skipped.
Lucene::SkipBuffer::~SkipBuffer
virtual ~SkipBuffer()
Lucene::MultiLevelSkipListReader::~MultiLevelSkipListReader
virtual ~MultiLevelSkipListReader()
Lucene::SkipBuffer::close
virtual void close()
Closes the stream to further operations.
Lucene::MultiLevelSkipListReader::numberOfLevelsToBuffer
int32_t numberOfLevelsToBuffer
Defines the number of top skip levels to buffer in memory. Reducing this number results in less memor...
Definition: MultiLevelSkipListReader.h:38
Lucene::IndexInput
Abstract base class for input from a file in a Directory. A random-access input stream....
Definition: IndexInput.h:17
Lucene::MultiLevelSkipListReader::MultiLevelSkipListReader
MultiLevelSkipListReader(const IndexInputPtr &skipStream, int32_t maxSkipLevels, int32_t skipInterval)
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::MultiLevelSkipListReader::childPointer
Collection< int64_t > childPointer
Definition: MultiLevelSkipListReader.h:50
Lucene::MultiLevelSkipListReader::maxNumberOfSkipLevels
int32_t maxNumberOfSkipLevels
the maximum number of skip levels possible for this index
Definition: MultiLevelSkipListReader.h:25
Lucene::SkipBuffer
Used to buffer the top skip levels.
Definition: MultiLevelSkipListReader.h:88
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::IndexInputPtr
boost::shared_ptr< IndexInput > IndexInputPtr
Definition: LuceneTypes.h:493
IndexInput.h
Lucene::MultiLevelSkipListReader::init
virtual void init(int64_t skipPointer, int32_t df)
Initializes the reader.
Lucene::MultiLevelSkipListReader::close
virtual void close()
Lucene::MultiLevelSkipListReader::lastDoc
int32_t lastDoc
Definition: MultiLevelSkipListReader.h:49
Lucene::MultiLevelSkipListReader::seekChild
virtual void seekChild(int32_t level)
Seeks the skip entry on the given level.
Lucene::SkipBuffer::readByte
virtual uint8_t readByte()
Reads and returns a single byte.
Lucene::MultiLevelSkipListReader
This abstract class reads skip lists with multiple levels.
Definition: MultiLevelSkipListReader.h:20
Lucene::MultiLevelSkipListReader::lastChildPointer
int64_t lastChildPointer
Definition: MultiLevelSkipListReader.h:51
Lucene::MultiLevelSkipListReader::setLastSkipData
virtual void setLastSkipData(int32_t level)
Copies the values of the last read skip entry on this level.
Lucene::MultiLevelSkipListReader::skipDoc
Collection< int32_t > skipDoc
Definition: MultiLevelSkipListReader.h:48
Lucene::SkipBuffer::pointer
int64_t pointer
Definition: MultiLevelSkipListReader.h:97
Lucene::SkipBuffer::getFilePointer
virtual int64_t getFilePointer()
Returns the current position in this file, where the next read will occur.
Lucene::MultiLevelSkipListReader::skipPointer
Collection< int64_t > skipPointer
Definition: MultiLevelSkipListReader.h:44
Lucene::SkipBuffer::length
virtual int64_t length()
The number of bytes in the file.
Lucene::MultiLevelSkipListReader::loadSkipLevels
virtual void loadSkipLevels()
Loads the skip levels.
Lucene::MultiLevelSkipListReader::docCount
int32_t docCount
Definition: MultiLevelSkipListReader.h:40
Lucene::MultiLevelSkipListReader::loadNextSkip
virtual bool loadNextSkip(int32_t level)
Lucene::MultiLevelSkipListReader::inputIsBuffered
bool inputIsBuffered
Definition: MultiLevelSkipListReader.h:53
Lucene::SkipBuffer::seek
virtual void seek(int64_t pos)
Sets current position in this file, where the next read will occur.

clucene.sourceforge.net