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


C++ TupleSchema::setColumnMetaData方法代码示例

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


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

示例1: createTupleSchema

TupleSchema* TupleSchema::createTupleSchema(const std::vector<ValueType>& columnTypes,
                                            const std::vector<int32_t>&   columnSizes,
                                            const std::vector<bool>&      allowNull,
                                            const std::vector<bool>&      columnInBytes,
                                            const std::vector<ValueType>& hiddenColumnTypes,
                                            const std::vector<int32_t>&   hiddenColumnSizes,
                                            const std::vector<bool>&      hiddenAllowNull,
                                            const std::vector<bool>&      hiddenColumnInBytes)
{
    const uint16_t uninlineableObjectColumnCount =
      TupleSchema::countUninlineableObjectColumns(columnTypes, columnSizes, columnInBytes);
    const uint16_t columnCount = static_cast<uint16_t>(columnTypes.size());
    const uint16_t hiddenColumnCount = static_cast<uint16_t>(hiddenColumnTypes.size());
    int memSize = memSizeForTupleSchema(columnCount,
                                        uninlineableObjectColumnCount,
                                        hiddenColumnCount);

    // allocate the set amount of memory and cast it to a tuple pointer
    TupleSchema *retval = reinterpret_cast<TupleSchema*>(new char[memSize]);

    // clear all the offset values
    memset(retval, 0, memSize);
    retval->m_columnCount = columnCount;
    retval->m_uninlinedObjectColumnCount = uninlineableObjectColumnCount;
    retval->m_hiddenColumnCount = hiddenColumnCount;
    retval->m_isHeaderless = false;

    uint16_t uninlinedObjectColumnIndex = 0;
    for (uint16_t ii = 0; ii < columnCount; ii++) {
        const ValueType type = columnTypes[ii];
        const uint32_t length = columnSizes[ii];
        const bool columnAllowNull = allowNull[ii];
        const bool inBytes = columnInBytes[ii];
        retval->setColumnMetaData(ii, type, length, columnAllowNull, uninlinedObjectColumnIndex, inBytes);
    }

    for (uint16_t ii = 0; ii < hiddenColumnCount; ++ii) {
        const ValueType type = hiddenColumnTypes[ii];
        const uint32_t length = hiddenColumnSizes[ii];
        const bool columnAllowNull = hiddenAllowNull[ii];
        const bool inBytes = hiddenColumnInBytes[ii];

        // We can't allow uninlineable data in hidden columns yet
        if (! isInlineable(type, length, inBytes)) {
            throwFatalLogicErrorStreamed("Attempt to create uninlineable hidden column");
        }

        retval->setColumnMetaData(static_cast<uint16_t>(columnCount + ii),
                                  type,
                                  length,
                                  columnAllowNull,
                                  uninlinedObjectColumnIndex,
                                  inBytes);
    }

    return retval;
}
开发者ID:simonzhangsm,项目名称:voltdb,代码行数:57,代码来源:TupleSchema.cpp

示例2: createTupleSchema

TupleSchema* TupleSchema::createTupleSchema(const std::vector<ValueType> columnTypes,
                                            const std::vector<int32_t> columnSizes,
                                            const std::vector<bool> allowNull,
                                            bool allowInlinedObjects)
{
    const uint16_t uninlineableObjectColumnCount =
      TupleSchema::countUninlineableObjectColumns(columnTypes, columnSizes, allowInlinedObjects);
    const uint16_t columnCount = static_cast<uint16_t>(columnTypes.size());
    // big enough for any data members plus big enough for tupleCount + 1 "ColumnInfo"
    //  fields. We need CI+1 because we get the length of a column by offset subtraction
    // Also allocate space for an int16_t for each uninlineable object column so that
    // the indices of uninlineable columns can be stored at the front and aid in iteration
    int memSize = (int)(sizeof(TupleSchema) +
                        (sizeof(ColumnInfo) * (columnCount + 1)) +
                        (uninlineableObjectColumnCount * sizeof(int16_t)));

    // allocate the set amount of memory and cast it to a tuple pointer
    TupleSchema *retval = reinterpret_cast<TupleSchema*>(new char[memSize]);

    // clear all the offset values
    memset(retval, 0, memSize);
    retval->m_allowInlinedObjects = allowInlinedObjects;
    retval->m_columnCount = columnCount;
    retval->m_uninlinedObjectColumnCount = uninlineableObjectColumnCount;

    uint16_t uninlinedObjectColumnIndex = 0;
    for (uint16_t ii = 0; ii < columnCount; ii++) {
        const ValueType type = columnTypes[ii];
        const uint32_t length = columnSizes[ii];
        const bool columnAllowNull = allowNull[ii];
        retval->setColumnMetaData(ii, type, length, columnAllowNull, uninlinedObjectColumnIndex);
    }

    return retval;
}
开发者ID:AllenShi,项目名称:h-store,代码行数:35,代码来源:TupleSchema.cpp


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