Files

92 lines
2.4 KiB
C
Raw Permalink Normal View History

2013-08-02 13:12:24 -07:00
// Matt Wells, copyright Sep 2000
// . used exculsively by RdbGet
// . used for scanning a key-range of records
// . does non-blocking disk reads
// . set loop to NULL to do blocking disk reads
// . we set m_errno to a positive value on error, so check it!
// . originally you could call getNextRecord() before the entire read
// was complete.
2016-03-08 22:14:30 +01:00
#ifndef GB_RDBSCAN_H
#define GB_RDBSCAN_H
2013-08-02 13:12:24 -07:00
#include "BigFile.h"
#include "Loop.h"
#include "RdbMap.h"
#include "RdbList.h"
2016-08-25 17:33:56 +02:00
#include "rdbid_t.h"
2013-08-02 13:12:24 -07:00
class RdbScan {
public:
// . returns false if blocked, true otherwise
// . sets errno on error
// . call this to start the read (sets up your key-range read too)
// . endKey must be provided
// . TODO: can we do multiple "simultaneous" non-blocking
// reads on the same fd?
// . we need array of files so BigFile::filecb() knows when file nuked
bool setRead ( BigFile *file ,
2014-11-10 14:45:11 -08:00
int32_t fixedDataSize ,
2014-10-30 13:36:39 -06:00
int64_t offset ,
2014-11-10 14:45:11 -08:00
int32_t bytesToRead ,
2013-08-02 13:12:24 -07:00
char *startKey ,
char *endKey ,
char keySize ,
RdbList *list , // we fill this up
void *state ,
void (* callback ) ( void *state ) ,
bool useHalfKeys ,
2016-08-25 17:33:56 +02:00
rdbid_t rdbId,
2014-11-10 14:45:11 -08:00
int32_t niceness , // = MAX_NICENESS ,
2013-08-02 13:12:24 -07:00
bool hitDisk ); // = true );
// RdbGet likes to get our list
RdbList *getList ( ) { return m_rdblist; }
2013-08-02 13:12:24 -07:00
// was buffer shifted down 6 bytes to turn first key into a 12 byter?
2016-09-29 15:47:21 +02:00
bool wasShifted() const { return m_shifted; }
char shiftCount() const { return m_shifted; }
int32_t getBytesToRead() const { return m_bytesToRead; }
int64_t getOffset() const { return m_offset; }
private:
static void gotListWrapper0(void *state);
void gotListWrapper();
2013-08-02 13:12:24 -07:00
void gotList ( );
// we set this list with the read buffer on read completion
RdbList *m_rdblist;
2013-08-02 13:12:24 -07:00
// for doing non-blocking reads with BigFile::read()
FileState m_fstate;
// for dealing with half keys
2014-11-10 14:45:11 -08:00
int32_t m_off;
2013-08-02 13:12:24 -07:00
// shifting it
char m_shifted;
2016-08-25 17:33:56 +02:00
rdbid_t m_rdbId;
2013-08-02 13:12:24 -07:00
// save for call to our gotListWrapper()
char m_startKey[MAX_KEY_BYTES];
char m_endKey [MAX_KEY_BYTES];
2014-11-10 14:45:11 -08:00
int32_t m_fixedDataSize;
2013-08-02 13:12:24 -07:00
char m_useHalfKeys;
2014-11-10 14:45:11 -08:00
int32_t m_bytesToRead;
2013-08-02 13:12:24 -07:00
void (* m_callback ) ( void *state ) ;
void *m_state;
// for sanity checking
BigFile *m_file;
2014-10-30 13:36:39 -06:00
int64_t m_offset;
2013-08-02 13:12:24 -07:00
char m_ks;
bool m_hitDisk;
};
2016-03-08 22:14:30 +01:00
#endif // GB_RDBSCAN_H