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


Loading...
Searching...
No Matches
CompoundFileReader.h
Go to the documentation of this file.
1
2// 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 COMPOUNDFILEREADER_H
8#define COMPOUNDFILEREADER_H
9
10#include "Directory.h"
11#include "BufferedIndexInput.h"
12
13namespace Lucene {
14
18class LPPAPI CompoundFileReader : public Directory {
19public:
20 CompoundFileReader(const DirectoryPtr& dir, const String& name);
21 CompoundFileReader(const DirectoryPtr& dir, const String& name, int32_t readBufferSize);
23
25
26protected:
27 struct FileEntry {
28 FileEntry(int64_t offset = 0, int64_t length = 0) {
29 this->offset = offset;
30 this->length = length;
31 }
32 int64_t offset;
33 int64_t length;
34 };
35 typedef boost::shared_ptr<FileEntry> FileEntryPtr;
37
39 String fileName;
43
44protected:
45 void ConstructReader(const DirectoryPtr& dir, const String& name, int32_t readBufferSize);
46
47public:
49 String getName();
50 virtual void close();
51 virtual IndexInputPtr openInput(const String& name);
52 virtual IndexInputPtr openInput(const String& name, int32_t bufferSize);
53
56
58 virtual bool fileExists(const String& name);
59
61 virtual uint64_t fileModified(const String& name);
62
64 virtual void touchFile(const String& name);
65
67 virtual void deleteFile(const String& name);
68
70 virtual void renameFile(const String& from, const String& to);
71
73 virtual int64_t fileLength(const String& name);
74
76 virtual IndexOutputPtr createOutput(const String& name);
77
79 virtual LockPtr makeLock(const String& name);
80};
81
83class LPPAPI CSIndexInput : public BufferedIndexInput {
84public:
86 CSIndexInput(const IndexInputPtr& base, int64_t fileOffset, int64_t length);
87 CSIndexInput(const IndexInputPtr& base, int64_t fileOffset, int64_t length, int32_t readBufferSize);
88 virtual ~CSIndexInput();
89
91
92public:
94 int64_t fileOffset;
95 int64_t _length;
96
97public:
99 virtual void close();
100
101 virtual int64_t length();
102
105
106protected:
111 virtual void readInternal(uint8_t* b, int32_t offset, int32_t length);
112
115 virtual void seekInternal(int64_t pos);
116};
117
118}
119
120#endif
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Base implementation class for buffered IndexInput.
Definition BufferedIndexInput.h:15
Implementation of an IndexInput that reads from a portion of the compound file.
Definition CompoundFileReader.h:83
CSIndexInput(const IndexInputPtr &base, int64_t fileOffset, int64_t length)
virtual int64_t length()
The number of bytes in the file.
virtual void close()
Closes the stream to further operations.
int64_t fileOffset
Definition CompoundFileReader.h:94
int64_t _length
Definition CompoundFileReader.h:95
IndexInputPtr base
Definition CompoundFileReader.h:93
virtual void readInternal(uint8_t *b, int32_t offset, int32_t length)
Implements buffer refill. Reads bytes from the current position in the input.
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a clone of this stream.
CSIndexInput(const IndexInputPtr &base, int64_t fileOffset, int64_t length, int32_t readBufferSize)
virtual void seekInternal(int64_t pos)
Implements seek. Sets current position in this file, where the next readInternal(byte[],...
Class for accessing a compound stream. This class implements a directory, but is limited to only read...
Definition CompoundFileReader.h:18
boost::shared_ptr< FileEntry > FileEntryPtr
Definition CompoundFileReader.h:35
virtual LockPtr makeLock(const String &name)
Not implemented.
virtual IndexOutputPtr createOutput(const String &name)
Not implemented.
virtual IndexInputPtr openInput(const String &name, int32_t bufferSize)
Returns a stream reading an existing file, with the specified read buffer size. The particular Direct...
virtual void close()
Closes the store.
MapStringFileEntryPtr entries
Definition CompoundFileReader.h:42
int32_t readBufferSize
Definition CompoundFileReader.h:40
virtual int64_t fileLength(const String &name)
Returns the length of a file in the directory.
virtual HashSet< String > listAll()
Returns an array of strings, one for each file in the directory.
virtual void touchFile(const String &name)
Set the modified time of the compound file to now.
void ConstructReader(const DirectoryPtr &dir, const String &name, int32_t readBufferSize)
String fileName
Definition CompoundFileReader.h:39
CompoundFileReader(const DirectoryPtr &dir, const String &name)
virtual IndexInputPtr openInput(const String &name)
Returns a stream reading an existing file.
IndexInputPtr stream
Definition CompoundFileReader.h:41
virtual void renameFile(const String &from, const String &to)
Not implemented.
HashMap< String, FileEntryPtr > MapStringFileEntryPtr
Definition CompoundFileReader.h:36
virtual uint64_t fileModified(const String &name)
Returns the time the compound file was last modified.
virtual bool fileExists(const String &name)
Returns true if a file with the given name exists.
CompoundFileReader(const DirectoryPtr &dir, const String &name, int32_t readBufferSize)
virtual void deleteFile(const String &name)
Not implemented.
DirectoryPtr directory
Definition CompoundFileReader.h:38
DirectoryPtr getDirectory()
A Directory is a flat list of files. Files may be written once, when they are created....
Definition Directory.h:18
Utility template class to handle hash maps that can be safely copied and shared.
Definition HashMap.h:17
Utility template class to handle hash set collections that can be safely copied and shared.
Definition HashSet.h:17
Definition AbstractAllTermDocs.h:12
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
boost::shared_ptr< Lock > LockPtr
Definition LuceneTypes.h:496
boost::shared_ptr< IndexInput > IndexInputPtr
Definition LuceneTypes.h:493
boost::shared_ptr< Directory > DirectoryPtr
Definition LuceneTypes.h:489
boost::shared_ptr< IndexOutput > IndexOutputPtr
Definition LuceneTypes.h:494
Definition CompoundFileReader.h:27
FileEntry(int64_t offset=0, int64_t length=0)
Definition CompoundFileReader.h:28
int64_t offset
Definition CompoundFileReader.h:32
int64_t length
Definition CompoundFileReader.h:33

clucene.sourceforge.net