本文整理汇总了C++中Index::createFromOnDiskIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::createFromOnDiskIndex方法的具体用法?C++ Index::createFromOnDiskIndex怎么用?C++ Index::createFromOnDiskIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::createFromOnDiskIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Main function.
int main(int argc, char** argv) {
cout.sync_with_stdio(false);
std::cout << std::endl
<< EMPH_ON << "WriteIndexListsMain, version " << __DATE__ << " "
<< __TIME__ << EMPH_OFF << std::endl
<< std::endl;
char* locale = setlocale(LC_CTYPE, "");
cout << "Set locale LC_CTYPE to: " << locale << endl;
std::locale loc;
ad_utility::ReadableNumberFacet facet(1);
std::locale locWithNumberGrouping(loc, &facet);
ad_utility::Log::imbue(locWithNumberGrouping);
string indexName = "";
bool freebase = false;
optind = 1;
// Process command line arguments.
while (true) {
int c = getopt_long(argc, argv, "i:f", options, NULL);
if (c == -1) break;
switch (c) {
case 'i':
indexName = optarg;
break;
case 'f':
freebase = true;
break;
default:
cout << endl
<< "! ERROR in processing options (getopt returned '" << c
<< "' = 0x" << std::setbase(16) << c << ")" << endl
<< endl;
exit(1);
}
}
if (indexName.size() == 0) {
cout << "Missing required argument --index (-i)..." << endl;
exit(1);
}
try {
Index index;
index.createFromOnDiskIndex(indexName);
index.addTextFromOnDiskIndex();
vector<string> lists;
lists.push_back("algo*");
bool decodeGapsAndFrequency = true;
index.dumpAsciiLists(lists, decodeGapsAndFrequency);
Engine engine;
QueryExecutionContext qec(index, engine);
ParsedQuery q;
if (!freebase) {
q = SparqlParser::parse("SELECT ?x WHERE {?x <is-a> <Scientist>}");
} else {
q = SparqlParser::parse(
"PREFIX fb: <http://rdf.freebase.com/ns/> SELECT ?p WHERE {?p "
"fb:people.person.profession fb:m.06q2q}");
q.expandPrefixes();
}
QueryPlanner queryPlanner(&qec);
auto qet = queryPlanner.createExecutionTree(q);
const auto res = qet.getResult();
AD_CHECK(res->size() > 0);
AD_CHECK(res->_data.cols() == 1);
string personlistFile = indexName + ".list.scientists";
std::ofstream f(personlistFile.c_str());
const IdTable& ids = res->_data;
for (size_t i = 0; i < ids.size(); ++i) {
f << ids(i, 0) << ' ';
}
f.close();
} catch (const std::exception& e) {
cout << e.what() << std::endl;
}
return 0;
}