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


FieldsReader.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 FIELDSREADER_H
8 #define FIELDSREADER_H
9 
10 #include "AbstractField.h"
11 #include "CloseableThreadLocal.h"
12 
13 namespace Lucene {
14 
16 class LPPAPI FieldsReader : public LuceneObject {
17 public:
19  FieldsReader(const FieldInfosPtr& fieldInfos, int32_t numTotalDocs, int32_t size, int32_t format, int32_t formatSize,
20  int32_t docStoreOffset, const IndexInputPtr& cloneableFieldsStream, const IndexInputPtr& cloneableIndexStream);
21  FieldsReader(const DirectoryPtr& d, const String& segment, const FieldInfosPtr& fn);
22  FieldsReader(const DirectoryPtr& d, const String& segment, const FieldInfosPtr& fn, int32_t readBufferSize, int32_t docStoreOffset = -1, int32_t size = 0);
23 
24  virtual ~FieldsReader();
25 
27 
28 protected:
30 
31  // The main fieldStream, used only for cloning.
33 
34  // This is a clone of cloneableFieldsStream used for reading documents. It should not be cloned outside of a
35  // synchronized context.
37 
40  int32_t numTotalDocs;
41  int32_t _size;
42  bool closed;
43  int32_t format;
44  int32_t formatSize;
45 
46  // The docID offset where our docs begin in the index file. This will be 0 if we have our own private file.
47  int32_t docStoreOffset;
48 
50  bool isOriginal;
51 
52 public:
56 
59  void close();
60 
61  int32_t size();
62 
64 
65  DocumentPtr doc(int32_t n, const FieldSelectorPtr& fieldSelector);
66 
69  IndexInputPtr rawDocs(Collection<int32_t> lengths, int32_t startDocID, int32_t numDocs);
70 
71 protected:
72  void ConstructReader(const DirectoryPtr& d, const String& segment, const FieldInfosPtr& fn, int32_t readBufferSize, int32_t docStoreOffset, int32_t size);
73 
74  void ensureOpen();
75 
76  void seekIndex(int32_t docID);
77 
80  void skipField(bool binary, bool compressed);
81  void skipField(bool binary, bool compressed, int32_t toRead);
82 
83  void addFieldLazy(const DocumentPtr& doc, const FieldInfoPtr& fi, bool binary, bool compressed, bool tokenize);
84  void addField(const DocumentPtr& doc, const FieldInfoPtr& fi, bool binary, bool compressed, bool tokenize);
85 
89  int32_t addFieldSize(const DocumentPtr& doc, const FieldInfoPtr& fi, bool binary, bool compressed);
90 
91  ByteArray uncompress(ByteArray b);
92  String uncompressString(ByteArray b);
93 
94  friend class LazyField;
95 };
96 
97 class LazyField : public AbstractField {
98 public:
99  LazyField(const FieldsReaderPtr& reader, const String& name, Store store, int32_t toRead, int64_t pointer, bool isBinary, bool isCompressed);
100  LazyField(const FieldsReaderPtr& reader, const String& name, Store store, Index index, TermVector termVector, int32_t toRead, int64_t pointer, bool isBinary, bool isCompressed);
101  virtual ~LazyField();
102 
104 
105 protected:
107  int32_t toRead;
108  int64_t pointer;
109 
112 
113 public:
117 
121 
124  String stringValue();
125 
126  int64_t getPointer();
127  void setPointer(int64_t pointer);
128  int32_t getToRead();
129  void setToRead(int32_t toRead);
130 
132  virtual ByteArray getBinaryValue(ByteArray result);
133 
134 protected:
136 };
137 
138 }
139 
140 #endif
Lucene::LazyField::readerValue
ReaderPtr readerValue()
The value of the field as a Reader, or null. If null, the String value, binary value,...
Lucene::FieldsReader::FieldsReader
FieldsReader(const DirectoryPtr &d, const String &segment, const FieldInfosPtr &fn)
Lucene::LazyField::pointer
int64_t pointer
Definition: FieldsReader.h:108
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::LazyField
Definition: FieldsReader.h:97
Lucene::FieldsReader::skipField
void skipField(bool binary, bool compressed, int32_t toRead)
Lucene::FieldsReader::ensureOpen
void ensureOpen()
Lucene::Collection< int32_t >
Lucene::LazyField::getBinaryValue
virtual ByteArray getBinaryValue(ByteArray result)
Return the raw byte[] for the binary field.
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::FieldsReader::numTotalDocs
int32_t numTotalDocs
Definition: FieldsReader.h:40
Lucene::AbstractField::name
virtual String name()
Returns the name of the field as an interned string. For example "date", "title", "body",...
Lucene::CloseableThreadLocal
General purpose thread-local map.
Definition: CloseableThreadLocal.h:16
Lucene::FieldsReader::addFieldLazy
void addFieldLazy(const DocumentPtr &doc, const FieldInfoPtr &fi, bool binary, bool compressed, bool tokenize)
Lucene::LazyField::isCompressed
bool isCompressed
Definition: FieldsReader.h:111
Lucene::FieldsReader::skipField
void skipField(bool binary, bool compressed)
Skip the field. We still have to read some of the information about the field, but can skip past the ...
Lucene::FieldInfosPtr
boost::shared_ptr< FieldInfos > FieldInfosPtr
Definition: LuceneTypes.h:127
Lucene::ReaderPtr
boost::shared_ptr< Reader > ReaderPtr
Definition: LuceneTypes.h:547
Lucene::FieldsReader::close
void close()
Closes the underlying IndexInput streams, including any ones associated with a lazy implementation of...
Lucene::FieldsReader::indexStream
IndexInputPtr indexStream
Definition: FieldsReader.h:39
Lucene::AbstractField
Definition: AbstractField.h:14
Lucene::AbstractField::isBinary
virtual bool isBinary()
True if the value of the field is stored as binary.
Lucene::FieldsReader::FieldsReader
FieldsReader(const DirectoryPtr &d, const String &segment, const FieldInfosPtr &fn, int32_t readBufferSize, int32_t docStoreOffset=-1, int32_t size=0)
Lucene::FieldsReader::cloneableFieldsStream
IndexInputPtr cloneableFieldsStream
Definition: FieldsReader.h:32
Lucene::FieldsReader::fieldsStreamTL
CloseableThreadLocal< IndexInput > fieldsStreamTL
Definition: FieldsReader.h:49
Lucene::FieldsReader::size
int32_t size()
Lucene::LazyField::getFieldStream
IndexInputPtr getFieldStream()
Lucene::LazyField::tokenStreamValue
TokenStreamPtr tokenStreamValue()
The value of the field as a TokenStream, or null. If null, the Reader value, String value,...
Lucene::FieldsReader::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a cloned FieldsReader that shares open IndexInputs with the original one. It is the caller's ...
Lucene::LazyField::~LazyField
virtual ~LazyField()
Lucene::FieldsReader::format
int32_t format
Definition: FieldsReader.h:43
Lucene::FieldsReader::fieldsStream
IndexInputPtr fieldsStream
Definition: FieldsReader.h:36
AbstractField.h
Lucene::DocumentPtr
boost::shared_ptr< Document > DocumentPtr
Definition: LuceneTypes.h:74
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::FieldInfoPtr
boost::shared_ptr< FieldInfo > FieldInfoPtr
Definition: LuceneTypes.h:126
Lucene::LazyField::stringValue
String stringValue()
The value of the field as a String, or null. If null, the Reader value, binary value,...
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::FieldsReader::closed
bool closed
Definition: FieldsReader.h:42
Lucene::FieldsReaderWeakPtr
boost::weak_ptr< FieldsReader > FieldsReaderWeakPtr
Definition: LuceneTypes.h:131
Lucene::FieldsReader::fieldInfos
FieldInfosPtr fieldInfos
Definition: FieldsReader.h:26
Lucene::FieldsReader::canReadRawDocs
bool canReadRawDocs()
Lucene::IndexInputPtr
boost::shared_ptr< IndexInput > IndexInputPtr
Definition: LuceneTypes.h:493
Lucene::FieldsReader::~FieldsReader
virtual ~FieldsReader()
Lucene::FieldsReader
Class responsible for access to stored document fields. It uses <segment>.fdt and <segment>....
Definition: FieldsReader.h:16
Lucene::LazyField::setPointer
void setPointer(int64_t pointer)
Lucene::AbstractField::Store
Store
Specifies whether and how a field should be stored.
Definition: AbstractField.h:17
Lucene::FieldsReader::FieldsReader
FieldsReader(const FieldInfosPtr &fieldInfos, int32_t numTotalDocs, int32_t size, int32_t format, int32_t formatSize, int32_t docStoreOffset, const IndexInputPtr &cloneableFieldsStream, const IndexInputPtr &cloneableIndexStream)
Used only by clone.
Lucene::LazyField::getToRead
int32_t getToRead()
Lucene::FieldsReader::addFieldSize
int32_t addFieldSize(const DocumentPtr &doc, const FieldInfoPtr &fi, bool binary, bool compressed)
Add the size of field as a byte[] containing the 4 bytes of the integer byte size (high order byte fi...
Lucene::FieldsReader::addField
void addField(const DocumentPtr &doc, const FieldInfoPtr &fi, bool binary, bool compressed, bool tokenize)
Lucene::FieldsReader::uncompress
ByteArray uncompress(ByteArray b)
Lucene::FieldsReader::rawDocs
IndexInputPtr rawDocs(Collection< int32_t > lengths, int32_t startDocID, int32_t numDocs)
Returns the length in bytes of each raw document in a contiguous range of length numDocs starting wit...
Lucene::LazyField::getPointer
int64_t getPointer()
Lucene::FieldsReader::isOriginal
bool isOriginal
Definition: FieldsReader.h:50
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
Lucene::FieldsReader::ConstructReader
void ConstructReader(const DirectoryPtr &d, const String &segment, const FieldInfosPtr &fn, int32_t readBufferSize, int32_t docStoreOffset, int32_t size)
Lucene::FieldsReader::docStoreOffset
int32_t docStoreOffset
Definition: FieldsReader.h:47
Lucene::TokenStreamPtr
boost::shared_ptr< TokenStream > TokenStreamPtr
Definition: LuceneTypes.h:63
Lucene::FieldSelectorPtr
boost::shared_ptr< FieldSelector > FieldSelectorPtr
Definition: LuceneTypes.h:77
Lucene::LazyField::setToRead
void setToRead(int32_t toRead)
Lucene::AbstractField::Index
Index
Specifies whether and how a field should be indexed.
Definition: AbstractField.h:28
Lucene::FieldsReader::seekIndex
void seekIndex(int32_t docID)
Lucene::FieldsReaderPtr
boost::shared_ptr< FieldsReader > FieldsReaderPtr
Definition: LuceneTypes.h:131
Lucene::FieldsReader::doc
DocumentPtr doc(int32_t n, const FieldSelectorPtr &fieldSelector)
Lucene::LazyField::LazyField
LazyField(const FieldsReaderPtr &reader, const String &name, Store store, int32_t toRead, int64_t pointer, bool isBinary, bool isCompressed)
Lucene::FieldsReader::uncompressString
String uncompressString(ByteArray b)
Lucene::FieldsReader::formatSize
int32_t formatSize
Definition: FieldsReader.h:44
Lucene::LazyField::toRead
int32_t toRead
Definition: FieldsReader.h:107
Lucene::LazyField::LazyField
LazyField(const FieldsReaderPtr &reader, const String &name, Store store, Index index, TermVector termVector, int32_t toRead, int64_t pointer, bool isBinary, bool isCompressed)
Lucene::FieldsReader::cloneableIndexStream
IndexInputPtr cloneableIndexStream
Definition: FieldsReader.h:38
Lucene::AbstractField::TermVector
TermVector
Specifies whether and how a field should have term vectors.
Definition: AbstractField.h:57
Lucene::FieldsReader::_size
int32_t _size
Definition: FieldsReader.h:41
CloseableThreadLocal.h
Lucene::LazyField::_reader
FieldsReaderWeakPtr _reader
Definition: FieldsReader.h:103

clucene.sourceforge.net