-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "TableHotspotPolicy.h" | ||
|
||
namespace pegasus { | ||
namespace server { | ||
|
||
Hotpot_calculator::Hotpot_calculator(const std::string &name, const int &app_size) | ||
: data_stores(app_size), _name(name) | ||
{ | ||
} | ||
|
||
void Hotpot_calculator::aggregate(std::vector<row_data> partitions) | ||
{ | ||
for (int i = 0; i < partitions.size(); i++) { | ||
while (data_stores[i].size() > MAX_STORE_SIZE) | ||
data_stores[i].pop(); | ||
Data_store temp; | ||
temp.aggregate(partitions[i]); | ||
data_stores[i].emplace(temp); | ||
} | ||
while (data_stores[partitions.size()].size() > MAX_STORE_SIZE) | ||
data_stores[partitions.size()].pop(); | ||
Data_store temp_all; | ||
for (int i = 0; i < partitions.size(); i++) { | ||
temp_all.merge(data_stores[i].back()); | ||
} | ||
data_stores[partitions.size()].emplace(temp_all); | ||
} | ||
|
||
void Hotpot_calculator::start_alg() | ||
{ | ||
_policy = new Algo1(&data_stores, &_hotpot_points); | ||
_policy->detect_hotspot_policy(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,60 @@ | ||
#include "data_store.h" | ||
#include <dsn/perf_counter/perf_counter.h> | ||
|
||
namespace pegasus { | ||
namespace server { | ||
class Hotspot_policy | ||
{ | ||
public: | ||
Hotspot_policy(Data_store *data_store){ | ||
_data_store = data_store; | ||
} | ||
virtual double detect_hotspot_policy() = 0; | ||
private: | ||
Data_store *_data_store; | ||
}; | ||
|
||
class Algo1 : public Hotspot_policy | ||
{ | ||
public: | ||
explicit Algo1(Data_store *data_store):Hotspot_policy(data_store){}; | ||
double detect_hotspot_policy() | ||
{ | ||
return 0; | ||
} | ||
}; | ||
|
||
class Algo2 : public Hotspot_policy | ||
{ | ||
public: | ||
explicit Algo2(Data_store *data_store):Hotspot_policy(data_store){}; | ||
double detect_hotspot_policy() | ||
{ | ||
return 0; | ||
} | ||
}; | ||
|
||
|
||
class Hotpot_calculator | ||
{ | ||
private: | ||
std::string _name; | ||
|
||
#define MAX_STORE_SIZE 100 | ||
|
||
public: | ||
std::vector< std::vector<Data_store> > data_stores; | ||
|
||
Hotpot_calculator(const std::string &name,int app_size) : _name(name), data_stores(app_size){} | ||
|
||
void aggregate(const std::vector<row_data> *partitions) { | ||
for (int i=0;i<partitions->size();i++){ | ||
data_stores[i].push_back(partitions[i]); | ||
} | ||
} | ||
|
||
}; | ||
namespace pegasus { | ||
namespace server { | ||
class Hotspot_policy | ||
{ | ||
public: | ||
Hotspot_policy(std::vector<std::queue<Data_store>> *data_stores, | ||
std::vector<dsn::perf_counter> *hot_points) | ||
: _data_stores(data_stores), _hot_points(hot_points) | ||
{ | ||
} | ||
virtual void detect_hotspot_policy() = 0; | ||
|
||
protected: | ||
std::vector<std::queue<Data_store>> *_data_stores; | ||
std::vector<dsn::perf_counter> *_hot_points; | ||
}; | ||
|
||
class Algo1 : public Hotspot_policy | ||
{ | ||
public: | ||
explicit Algo1(std::vector<std::queue<Data_store>> *data_stores, | ||
std::vector<dsn::perf_counter> *hot_points) | ||
: Hotspot_policy(data_stores, hot_points){}; | ||
void detect_hotspot_policy() | ||
{ | ||
for (int i = 0; i < (_data_stores->size()); i++) | ||
(*_hot_points)[i].set((*_data_stores)[i].front().total_multi_get_qps); | ||
return; | ||
} | ||
}; | ||
|
||
class Algo2 : public Hotspot_policy | ||
{ | ||
public: | ||
explicit Algo2(std::vector<std::queue<Data_store>> *data_stores, | ||
std::vector<dsn::perf_counter> *hot_points) | ||
: Hotspot_policy(data_stores, hot_points){}; | ||
void detect_hotspot_policy() { return; } | ||
}; | ||
|
||
class Hotpot_calculator | ||
{ | ||
public: | ||
std::vector<std::queue<Data_store>> data_stores; | ||
Hotpot_calculator(const std::string &name, const int &app_size); | ||
void aggregate(std::vector<row_data> partitions); | ||
void start_alg(); | ||
|
||
private: | ||
std::string _name; | ||
Hotspot_policy *_policy; | ||
std::vector<dsn::perf_counter> _hotpot_points; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters