当前位置: 首页>>代码示例>>C++>>正文


C++ StatementPtr::execute_int方法代码示例

本文整理汇总了C++中sqldatabase::StatementPtr::execute_int方法的典型用法代码示例。如果您正苦于以下问题:C++ StatementPtr::execute_int方法的具体用法?C++ StatementPtr::execute_int怎么用?C++ StatementPtr::execute_int使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqldatabase::StatementPtr的用法示例。


在下文中一共展示了StatementPtr::execute_int方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: count

// Count how many tests are missing first_error information when it should be available.
static void
countMissingErrors(const SqlDatabase::TransactionPtr &tx, const Settings &settings) {
    std::vector<std::string> args;
    SqlDatabase::StatementPtr q = tx->statement("select count(*)"
                                                " from test_results test"
                                                " join attachments att on test.id = att.test_id" +
                                                sqlWhereClause(tx, settings, args) + " and"
                                                "    test.first_error is null and"
                                                "    test.status <> 'end' and"
                                                "    att.name = 'Final output'");
    sqlBindArgs(q, args);
    int n = q->execute_int();
    std::cout <<n <<"\n";
}
开发者ID:sujankh,项目名称:rose-matlab,代码行数:15,代码来源:matrixErrors.C

示例2: sqrt

static void
callLSH(const SqlDatabase::TransactionPtr &tx, const std::string databaseName, double similarity_threshold, const string& Exec,
        int norm, size_t hash_function_size, size_t hash_table_count)
{
    double distance = sqrt((1. - similarity_threshold) * 50.);
    double false_negative_rate = ( similarity_threshold != 1.0) ? 0.0100 : 0;
    vector<CloneRange> ranges = computeranges(distance, 50, 100000);
    int maxNumElementsInGroup = -1;
    int maxNumElementIdx = -1;

    // FIXME: We can't pass parameters to the exec'd process this way because the parent's SQL statements are
    // being executed in a transaction -- they won't be visible in the child. [Robb P. Matzke 2013-08-12]
    tx->execute("delete from detection_parameters");
    tx->statement("insert into detection_parameters (similarity_threshold, false_negative_rate) values (?, ?)")
        ->bind(0, similarity_threshold)
        ->bind(1, false_negative_rate)
        ->execute();
  
    map<size_t, int> groupSizes;
    std::cout << "Looking for the biggest group" << std::endl;
    for (size_t i = 0; i < ranges.size(); ++i) {
        std::string sql = std::string("select count(*) from vectors where sum_of_counts >= ?") +
                          (ranges[i].high != -1 ? " and sum_of_counts <= ?" : "");
        SqlDatabase::StatementPtr cmd = tx->statement(sql);
        cmd->bind(0, ranges[i].low);
        if (ranges[i].high != -1)
            cmd->bind(1, ranges[i].high);
        int numElementsInGroup = cmd->execute_int();
        groupSizes[i] = numElementsInGroup;
        std::cerr << "The current group from " << ranges[i].low << " to " << ranges[i].high
                  << " is of size " << numElementsInGroup << std::endl;
        if (numElementsInGroup > maxNumElementsInGroup) {
            maxNumElementsInGroup = numElementsInGroup;
            maxNumElementIdx = i;
        }
    }

    std::cout << "Biggest group found " << ranges[maxNumElementIdx].low << " " << ranges[maxNumElementIdx].high << std::endl;
    char tempDirName[] = "/tmp/paramdirXXXXXX";
    char* mkdtempResult = mkdtemp(tempDirName);
    if (!mkdtempResult) {
	perror("mkdtemp: ");
	exit (1);
    }
    string paramFileName = string(tempDirName) + "/params";
    paramFileName = "/tmp/lshparamdirE40hF1/params";
    std::cout << "Number of groups :" << ranges.size() << std::endl;

    for (int i = 0; i < (int)ranges.size(); ++i) {
        size_t group = (i == 0) ? maxNumElementIdx : (i <= maxNumElementIdx) ? i - 1 : i;
        if (groupSizes[group] > 1) {
            std::cout << "Executing LSH code low " << ranges[group].low  
                      << " high " << ranges[group].high << " group  " << group << " size " << groupSizes[group] << std::endl;
            if(norm == 3) {
                executeLSHCode(tx, databaseName, Exec, paramFileName, ranges[group]);
            } else {
                executeLSHCodeLLNL(tx, databaseName, Exec, paramFileName, ranges[group], norm, similarity_threshold,
                                   false_negative_rate, groupSizes[group]);
            }
        }
    }
    unlink(paramFileName.c_str());
    rmdir(tempDirName);
}
开发者ID:8l,项目名称:rose,代码行数:64,代码来源:callLSH.C


注:本文中的sqldatabase::StatementPtr::execute_int方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。