コード例 #1
0
void mergeTwoHlls(ServerInterface &srvInterface, const VString& hllStr1, const VString& hllStr2, VString& result) {
    SerializedHyperLogLog* hll = hllFromStr(hllStr1);
    SerializedHyperLogLog* hll2 = hllFromStr(hllStr2);

    if (hll == NULL) {
        hll = hll2;
        hll2 = NULL;
    }

    if (hll2 != NULL)
      hll->merge(*hll2);

    result.copy(hllStr1);

    if (hll != NULL)
        updateStringFromHll(result, hll);

    if (hll != NULL)
        delete hll;
    if (hll2 != NULL)
        delete hll2;
}
コード例 #2
0
void updateStringFromHll(VString& str, SerializedHyperLogLog* hll) {
    char* cstr = hll->toString(str.data()); 
    str.copy(cstr, 9 + hll->registerSize()); // size of prefix + size of binary array. prefix is %d|%d|bin_
}