Example #1
0
void histogram::update(uint64_t x, uint64_t y) {
	validate_snapshots();

	auto indx = get_indx(x, y);
	m_snapshots.rbegin()->counters[indx] += 1;
	m_last_data.counters[indx] += 1;
}
Example #2
0
int validate_phase1(tr_submit_msg* t) {
	flat_key_hash* rs_hashes;
	
	if (t->start >= (vs.ST - MaxPreviousST)) {
		rs_hashes = TR_SUBMIT_MSG_RS_HASH(t);
		if (validate_snapshots(t, rs_hashes) == 0) {
			prevws_conflict++;
			return 0;
		}
    } else {
        too_old++;
		return 0;
    }
    return 1;
}
Example #3
0
rapidjson::Value& histogram::report(rapidjson::Value &stat_value,
                                    rapidjson::Document::AllocatorType &allocator) {
	validate_snapshots();

	rapidjson::Value snapshots(rapidjson::kArrayType);
	snapshots.Reserve(m_snapshots.size(), allocator);
	for (auto it =  m_snapshots.begin(), end = m_snapshots.end(); it != end; ++it) {
		rapidjson::Value snapshot_value(rapidjson::kObjectType);
		snapshots.PushBack(print_data(snapshot_value, allocator, *it),
		                   allocator);
	}

	stat_value.AddMember("snapshots", snapshots, allocator);

	rapidjson::Value last_value(rapidjson::kObjectType);
	stat_value.AddMember("last_snapshot",
	                     print_data(last_value, allocator, m_last_data),
	                     allocator);

	clear_last();

	return stat_value;
}
Example #4
0
static int validate(tr_submit_msg* t) {
    int i;
    flat_key_hash* rs_hashes;
    
    rs_hashes = TR_SUBMIT_MSG_RS_HASH(t);
    
    // Check readset of t against writesets of old snapshots
    if (vs.ST > t->start) {
        if (validate_snapshots(t, rs_hashes) == 0) {
            prevws_conflict++;
            return 0;
        }
    }
	
    // Check readset of t against writeset of current snapshot
    for (i = 0; i < t->readset_count; i++) {
        if (bloom_contains_hashes(vs.ws, rs_hashes[i].hash)) {
            ws_conflict++;
            return 0;
        }
    }
    
    return 1;
}