|
|
@ -1,14 +1,10 @@ |
|
|
|
#pragma once |
|
|
|
#include <stdint.h> |
|
|
|
#ifdef COMPILE_TIME |
|
|
|
#include "9float.hpp" |
|
|
|
using scatter_key_t = ninefloat::Q<uint64_t,64>; |
|
|
|
static const scatter_key_t scatter_key_increment = ninefloat::Q<uint64_t,64>::min_increment(); |
|
|
|
#else |
|
|
|
using scatter_key_t = uint64_t; |
|
|
|
static const scatter_key_t scatter_key_increment = 1; |
|
|
|
#endif |
|
|
|
|
|
|
|
#include "9float.hpp" |
|
|
|
using scatter_key_t = ninefloat::Q<uint64_t,64>; |
|
|
|
static const scatter_key_t scatter_key_increment = ninefloat::Q<uint64_t,64>::min_increment(); |
|
|
|
#include <vector> |
|
|
|
#include <numeric> |
|
|
|
|
|
|
|
namespace StorageTree{ |
|
|
|
|
|
|
@ -35,7 +31,7 @@ namespace StorageTree{ |
|
|
|
constexpr T max(T any = 0) |
|
|
|
{ |
|
|
|
if(any>any+scatter_key_increment) |
|
|
|
return any |
|
|
|
return any; |
|
|
|
return max(any+scatter_key_increment); |
|
|
|
} |
|
|
|
} |
|
|
@ -50,26 +46,33 @@ namespace StorageTree{ |
|
|
|
using root = _impl::subdivision<datacenter>; |
|
|
|
|
|
|
|
template<class T, std::enable_if_t<T::divisible>> |
|
|
|
kt">void update_weights(T& root, uint64_t sub_ratio=1, scatter_key_t begin=0, scatter_key_t end=_impl::max<scatter_key_t>()) |
|
|
|
n">uint64_t total_weight(T& root) |
|
|
|
{ |
|
|
|
scatter_key_t address_space = end-begin; |
|
|
|
scatter_key_t base = begin |
|
|
|
for(int idx=0:idx<root.content.size();idx++) |
|
|
|
{ |
|
|
|
auto& elem = root.content[idx]; |
|
|
|
if(idx!=root.content.size()-1) |
|
|
|
return std::reduce( |
|
|
|
root.content.begin(), |
|
|
|
root.content.end(), |
|
|
|
0UL, |
|
|
|
[](auto val, uint64_t acc) |
|
|
|
{ |
|
|
|
update_weights(elem, root.content.size()*sub_ratio, base, base+address_space/root.content.size()); |
|
|
|
base = base+address_space/root.content.size()+scatter_key_increment; |
|
|
|
return acc+total_weight(val); |
|
|
|
} |
|
|
|
else |
|
|
|
update_weights(elem, root.content.size()*sub_ratio, base, end); |
|
|
|
|
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
template<class T, std::enable_if_t<!T::divisible>> |
|
|
|
uint64_t total_weight(T& root) |
|
|
|
{ |
|
|
|
return root.weight; |
|
|
|
} |
|
|
|
|
|
|
|
template<class T, std::enable_if_t<T::divisible>> |
|
|
|
scatter_key_t update_weights(T& root, uint64_t sub_ratio=1, uint64_t total, scatter_key_t begin=0, scatter_key_t ratio=0.5) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
template<class T, std::enable_if_t<!T::divisible>> |
|
|
|
void update_weights(T& root, scatter_key_t begin, scatter_key_t end) |
|
|
|
n">scatter_key_t update_weights(T& root, uint64_t sub_ratio=1, uint64_t total, scatter_key_t begin, scatter_key_t end) |
|
|
|
{ |
|
|
|
this->begin = begin; |
|
|
|
this->end = end; |
|
|
|