2016-05-16 03:16:22 +08:00
|
|
|
/*=============================================================================
|
|
|
|
# Filename: Strategy.h
|
|
|
|
# Author: Bookug Lobert
|
|
|
|
# Mail: zengli-bookug@pku.edu.cn
|
|
|
|
# Last Modified: 2016-05-07 16:28
|
|
|
|
# Description:
|
|
|
|
=============================================================================*/
|
|
|
|
|
|
|
|
#ifndef _DATABASE_STRATEGY_H
|
|
|
|
#define _DATABASE_STRATEGY_H
|
|
|
|
|
|
|
|
#include "../Util/Util.h"
|
|
|
|
#include "../Util/Triple.h"
|
|
|
|
#include "Join.h"
|
|
|
|
#include "../Query/IDList.h"
|
|
|
|
#include "../Query/SPARQLquery.h"
|
|
|
|
#include "../Query/BasicQuery.h"
|
|
|
|
#include "../KVstore/KVstore.h"
|
|
|
|
#include "../VSTree/VSTree.h"
|
2016-09-25 22:14:36 +08:00
|
|
|
#include "../Query/ResultFilter.h"
|
2016-05-16 03:16:22 +08:00
|
|
|
|
|
|
|
class Strategy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Strategy();
|
2017-03-24 20:10:43 +08:00
|
|
|
Strategy(KVstore*, VSTree*, TYPE_TRIPLE_NUM*, TYPE_PREDICATE_ID, TYPE_ENTITY_LITERAL_ID);
|
2016-05-16 03:16:22 +08:00
|
|
|
~Strategy();
|
|
|
|
//select efficient strategy to do the sparql query
|
2016-09-25 22:14:36 +08:00
|
|
|
bool handle(SPARQLquery&, ResultFilter* _result_filter = NULL);
|
2016-05-16 03:16:22 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
int method;
|
|
|
|
KVstore* kvstore;
|
|
|
|
VSTree* vstree;
|
2017-03-24 20:10:43 +08:00
|
|
|
TYPE_TRIPLE_NUM* pre2num;
|
|
|
|
TYPE_PREDICATE_ID limitID_predicate;
|
|
|
|
TYPE_ENTITY_LITERAL_ID limitID_literal;
|
|
|
|
|
|
|
|
//NOTICE: even the ID type is int, it is no problem and no waste that we use unsigned in answer
|
|
|
|
//(because -1, -2 or other invalid IDs can not be in answer)
|
|
|
|
void handler0(BasicQuery*, vector<unsigned*>&, ResultFilter* _result_filter = NULL);
|
|
|
|
void handler1(BasicQuery*, vector<unsigned*>&);
|
|
|
|
void handler2(BasicQuery*, vector<unsigned*>&);
|
|
|
|
void handler3(BasicQuery*, vector<unsigned*>&);
|
|
|
|
void handler4(BasicQuery*, vector<unsigned*>&);
|
|
|
|
void handler5(BasicQuery*, vector<unsigned*>&);
|
2016-05-16 03:16:22 +08:00
|
|
|
//QueryHandler *dispatch;
|
|
|
|
//void prepare_handler();
|
|
|
|
};
|
|
|
|
|
2017-03-24 20:10:43 +08:00
|
|
|
//function pointer array
|
2016-05-16 03:16:22 +08:00
|
|
|
static const unsigned QUERY_HANDLER_NUM = 4;
|
2017-03-24 20:10:43 +08:00
|
|
|
typedef void (Strategy::*QueryHandler[QUERY_HANDLER_NUM]) (BasicQuery*, vector<unsigned*>&);
|
2016-05-16 03:16:22 +08:00
|
|
|
//QueryHandler dispatch;
|
|
|
|
|
|
|
|
#endif //_DATABASE_STRATEGY_H
|
|
|
|
|