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


RAMInputStream.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 RAMINPUTSTREAM_H
8 #define RAMINPUTSTREAM_H
9 
10 #include "IndexInput.h"
11 
12 namespace Lucene {
13 
15 class RAMInputStream : public IndexInput {
16 public:
18  RAMInputStream(const RAMFilePtr& f);
19  virtual ~RAMInputStream();
20 
22 
23 public:
24  static const int32_t BUFFER_SIZE;
25 
26 protected:
28  int64_t _length;
29  ByteArray currentBuffer;
31  int32_t bufferPosition;
32  int64_t bufferStart;
33  int32_t bufferLength;
34 
35 public:
37  virtual void close();
38 
40  virtual int64_t length();
41 
44  virtual uint8_t readByte();
45 
51  virtual void readBytes(uint8_t* b, int32_t offset, int32_t length);
52 
55  virtual int64_t getFilePointer();
56 
59  virtual void seek(int64_t pos);
60 
62  virtual LuceneObjectPtr clone(const LuceneObjectPtr& other = LuceneObjectPtr());
63 
64 protected:
65  void switchCurrentBuffer(bool enforceEOF);
66 };
67 
68 }
69 
70 #endif
RAMFilePtr file
Definition: RAMInputStream.h:27
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.
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
int32_t currentBufferIndex
Definition: RAMInputStream.h:30
int64_t bufferStart
Definition: RAMInputStream.h:32
int64_t _length
Definition: RAMInputStream.h:28
int32_t bufferLength
Definition: RAMInputStream.h:33
virtual int64_t length()
The number of bytes in the file.
void switchCurrentBuffer(bool enforceEOF)
virtual void seek(int64_t pos)
Sets current position in this file, where the next read will occur.
virtual uint8_t readByte()
Reads and returns a single byte.
static const int32_t BUFFER_SIZE
Definition: RAMInputStream.h:21
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Definition: AbstractAllTermDocs.h:12
ByteArray currentBuffer
Definition: RAMInputStream.h:29
A memory-resident IndexInput implementation.
Definition: RAMInputStream.h:15
virtual void close()
Closes the stream to further operations.
boost::shared_ptr< RAMFile > RAMFilePtr
Definition: LuceneTypes.h:506
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a clone of this stream.
Abstract base class for input from a file in a Directory. A random-access input stream. Used for all Lucene index input operations.
Definition: IndexInput.h:17
int32_t bufferPosition
Definition: RAMInputStream.h:31
virtual int64_t getFilePointer()
Returns the current position in this file, where the next read will occur.

clucene.sourceforge.net