Files

188 lines
4.8 KiB
C
Raw Permalink Normal View History

2013-08-02 13:12:24 -07:00
// Matt Wells, copyright Sep 2001
// . get a lists from tree, cache and disk
2016-03-08 22:14:30 +01:00
#ifndef GB_MSG5_H
#define GB_MSG5_H
2013-08-02 13:12:24 -07:00
#include "Msg3.h"
#include "RdbList.h"
2016-07-22 13:40:55 +02:00
#include "JobScheduler.h" //job_exit_t
#include "rdbid_t.h"
#include "GbSignature.h"
2016-07-22 13:40:55 +02:00
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
extern int32_t g_numCorrupt;
2013-08-02 13:12:24 -07:00
2016-09-15 15:32:48 +02:00
extern bool g_isDumpingRdbFromMain;
2013-08-02 13:12:24 -07:00
class Msg2;
2013-08-02 13:12:24 -07:00
class Msg5 {
public:
Msg5();
~Msg5();
// . set "list" with the asked for records
// . returns false if blocked, true otherwise
// . sets errno on error
// . RdbList will be populated with the records you want
// . we pass ourselves back to callback since requestHandler()s of
// various msg classes often do not have any context/state, and they
// construct us in a C wrapper so they need to delete us when
// they're done with us
// . if maxCacheAge is > 0, we lookup in cache first
bool getList ( rdbid_t rdbId,
collnum_t collnum ,
2013-08-02 13:12:24 -07:00
RdbList *list ,
2016-04-11 11:48:30 +02:00
const void *startKey ,
const void *endKey ,
2014-11-10 14:45:11 -08:00
int32_t recSizes , // requestd scan size(-1 all)
2013-08-02 13:12:24 -07:00
bool includeTree ,
2014-11-10 14:45:11 -08:00
int32_t startFileNum , // first file to scan
int32_t numFiles , // rel.to startFileNum,-1 all
2013-08-02 13:12:24 -07:00
void *state , // for callback
2016-06-21 12:06:20 +02:00
void (* callback ) ( void *state, RdbList *list, Msg5 *msg5 ),
2014-11-10 14:45:11 -08:00
int32_t niceness ,
2013-08-02 13:12:24 -07:00
bool doErrorCorrection ,
int32_t maxRetries,
2017-05-08 15:45:34 +02:00
bool isRealMerge);
2013-08-02 13:12:24 -07:00
bool getSingleUnmergedList(rdbid_t rdbId,
collnum_t collnum,
RdbList *list,
const void *startKey,
const void *endKey,
int32_t recSizes, // requested scan size(-1 all)
int32_t fileNum, // file to scan
void *state, // for callback
void (*callback)(void *state, RdbList *list, Msg5 *msg5),
int32_t niceness);
bool getTreeList(RdbList *result, rdbid_t rdbId, collnum_t collnum, const void *startKey, const void *endKey);
bool getTreeList(RdbList *result, const void *startKey, const void *endKey, int32_t *numPositiveRecs,
int32_t *numNegativeRecs, int32_t *memUsedByTree, int32_t *numUsedNodes);
2013-08-02 13:12:24 -07:00
// frees m_treeList, m_diskList (can be quite a lot of mem 2+ megs)
void reset();
2016-08-12 14:24:36 +02:00
bool isWaitingForList() const { return m_waitingForList; }
int32_t minRecSizes() const { return m_minRecSizes; }
declare_signature
2016-08-12 14:24:36 +02:00
// we add our m_finalList(s) to this, the user's list
RdbList *m_list;
// private:
// holds all RdbLists from disk
Msg3 m_msg3;
2016-08-30 14:33:42 +02:00
private:
2016-08-12 14:24:36 +02:00
// holds list parms
char m_startKey[MAX_KEY_BYTES];
char m_endKey[MAX_KEY_BYTES];
2013-08-02 13:12:24 -07:00
// called to read lists from disk using Msg3
bool readList();
// keep public for doneScanningWrapper to call
bool gotList();
bool gotList2();
// does readList() need to be called again due to negative rec
// annihilation?
bool needsRecall();
bool doneMerging ();
// . when a list is bad we try to patch it by getting a list from
// a host in our redundancy group
// . we also get a local list from ALL files and tree to remove
// recs we already have from the remote list
bool getRemoteList ( );
bool gotRemoteList ( );
2016-07-22 13:40:55 +02:00
// hold the caller of getList()'s callback here
void (* m_callback )( void *state , RdbList *list , Msg5 *msg );
void *m_state ;
char m_calledCallback;
2013-08-02 13:12:24 -07:00
// holds list from tree
RdbList m_treeList;
RdbList m_dummy;
bool m_includeTree;
2014-11-10 14:45:11 -08:00
int32_t m_numFiles;
2018-01-05 11:21:51 +01:00
int32_t m_numSources;
2014-11-10 14:45:11 -08:00
int32_t m_startFileNum;
int32_t m_minRecSizes;
rdbid_t m_rdbId;
2013-08-02 13:12:24 -07:00
// . cache may modify these
// . gotLists() may modify these before reading more
char m_fileStartKey[MAX_KEY_BYTES];
2014-11-10 14:45:11 -08:00
int32_t m_newMinRecSizes;
int32_t m_round;
int32_t m_totalSize;
2013-08-02 13:12:24 -07:00
bool m_readAbsolutelyNothing;
2014-11-10 14:45:11 -08:00
int32_t m_niceness;
2013-08-02 13:12:24 -07:00
// error correction stuff
bool m_doErrorCorrection;
bool m_hadCorruption;
class Msg0 *m_msg0;
// for timing debug
2014-10-30 13:36:39 -06:00
int64_t m_startTime;
2013-08-02 13:12:24 -07:00
// hold pointers to lists to merge
RdbList *m_listPtrs [ MAX_RDB_FILES + 1 ]; // plus tree
2014-11-10 14:45:11 -08:00
int32_t m_numListPtrs;
2013-08-02 13:12:24 -07:00
bool m_removeNegRecs;
char m_minEndKey[MAX_KEY_BYTES];
// info for truncating and passing to RdbList::indexMerge_r()
char m_prevKey[MAX_KEY_BYTES];
2014-11-10 14:45:11 -08:00
int32_t m_oldListSize;
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_maxRetries;
2013-08-02 13:12:24 -07:00
bool m_isRealMerge;
char m_ks;
bool m_waitingForList;
collnum_t m_collnum;
2016-07-22 13:40:55 +02:00
int32_t m_errno;
bool m_isSingleUnmergedListGet;
static void gotListWrapper0(void *state);
2016-07-22 13:40:55 +02:00
void gotListWrapper();
static void mergeDoneWrapper(void *state, job_exit_t exit_type);
void mergeDone(job_exit_t exit_type);
2016-07-22 13:40:55 +02:00
static void gotRemoteListWrapper(void *state);
static void mergeListsWrapper(void *state);
void repairLists();
void mergeLists();
2013-08-02 13:12:24 -07:00
};
2016-03-08 22:14:30 +01:00
#endif // GB_MSG5_H