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
FieldsReader.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 FIELDSREADER_H
8 #define FIELDSREADER_H
9
10 #include "AbstractField.h"
11 #include "CloseableThreadLocal.h"
12
13 namespace Lucene
14 {
16 class FieldsReader : public LuceneObject
17 {
18 public:
20 FieldsReader(FieldInfosPtr fieldInfos, int32_t numTotalDocs, int32_t size, int32_t format, int32_t formatSize,
21 int32_t docStoreOffset, IndexInputPtr cloneableFieldsStream, IndexInputPtr cloneableIndexStream);
22 FieldsReader(DirectoryPtr d, const String& segment, FieldInfosPtr fn);
23 FieldsReader(DirectoryPtr d, const String& segment, FieldInfosPtr fn, int32_t readBufferSize, int32_t docStoreOffset = -1, int32_t size = 0);
24
25 virtual ~FieldsReader();
26
27 LUCENE_CLASS(FieldsReader);
28
29 protected:
30 FieldInfosPtr fieldInfos;
31
32 // The main fieldStream, used only for cloning.
33 IndexInputPtr cloneableFieldsStream;
34
35 // This is a clone of cloneableFieldsStream used for reading documents. It should not be cloned outside of a
36 // synchronized context.
37 IndexInputPtr fieldsStream;
38
39 IndexInputPtr cloneableIndexStream;
40 IndexInputPtr indexStream;
41 int32_t numTotalDocs;
42 int32_t _size;
43 bool closed;
44 int32_t format;
45 int32_t formatSize;
46
47 // The docID offset where our docs begin in the index file. This will be 0 if we have our own private file.
48 int32_t docStoreOffset;
49
50 CloseableThreadLocal<IndexInput> fieldsStreamTL;
51 bool isOriginal;
52
53 public:
56 virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());
57
60 void close();
61
62 int32_t size();
63
64 bool canReadRawDocs();
65
66 DocumentPtr doc(int32_t n, FieldSelectorPtr fieldSelector);
67
70 IndexInputPtr rawDocs(Collection<int32_t> lengths, int32_t startDocID, int32_t numDocs);
71
72 protected:
73 void ConstructReader(DirectoryPtr d, const String& segment, FieldInfosPtr fn, int32_t readBufferSize, int32_t docStoreOffset, int32_t size);
74
75 void ensureOpen();
76
77 void seekIndex(int32_t docID);
78
81 void skipField(bool binary, bool compressed);
82 void skipField(bool binary, bool compressed, int32_t toRead);
83
84 void addFieldLazy(DocumentPtr doc, FieldInfoPtr fi, bool binary, bool compressed, bool tokenize);
85 void addField(DocumentPtr doc, FieldInfoPtr fi, bool binary, bool compressed, bool tokenize);
86
90 int32_t addFieldSize(DocumentPtr doc, FieldInfoPtr fi, bool binary, bool compressed);
91
92 ByteArray uncompress(ByteArray b);
93 String uncompressString(ByteArray b);
94
95 friend class LazyField;
96 };
97
98 class LazyField : public AbstractField
99 {
100 public:
101 LazyField(FieldsReaderPtr reader, const String& name, Store store, int32_t toRead, int64_t pointer, bool isBinary, bool isCompressed);
102 LazyField(FieldsReaderPtr reader, const String& name, Store store, Index index, TermVector termVector, int32_t toRead, int64_t pointer, bool isBinary, bool isCompressed);
103 virtual ~LazyField();
104
105 LUCENE_CLASS(LazyField);
106
107 protected:
108 FieldsReaderWeakPtr _reader;
109 int32_t toRead;
110 int64_t pointer;
111
113 bool isCompressed;
114
115 public:
118 ReaderPtr readerValue();
119
122 TokenStreamPtr tokenStreamValue();
123
126 String stringValue();
127
128 int64_t getPointer();
129 void setPointer(int64_t pointer);
130 int32_t getToRead();
131 void setToRead(int32_t toRead);
132
134 virtual ByteArray getBinaryValue(ByteArray result);
135
136 protected:
137 IndexInputPtr getFieldStream();
138 };
139 }
140
141 #endif

clucene.sourceforge.net