open-source-search-engine/RdbScan.h

93 lines
2.4 KiB
C
Raw Normal View History

2013-08-03 00:12:24 +04: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.
#ifndef _RDBSCAN_H_
#define _RDBSCAN_H_
#include "BigFile.h"
#include "Loop.h"
#include "RdbMap.h"
#include "RdbList.h"
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-11 01:45:11 +03:00
int32_t fixedDataSize ,
2014-10-30 22:36:39 +03:00
int64_t offset ,
2014-11-11 01:45:11 +03:00
int32_t bytesToRead ,
2013-08-03 00:12:24 +04:00
//key_t startKey ,
//key_t endKey ,
char *startKey ,
char *endKey ,
char keySize ,
RdbList *list , // we fill this up
void *state ,
void (* callback ) ( void *state ) ,
bool useHalfKeys ,
char rdbId,
2014-11-11 01:45:11 +03:00
int32_t niceness , // = MAX_NICENESS ,
2013-08-03 00:12:24 +04:00
bool allowPageCache , // = true ,
bool hitDisk ); // = true );
// RdbGet likes to get our list
RdbList *getList ( ) { return m_list; };
// was buffer shifted down 6 bytes to turn first key into a 12 byter?
bool wasShifted () { return m_shifted; };
void gotList ( );
// we set this list with the read buffer on read completion
RdbList *m_list;
// for doing non-blocking reads with BigFile::read()
FileState m_fstate;
// for dealing with half keys
2014-11-11 01:45:11 +03:00
int32_t m_off;
2013-08-03 00:12:24 +04:00
// shifting it
char m_shifted;
char m_rdbId;
// save for call to our gotListWrapper()
//key_t m_startKey;
char m_startKey[MAX_KEY_BYTES];
char m_endKey [MAX_KEY_BYTES];
2014-11-11 01:45:11 +03:00
int32_t m_fixedDataSize;
2013-08-03 00:12:24 +04:00
char m_useHalfKeys;
2014-11-11 01:45:11 +03:00
int32_t m_bytesToRead;
2013-08-03 00:12:24 +04:00
void (* m_callback ) ( void *state ) ;
void *m_state;
// for sanity checking
BigFile *m_file;
2014-10-30 22:36:39 +03:00
int64_t m_offset;
2013-08-03 00:12:24 +04:00
char m_ks;
// for allowing page cache
bool m_allowPageCache;
bool m_hitDisk;
};
#endif