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
TermVectorsReader.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 TERMVECTORSREADER_H
8 #define TERMVECTORSREADER_H
9
10 #include "TermVectorMapper.h"
11
12 namespace Lucene
13 {
14 class TermVectorsReader : public LuceneObject
15 {
16 public:
17 TermVectorsReader();
18 TermVectorsReader(DirectoryPtr d, const String& segment, FieldInfosPtr fieldInfos);
19 TermVectorsReader(DirectoryPtr d, const String& segment, FieldInfosPtr fieldInfos,
20 int32_t readBufferSize, int32_t docStoreOffset = -1, int32_t size = 0);
21 virtual ~TermVectorsReader();
22
23 LUCENE_CLASS(TermVectorsReader);
24
25 public:
27 static const int32_t FORMAT_VERSION;
28
30 static const int32_t FORMAT_VERSION2;
31
33 static const int32_t FORMAT_UTF8_LENGTH_IN_BYTES;
34
36 static const int32_t FORMAT_CURRENT;
37
39 static const int32_t FORMAT_SIZE;
40
41 static const uint8_t STORE_POSITIONS_WITH_TERMVECTOR;
42 static const uint8_t STORE_OFFSET_WITH_TERMVECTOR;
43
44 protected:
45 FieldInfosPtr fieldInfos;
46
47 IndexInputPtr tvx;
48 IndexInputPtr tvd;
49 IndexInputPtr tvf;
50 int32_t _size;
51 int32_t numTotalDocs;
52
54 int32_t docStoreOffset;
55
56 int32_t format;
57
58 public:
60 IndexInputPtr getTvdStream();
61
63 IndexInputPtr getTvfStream();
64
65 bool canReadRawDocs();
66
70 void rawDocs(Collection<int32_t> tvdLengths, Collection<int32_t> tvfLengths, int32_t startDocID, int32_t numDocs);
71
72 void close();
73
75 int32_t size();
76
77 void get(int32_t docNum, const String& field, TermVectorMapperPtr mapper);
78
84 TermFreqVectorPtr get(int32_t docNum, const String& field);
85
90 Collection<TermFreqVectorPtr> get(int32_t docNum);
91
92 void get(int32_t docNumber, TermVectorMapperPtr mapper);
93
94 virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());
95
96 protected:
97 void ConstructReader(DirectoryPtr d, const String& segment, FieldInfosPtr fieldInfos, int32_t readBufferSize, int32_t docStoreOffset, int32_t size);
98
99 void seekTvx(int32_t docNum);
100
101 int32_t checkValidFormat(IndexInputPtr in);
102
104 Collection<String> readFields(int32_t fieldCount);
105
107 Collection<int64_t> readTvfPointers(int32_t fieldCount);
108
109 Collection<TermFreqVectorPtr> readTermVectors(int32_t docNum, Collection<String> fields, Collection<int64_t> tvfPointers);
110 void readTermVectors(Collection<String> fields, Collection<int64_t> tvfPointers, TermVectorMapperPtr mapper);
111
115 void readTermVector(const String& field, int64_t tvfPointer, TermVectorMapperPtr mapper);
116 };
117
119 class ParallelArrayTermVectorMapper : public TermVectorMapper
120 {
121 public:
122 ParallelArrayTermVectorMapper();
123 virtual ~ParallelArrayTermVectorMapper();
124
125 LUCENE_CLASS(ParallelArrayTermVectorMapper);
126
127 protected:
128 Collection<String> terms;
129 Collection<int32_t> termFreqs;
130 Collection< Collection<int32_t> > positions;
131 Collection< Collection<TermVectorOffsetInfoPtr> > offsets;
132 int32_t currentPosition;
133 bool storingOffsets;
134 bool storingPositions;
135 String field;
136
137 public:
140 virtual void setExpectations(const String& field, int32_t numTerms, bool storeOffsets, bool storePositions);
141
143 virtual void map(const String& term, int32_t frequency, Collection<TermVectorOffsetInfoPtr> offsets, Collection<int32_t> positions);
144
147 TermFreqVectorPtr materializeVector();
148 };
149 }
150
151 #endif

clucene.sourceforge.net