本文整理汇总了C++中Predicate::getCardinality方法的典型用法代码示例。如果您正苦于以下问题:C++ Predicate::getCardinality方法的具体用法?C++ Predicate::getCardinality怎么用?C++ Predicate::getCardinality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predicate
的用法示例。
在下文中一共展示了Predicate::getCardinality方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: t
//.........这里部分代码省略.........
posToCopy[nPosToCopy++] = 2;
} else {
//Constant
t.set(VTerm(0, pattern->object()), 2);
outputTuple[2] = pattern->object();
}*/
//Replace variables with constants if posJoins != NULL.
VTuple t = query.getTuple();
VTuple boundTuple = t;
if (posJoins != NULL) {
//The posjoins do not include constants
int j = 0;
for (std::vector<uint8_t>::const_iterator itr = newPosJoins.begin();
itr != newPosJoins.end(); ++itr) {
boundTuple.set(VTerm(0, possibleValuesJoins->at(j++)), *itr);
}
}
/*std::string ti("TI");
Literal query(program.getPredicate(ti, Predicate::calculateAdornment(boundTuple)),
boundTuple);*/
//Get all adorned rules
Wizard wizard;
std::shared_ptr<Program> adornedProgram = wizard.getAdornedProgram(query, program);
//Rewrite and add the rules
std::pair<PredId_t, PredId_t> inputOutputRelIDs;
std::shared_ptr<Program> magicProgram = wizard.doMagic(query, adornedProgram,
inputOutputRelIDs);
#ifdef DEBUG
//Print all rules
BOOST_LOG_TRIVIAL(debug) << "Rewritten program:";
std::vector<Rule> newRules = magicProgram->getAllRules();
for (std::vector<Rule>::iterator itr = newRules.begin(); itr != newRules.end(); ++itr) {
BOOST_LOG_TRIVIAL(debug) << itr->tostring(magicProgram.get(), &edb);
}
#endif
SemiNaiver naiver(magicProgram->getAllRules(), edb, magicProgram.get(), true, true) ;
//Add all the input tuples in the input relation
Predicate pred = magicProgram->getPredicate(inputOutputRelIDs.first);
VTuple onlyConstsTuple(pred.getCardinality());
int j = 0;
for (int i = 0; i < t.getSize(); ++i) {
if (!boundTuple.get(i).isVariable()) {
onlyConstsTuple.set(VTerm(0, t.get(i).getValue()), j++);
}
}
Literal unboundQuery(pred, onlyConstsTuple);
naiver.addDataToIDBRelation(magicProgram->getPredicate(inputOutputRelIDs.first),
getBlockFromQuery(unboundQuery, query,
newPosJoins.size() != 0 ? &newPosJoins : NULL, possibleValuesJoins));
//Exec the materialization
naiver.run(1, 2);
//Extract the tuples from the output relation
Literal outputLiteral(magicProgram->getPredicate(inputOutputRelIDs.second), t);
FCIterator itr = naiver.getTable(outputLiteral, 0, (size_t) - 1);
TupleTable *finalTable;
if (returnOnlyVars) {
finalTable = new TupleTable(outputLiteral.getNVars());
} else {
finalTable = new TupleTable(3);
}
while (!itr.isEmpty()) {
std::shared_ptr<const FCInternalTable> table = itr.getCurrentTable();
FCInternalTableItr *itrTable = table->getIterator();
if (returnOnlyVars) {
const uint8_t rowSize = table->getRowSize();
while (itrTable->hasNext()) {
itrTable->next();
for (uint8_t j = 0; j < rowSize; ++j) {
finalTable->addValue(itrTable->getCurrentValue(j));
}
}
} else {
while (itrTable->hasNext()) {
itrTable->next();
for (uint8_t j = 0; j < nPosToCopy; ++j) {
outputTuple[posToCopy[j]] = itrTable->getCurrentValue(j);
}
finalTable->addRow(outputTuple);
}
}
table->releaseIterator(itrTable);
itr.moveNextCount();
}
std::shared_ptr<TupleTable> pFinalTable(finalTable);
return new TupleTableItr(pFinalTable);
}