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


C++ Table::activeTupleCount方法代码示例

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


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

示例1: serialize_in

TEST_F(TableSerializeTest, NullStrings) {
    std::string *columnNames = new std::string[1];
    std::vector<voltdb::ValueType> columnTypes(1, voltdb::VALUE_TYPE_VARCHAR);
    std::vector<int32_t> columnSizes(1, 20);
    std::vector<bool> columnAllowNull(1, false);
    voltdb::TupleSchema *schema = voltdb::TupleSchema::createTupleSchema(columnTypes, columnSizes, columnAllowNull, true);
    columnNames[0] = "";
    table_->deleteAllTuples(true);
    delete table_;
    table_ = TableFactory::getTempTable(this->database_id, "temp_table", schema,
                                        columnNames, NULL);

    TableTuple& tuple = table_->tempTuple();
    tuple.setNValue(0, ValueFactory::getNullStringValue());
    table_->insertTuple(tuple);

    // Serialize the table
    CopySerializeOutput serialize_out;
    table_->serializeTo(serialize_out);

    // Deserialize the table: verify that it matches the existing table
    ReferenceSerializeInput serialize_in(serialize_out.data() + sizeof(int32_t), serialize_out.size() - sizeof(int32_t));
    TempTableLimits limits;
    schema = TupleSchema::createTupleSchema(table_->schema());
    Table* deserialized = TableFactory::getTempTable(this->database_id, "foo", schema,
                                                     columnNames, &limits);
    deserialized->loadTuplesFrom(serialize_in, NULL);

    EXPECT_EQ(1, deserialized->activeTupleCount());
    EXPECT_EQ(1, table_->activeTupleCount());
    EXPECT_EQ(1, deserialized->columnCount());
    EXPECT_EQ(1, table_->columnCount());
    EXPECT_EQ("", table_->columnName(0));
    EXPECT_EQ("", deserialized->columnName(0));
    EXPECT_EQ(VALUE_TYPE_VARCHAR, table_->schema()->columnType(0));
    EXPECT_EQ(VALUE_TYPE_VARCHAR, deserialized->schema()->columnType(0));
    EXPECT_EQ(true, table_->schema()->columnIsInlined(0));

    TableIterator iter = deserialized->iterator();
    TableTuple t(deserialized->schema());
    int count = 0;
    while (iter.next(t)) {
        EXPECT_EQ(VALUE_TYPE_VARCHAR, tuple.getType(0));
        EXPECT_EQ(VALUE_TYPE_VARCHAR, t.getType(0));
        EXPECT_TRUE(tuple.getNValue(0).isNull());
        EXPECT_TRUE(t.getNValue(0).isNull());
        EXPECT_TRUE(ValueFactory::getNullStringValue().op_equals(tuple.getNValue(0)).isTrue());
        EXPECT_TRUE(ValueFactory::getNullStringValue().op_equals(t.getNValue(0)).isTrue());
        count += 1;
    }
    EXPECT_EQ(1, count);
    delete deserialized;
    // clean up
    delete[] columnNames;
}
开发者ID:BibudhLahiriCC,项目名称:voltdb,代码行数:55,代码来源:serialize_test.cpp

示例2: eval

NValue OperatorExistsExpression::eval(const TableTuple *tuple1, const TableTuple *tuple2) const
{
    // Execute the subquery and get its subquery id
    assert(m_left != NULL);
    NValue lnv = m_left->eval(tuple1, tuple2);
    int subqueryId = ValuePeeker::peekInteger(lnv);

    // Get the subquery context

    ExecutorContext* exeContext = ExecutorContext::getExecutorContext();

    // The EXISTS (SELECT inner_expr ...) evaluates as follows:
    // The subquery produces a row => TRUE
    // The subquery produces an empty result set => FALSE
    Table* outputTable = exeContext->getSubqueryOutputTable(subqueryId);
    assert(outputTable != NULL);
    if (outputTable->activeTupleCount() > 0) {
        return NValue::getTrue();
    } else {
        return NValue::getFalse();
    }
}
开发者ID:DarkDare,项目名称:voltdb,代码行数:22,代码来源:operatorexpression.cpp


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