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


C++ TableTuple::inlinedDataIsVolatile方法代码示例

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


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

示例1: UniqueEngineBuilder

TEST_F(TableTupleTest, VolatileStandAloneTuple) {
    UniqueEngine engine = UniqueEngineBuilder().build();

    // A schema with
    //    - one fixed size column
    //    - one inlined variable-length column
    //    - one non-inlined variable-length column
    ScopedTupleSchema schema{Tools::buildSchema(VALUE_TYPE_BIGINT,
                                                std::make_pair(VALUE_TYPE_VARCHAR, 12),
                                                std::make_pair(VALUE_TYPE_VARCHAR, 256))};
    StandAloneTupleStorage standAloneTuple{schema.get()};
    TableTuple tuple = standAloneTuple.tuple();
    Tools::setTupleValues(&tuple, int64_t(0), "foo", "foo bar");

    // Stand alone tuples are similar to pool-backed tuples.
    ASSERT_TRUE(tuple.inlinedDataIsVolatile());
    ASSERT_FALSE(tuple.nonInlinedDataIsVolatile());

    NValue nv = tuple.getNValue(0);
    ASSERT_FALSE(nv.getVolatile());

    nv = tuple.getNValue(1);
    ASSERT_TRUE(nv.getVolatile());

    nv = tuple.getNValue(2);
    ASSERT_FALSE(nv.getVolatile());
}
开发者ID:simonzhangsm,项目名称:voltdb,代码行数:27,代码来源:tabletuple_test.cpp

示例2: iterTuple

TEST_F(LargeTempTableTest, Basic) {
    UniqueEngine engine = UniqueEngineBuilder().build();
    LargeTempTableBlockCache* lttBlockCache = ExecutorContext::getExecutorContext()->lttBlockCache();

    TupleSchema* schema = Tools::buildSchema(VALUE_TYPE_BIGINT,
                                             VALUE_TYPE_DOUBLE,
                                             std::make_pair(VALUE_TYPE_VARCHAR, 15),
                                             std::make_pair(VALUE_TYPE_VARCHAR, 128));
    std::vector<std::string> columnNames{
        "pk", "val", "inline_text", "noninline_text"
    };
    auto ltt = makeUniqueTable(TableFactory::buildLargeTempTable(
        "ltmp",
        schema,
        columnNames));

    TableTuple tuple = ltt->tempTuple();

    // Temp tuple for large temp tables is like the temp tuple for
    // normal temp tables and persistent tables:
    //   - inlined, variable-length data is volatile
    //   - non-inlined, variable-length data is in the temp string pool,
    //     which is not volatile.
    ASSERT_TRUE(tuple.inlinedDataIsVolatile());
    ASSERT_FALSE(tuple.nonInlinedDataIsVolatile());

    std::vector<int64_t> pkVals{66, 67, 68};
    std::vector<double> floatVals{3.14, 6.28, 7.77};
    std::vector<std::string> inlineTextVals{"foo", "bar", "baz"};
    std::vector<std::string> nonInlineTextVals{"ffoo", "bbar", "bbaz"};

    ASSERT_EQ(0, lttBlockCache->numPinnedEntries());
    for (int i = 0; i < pkVals.size(); ++i) {
        Tools::setTupleValues(&tuple, pkVals[i], floatVals[i], inlineTextVals[i], nonInlineTextVals[i]);
        ltt->insertTuple(tuple);
    }

    ASSERT_EQ(1, lttBlockCache->numPinnedEntries());

    try {
        TableIterator it = ltt->iterator();
        ASSERT_TRUE_WITH_MESSAGE(false, "Expected release of pinned block to fail");
    }
    catch (const SerializableEEException &exc) {
        ASSERT_NE(std::string::npos, exc.message().find("Attempt to iterate over large temp table before finishInserts() is called"));
    }

    ltt->finishInserts();

    // finishInserts is idempotent and may be called multiple times
    ltt->finishInserts();

    try {
        Tools::setTupleValues(&tuple, int64_t(-1), 3.14, "dino", "ddino");
        ltt->insertTuple(tuple);
        ASSERT_TRUE_WITH_MESSAGE(false, "Expected insertTuple() to fail after finishInserts() called");
    }
    catch (const SerializableEEException& exc) {
        ASSERT_NE(std::string::npos, exc.message().find("Attempt to insert after finishInserts() called"));
    }

    ASSERT_EQ(0, lttBlockCache->numPinnedEntries());

    {
        TableIterator iter = ltt->iterator();
        TableTuple iterTuple(ltt->schema());
        int i = 0;
        while (iter.next(iterTuple)) {
            if (! assertTupleValuesEqual(&iterTuple,
                                         pkVals[i],
                                         floatVals[i],
                                         inlineTextVals[i],
                                         nonInlineTextVals[i])) {
                break;
            }
            ++i;
        }

        ASSERT_EQ(pkVals.size(), i);
    }

    ltt->deleteAllTempTuples();

    ASSERT_EQ(0, lttBlockCache->totalBlockCount());
    ASSERT_EQ(0, lttBlockCache->allocatedMemory());
}
开发者ID:alexeevm,项目名称:voltdb,代码行数:86,代码来源:LargeTempTableTest.cpp


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