TEST(Stats, Convergence) {
    // load a table
    InterpreterRelation rel(2);

    SymbolTable symTable;

    SymbolMask mask(2);
    mask.setSymbol(0);
    mask.setSymbol(1);

    {
        std::fstream in(BUILDDIR "../tests/evaluation/hmmer/facts/DirectFlow.facts");

        IODirectives ioDirectives(
                {{"IO", "file"}, {"filename", BUILDDIR "../tests/evaluation/hmmer/facts/DirectFlow.facts"},
                        {"delimiter", "\t"}});
        // if file not found => be done
        if (!in.is_open()) return;

        std::unique_ptr<ReadStream> reader =
                IOSystem::getInstance().getReader(mask, symTable, ioDirectives, false);
        reader->readAll(rel);
    }

    std::cout << rel.size() << "\n";

    InterpreterRelation rel2(3);

    for (const auto& cur : rel) {
        rel2.insert(cur[0], cur[1], 1);
    }

    RelationStats full = RelationStats::extractFrom(rel2);

    RelationStats s10 = RelationStats::extractFrom(rel2, 10);
    RelationStats s100 = RelationStats::extractFrom(rel2, 100);
    RelationStats s1000 = RelationStats::extractFrom(rel2, 1000);
    RelationStats s10000 = RelationStats::extractFrom(rel2, 10000);

    for (int i = 0; i < 3; i++) {
        std::cout << "Card " << i << ":\n";
        std::cout << "\t" << s10.getEstimatedCardinality(i) << " - "
                  << (s10.getEstimatedCardinality(i) - full.getEstimatedCardinality(i)) << "\n";
        std::cout << "\t" << s100.getEstimatedCardinality(i) << " - "
                  << (s100.getEstimatedCardinality(i) - full.getEstimatedCardinality(i)) << "\n";
        std::cout << "\t" << s1000.getEstimatedCardinality(i) << " - "
                  << (s1000.getEstimatedCardinality(i) - full.getEstimatedCardinality(i)) << "\n";
        std::cout << "\t" << s10000.getEstimatedCardinality(i) << " - "
                  << (s10000.getEstimatedCardinality(i) - full.getEstimatedCardinality(i)) << "\n";
        std::cout << "\t" << full.getEstimatedCardinality(i) << " - "
                  << (full.getEstimatedCardinality(i) - full.getEstimatedCardinality(i)) << "\n";

        std::cout << "\n";
    }
}
예제 #2
0
ZQ<void> Worker::QCall()
	{
	ZAcqMtx acq(fMtx);

	for (;;)
		{
		fWorking = ZThread::sID();
		fNextWake = kDistantFuture;
		ZRelMtx rel(fMtx);

		ZQ<bool> result;

		try { result = fCallable_Work->QCall(this); }
		catch (...) {}

		ZAcqMtx acq(fMtx);
		fWorking = 0;

		if (result && *result)
			{
			if (fNextWake < kDistantFuture)
				{
				if (fNextWake <= Time::sSystem())
					continue;
				sNextStartAt(fNextWake, Job(fStarter, this));
				}
			return notnull;
			}

		fStarter.Clear();
		fCnd.Broadcast();

		ZRelMtx rel2(fMtx);

		try { sCall(fCallable_Detached, this); }
		catch (...) {}

		return null;
		}
	}