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


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

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


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

示例1: p_execute_tuple_internal

void InsertExecutor::p_execute_tuple_internal(TableTuple &tuple) {
    const std::vector<int>& fieldMap = m_node->getFieldMap();
    std::size_t mapSize = fieldMap.size();

    for (int i = 0; i < mapSize; ++i) {
        // Most executors will just call setNValue instead of
        // setNValueAllocateForObjectCopies.
        //
        // However, We need to call
        // setNValueAllocateForObjectCopies here.  Sometimes the
        // input table's schema has an inlined string field, and
        // it's being assigned to the target table's non-inlined
        // string field.  In this case we need to tell the NValue
        // where to allocate the string data.
        // For an "upsert", this templateTuple setup has two effects --
        // It sets the primary key column(s) and it sets the
        // updated columns to their new values.
        // If the primary key value (combination) is new, the
        // templateTuple is the exact combination of new values
        // and default values required by the insert.
        // If the primary key value (combination) already exists,
        // only the NEW values stored on the templateTuple get updated
        // in the existing tuple and its other columns keep their existing
        // values -- the DEFAULT values that are stored in templateTuple
        // DO NOT get copied to an existing tuple.
        m_templateTuple.setNValueAllocateForObjectCopies(fieldMap[i],
                                                         tuple.getNValue(i),
                                                         m_tempPool);
    }

    VOLT_TRACE("Inserting tuple '%s' into target table '%s' with table schema: %s",
               m_templateTuple.debug(m_targetTable->name()).c_str(), m_targetTable->name().c_str(),
               m_targetTable->schema()->debug().c_str());

    // If there is a partition column for the target table
    if (m_partitionColumn != -1) {
        // get the value for the partition column
        NValue value = m_templateTuple.getNValue(m_partitionColumn);
        bool isLocal = m_engine->isLocalSite(value);

        // if it doesn't map to this partiton
        if (!isLocal) {
            if (m_multiPartition) {
                // The same row is presumed to also be generated
                // on some other partition, where the partition key
                // belongs.
                return;
            }
            // When a streamed table has no views, let an SP insert execute.
            // This is backward compatible with when there were only export
            // tables with no views on them.
            // When there are views, be strict and throw mispartitioned
            // tuples to force partitioned data to be generated only
            // where partitioned view rows are maintained.
            if (!m_isStreamed || m_hasStreamView) {
                throw ConstraintFailureException(m_targetTable, m_templateTuple,
                                                 "Mispartitioned tuple in single-partition insert statement.");
            }
        }
    }

    if (m_isUpsert) {
        // upsert execution logic
        assert(m_persistentTable->primaryKeyIndex() != NULL);
        TableTuple existsTuple = m_persistentTable->lookupTupleByValues(m_templateTuple);

        if (!existsTuple.isNullTuple()) {
            // The tuple exists already, update (only) the templateTuple columns
            // that were initialized from the input tuple via the field map.
            // Technically, this includes setting primary key values,
            // but they are getting set to equivalent values, so that's OK.
            // A simple setNValue works here because any required object
            // allocations were handled when copying the input values into
            // the templateTuple.
            m_upsertTuple.move(m_templateTuple.address());
            TableTuple &tempTuple = m_persistentTable->copyIntoTempTuple(existsTuple);
            for (int i = 0; i < mapSize; ++i) {
                tempTuple.setNValue(fieldMap[i],
                                    m_templateTuple.getNValue(fieldMap[i]));
            }
            m_persistentTable->updateTupleWithSpecificIndexes(existsTuple, tempTuple,
                                                              m_persistentTable->allIndexes());
            // successfully updated
            ++m_modifiedTuples;
            return;
        }
        // else, the primary key did not match,
        // so fall through to the "insert" logic
    }

    // try to put the tuple into the target table
    if (m_hasPurgeFragment) {
        executePurgeFragmentIfNeeded(&m_persistentTable);
        // purge fragment might have truncated the table, and
        // refreshed the persistent table pointer.  Make sure to
        // use it when doing the insert below.
        m_targetTable = m_persistentTable;
    }
    m_targetTable->insertTuple(m_templateTuple);
    VOLT_TRACE("Target table:\n%s\n", m_targetTable->debug().c_str());
//.........这里部分代码省略.........
开发者ID:hazelnutsgz,项目名称:voltdb,代码行数:101,代码来源:insertexecutor.cpp

示例2: p_execute


//.........这里部分代码省略.........
    //  (3) Check whether the tuple satisfies the post expression.
    //      If it does, then add it to the output table
    //
    // Use our search key to prime the index iterator
    // Now loop through each tuple given to us by the iterator
    //

    TableTuple tuple;
    if (activeNumOfSearchKeys > 0) {
        VOLT_TRACE("INDEX_LOOKUP_TYPE(%d) m_numSearchkeys(%d) key:%s",
                localLookupType, activeNumOfSearchKeys, searchKey.debugNoHeader().c_str());

        if (localLookupType == INDEX_LOOKUP_TYPE_EQ) {
            tableIndex->moveToKey(&searchKey, indexCursor);
        }
        else if (localLookupType == INDEX_LOOKUP_TYPE_GT) {
            tableIndex->moveToGreaterThanKey(&searchKey, indexCursor);
        }
        else if (localLookupType == INDEX_LOOKUP_TYPE_GTE) {
            tableIndex->moveToKeyOrGreater(&searchKey, indexCursor);
        }
        else if (localLookupType == INDEX_LOOKUP_TYPE_LT) {
            tableIndex->moveToLessThanKey(&searchKey, indexCursor);
        }
        else if (localLookupType == INDEX_LOOKUP_TYPE_LTE) {
            // find the entry whose key is greater than search key,
            // do a forward scan using initialExpr to find the correct
            // start point to do reverse scan
            bool isEnd = tableIndex->moveToGreaterThanKey(&searchKey, indexCursor);
            if (isEnd) {
                tableIndex->moveToEnd(false, indexCursor);
            }
            else {
                while (!(tuple = tableIndex->nextValue(indexCursor)).isNullTuple()) {
                    pmp.countdownProgress();
                    if (initial_expression != NULL && !initial_expression->eval(&tuple, NULL).isTrue()) {
                        // just passed the first failed entry, so move 2 backward
                        tableIndex->moveToBeforePriorEntry(indexCursor);
                        break;
                    }
                }
                if (tuple.isNullTuple()) {
                    tableIndex->moveToEnd(false, indexCursor);
                }
            }
        }
        else {
            return false;
        }
    }
    else {
        bool toStartActually = (localSortDirection != SORT_DIRECTION_TYPE_DESC);
        tableIndex->moveToEnd(toStartActually, indexCursor);
    }

    int tuple_ctr = 0;
    int tuples_skipped = 0;     // for offset
    int limit = -1;
    int offset = -1;
    if (limit_node != NULL) {
        limit_node->getLimitAndOffsetByReference(params, limit, offset);
    }

    //
    // We have to different nextValue() methods for different lookup types
    //
开发者ID:dinuschen,项目名称:voltdb,代码行数:67,代码来源:indexscanexecutor.cpp

示例3: insertTuple

 TableTuple insertTuple(PersistentTable* table, TableTuple temp_tuple) {
     table->insertTuple(temp_tuple);
     TableTuple tuple = table->lookupTupleByValues(temp_tuple);
     assert(!tuple.isNullTuple());
     return tuple;
 }
开发者ID:sandeepk17,项目名称:voltdb,代码行数:6,代码来源:DRBinaryLog_test.cpp

示例4: p_execute


//.........这里部分代码省略.........
    //  (2) For each tuple that comes back, check whether the
    //  end_expression is false.
    //  If it is, then we stop scanning. Otherwise...
    //  (3) Check whether the tuple satisfies the post expression.
    //      If it does, then add it to the output table
    //
    // Use our search key to prime the index iterator
    // Now loop through each tuple given to us by the iterator
    //

    TableTuple tuple;
    if (activeNumOfSearchKeys > 0) {
        VOLT_TRACE("INDEX_LOOKUP_TYPE(%d) m_numSearchkeys(%d) key:%s",
                   localLookupType, activeNumOfSearchKeys, searchKey.debugNoHeader().c_str());

        if (localLookupType == INDEX_LOOKUP_TYPE_EQ) {
            tableIndex->moveToKey(&searchKey);
        }
        else if (localLookupType == INDEX_LOOKUP_TYPE_GT) {
            tableIndex->moveToGreaterThanKey(&searchKey);
        }
        else if (localLookupType == INDEX_LOOKUP_TYPE_GTE) {
            tableIndex->moveToKeyOrGreater(&searchKey);
        } else if (localLookupType == INDEX_LOOKUP_TYPE_LT) {
            tableIndex->moveToLessThanKey(&searchKey);
        } else if (localLookupType == INDEX_LOOKUP_TYPE_LTE) {
            // find the entry whose key is greater than search key,
            // do a forward scan using initialExpr to find the correct
            // start point to do reverse scan
            bool isEnd = tableIndex->moveToGreaterThanKey(&searchKey);
            if (isEnd) {
                tableIndex->moveToEnd(false);
            } else {
                while (!(tuple = tableIndex->nextValue()).isNullTuple()) {
                    pmp.countdownProgress();
                    if (initial_expression != NULL && !initial_expression->eval(&tuple, NULL).isTrue()) {
                        // just passed the first failed entry, so move 2 backward
                        tableIndex->moveToBeforePriorEntry();
                        break;
                    }
                }
                if (tuple.isNullTuple()) {
                    tableIndex->moveToEnd(false);
                }
            }
        }
        else {
            return false;
        }
    } else {
        bool toStartActually = (localSortDirection != SORT_DIRECTION_TYPE_DESC);
        tableIndex->moveToEnd(toStartActually);
    }

    int tuple_ctr = 0;
    int tuples_skipped = 0;     // for offset
    int limit = -1;
    int offset = -1;
    if (limit_node != NULL) {
        limit_node->getLimitAndOffsetByReference(params, limit, offset);
    }

    //
    // We have to different nextValue() methods for different lookup types
    //
    while ((limit == -1 || tuple_ctr < limit) &&
开发者ID:liyongcun,项目名称:voltdb,代码行数:67,代码来源:indexscanexecutor.cpp

示例5: scanSomeRecords

    // Scan some records in the table, verifying that points that are
    // supposed to be inside are, and those that are not aren't.
    // Print out some stats about how long things took.
    void scanSomeRecords(PersistentTable *table, int numTuples, int numScans) {
        std::cout << "            Scanning for containing polygons on " << numScans << " points...\n";

        auto start = std::chrono::high_resolution_clock::now();
        std::chrono::microseconds usSpentScanning = std::chrono::duration_cast<microseconds>(start - start);
        std::chrono::microseconds usSpentContainsing = std::chrono::duration_cast<microseconds>(start - start);

        CoveringCellIndex* ccIndex = static_cast<CoveringCellIndex*>(table->index("poly_idx"));
        TableTuple tempTuple = table->tempTuple();
        StandAloneTupleStorage searchKey(ccIndex->getKeySchema());

        int numContainingCells = 0;
        int numContainingPolygons = 0;

        for (int i = 0; i < numScans; ++i) {
            // Pick a tuple at random.
            int pk = std::rand() % numTuples;
            tempTuple.setNValue(PK_COL_INDEX, ValueFactory::getIntegerValue(pk));
            TableTuple sampleTuple = table->lookupTupleByValues(tempTuple);
            ASSERT_FALSE(sampleTuple.isNullTuple());

            NValue geog = sampleTuple.getNValue(GEOG_COL_INDEX);
            if (geog.isNull()) {
                // There is one null row in the table.
                continue;
            }

            // The centroid will be inside polygons with one ring, and
            // not inside polygons with two rings (because the second
            // ring is a hole in the center).
            NValue centroid = geog.callUnary<FUNC_VOLT_POLYGON_CENTROID>();
            int32_t numInteriorRings = ValuePeeker::peekAsBigInt(geog.callUnary<FUNC_VOLT_POLYGON_NUM_INTERIOR_RINGS>());

            bool isValid = ValuePeeker::peekBoolean(geog.callUnary<FUNC_VOLT_VALIDATE_POLYGON>());
            if (! isValid) {
                std::ostringstream oss;
                int32_t len;
                const char* reasonChars = ValuePeeker::peekObject_withoutNull(geog.callUnary<FUNC_VOLT_POLYGON_INVALID_REASON>(), &len);
                std::string reason = std::string(reasonChars, len);
                oss << "At " << i << "th scan, expected a valid polygon at pk "
                    << pk << " but isValid says its not because \""
                    << reason << "\".  WKT:\n"
                    << nvalToWkt(geog);

                ASSERT_TRUE_WITH_MESSAGE(isValid, oss.str().c_str());
            }

            start = std::chrono::high_resolution_clock::now();

            searchKey.tuple().setNValue(0, centroid);
            IndexCursor cursor(ccIndex->getTupleSchema());

            bool foundSamplePoly = false;
            bool b = ccIndex->moveToCoveringCell(&searchKey.tuple(), cursor);
            if (b) {
                TableTuple foundTuple = ccIndex->nextValueAtKey(cursor);
                while (! foundTuple.isNullTuple()) {
                    ++numContainingCells;

                    auto startContains = std::chrono::high_resolution_clock::now();
                    bool polygonContains = ValuePeeker::peekBoolean(NValue::call<FUNC_VOLT_CONTAINS>({geog, centroid}));
                    auto endContains = std::chrono::high_resolution_clock::now();
                    usSpentContainsing += std::chrono::duration_cast<microseconds>(endContains - startContains);

                    if (polygonContains)
                        ++numContainingPolygons;

                    int foundPk = ValuePeeker::peekAsInteger(foundTuple.getNValue(PK_COL_INDEX));
                    if (foundPk == pk && polygonContains) {
                        foundSamplePoly = true;
                    }

                    foundTuple = ccIndex->nextValueAtKey(cursor);
                }
            }

            auto end = std::chrono::high_resolution_clock::now();
            usSpentScanning += std::chrono::duration_cast<microseconds>(end - start);

            ASSERT_TRUE(numInteriorRings == 0 || numInteriorRings == 1);

            if (numInteriorRings == 0 && !foundSamplePoly) {
                std::ostringstream oss;
                oss << "At " << i << "th scan, expected to find centroid in polygon with primary key "
                    << pk << ", centroid WKT:\n" << nvalToWkt(centroid)
                    << "\npolygon WKT:\n" << nvalToWkt(geog);
                ASSERT_TRUE_WITH_MESSAGE(foundSamplePoly, oss.str().c_str());
            }
            else if (numInteriorRings == 1) {
                // There was a hole in the center so the centroid is not in the polygon
                ASSERT_TRUE_WITH_MESSAGE(!foundSamplePoly, "Expected to not find centroid contained by polygon with hole in the center");
            }
        }

        auto avgTotalUsSpentScanning = usSpentScanning.count() / numScans;
        auto avgUsSpentContainsing = usSpentContainsing.count() / numScans;
        auto avgUsSpentScanning = avgTotalUsSpentScanning - avgUsSpentContainsing;
//.........这里部分代码省略.........
开发者ID:dinuschen,项目名称:voltdb,代码行数:101,代码来源:CoveringCellIndexTest.cpp

示例6: p_execute


//.........这里部分代码省略.........

            // if it doesn't map to this site
            if (!isLocal) {
                if (!m_multiPartition) {
                    throw ConstraintFailureException(
                            dynamic_cast<PersistentTable*>(targetTable),
                            templateTuple,
                            "Mispartitioned tuple in single-partition insert statement.");
                }

                // don't insert
                continue;
            }
        }

        // for multi partition export tables, only insert into one
        // place (the partition with hash(0)), if the data is from a
        // replicated source.  If the data is coming from a subquery
        // with partitioned tables, we need to perform the insert on
        // every partition.
        if (m_isStreamed && m_multiPartition && !m_sourceIsPartitioned) {
            bool isLocal = m_engine->isLocalSite(ValueFactory::getBigIntValue(0));
            if (!isLocal) continue;
        }


        if (! m_isUpsert) {
            // try to put the tuple into the target table

            if (m_hasPurgeFragment) {
                if (!executePurgeFragmentIfNeeded(&persistentTable))
                    return false;
                // purge fragment might have truncated the table, and
                // refreshed the persistent table pointer.  Make sure to
                // use it when doing the insert below.
                targetTable = persistentTable;
            }

            if (!targetTable->insertTuple(templateTuple)) {
                VOLT_ERROR("Failed to insert tuple from input table '%s' into"
                           " target table '%s'",
                           m_inputTable->name().c_str(),
                           targetTable->name().c_str());
                return false;
            }

        } else {
            // upsert execution logic
            assert(persistentTable->primaryKeyIndex() != NULL);
            TableTuple existsTuple = persistentTable->lookupTupleByValues(templateTuple);

            if (existsTuple.isNullTuple()) {
                // try to put the tuple into the target table

                if (m_hasPurgeFragment) {
                    if (!executePurgeFragmentIfNeeded(&persistentTable))
                        return false;
                }

                if (!persistentTable->insertTuple(templateTuple)) {
                    VOLT_ERROR("Failed to insert tuple from input table '%s' into"
                               " target table '%s'",
                               m_inputTable->name().c_str(),
                               persistentTable->name().c_str());
                    return false;
                }
            } else {
                // tuple exists already, try to update the tuple instead
                upsertTuple.move(templateTuple.address());
                TableTuple &tempTuple = persistentTable->getTempTupleInlined(upsertTuple);

                if (!persistentTable->updateTupleWithSpecificIndexes(existsTuple, tempTuple,
                        persistentTable->allIndexes())) {
                    VOLT_INFO("Failed to update existsTuple from table '%s'",
                            persistentTable->name().c_str());
                    return false;
                }
            }
        }

        // successfully inserted or updated
        modifiedTuples++;
    }

    TableTuple& count_tuple = outputTable->tempTuple();
    count_tuple.setNValue(0, ValueFactory::getBigIntValue(modifiedTuples));
    // try to put the tuple into the output table
    if (!outputTable->insertTuple(count_tuple)) {
        VOLT_ERROR("Failed to insert tuple count (%d) into"
                   " output table '%s'",
                   modifiedTuples,
                   outputTable->name().c_str());
        return false;
    }

    // add to the planfragments count of modified tuples
    m_engine->addToTuplesModified(modifiedTuples);
    VOLT_DEBUG("Finished inserting %d tuples", modifiedTuples);
    return true;
}
开发者ID:DarkDare,项目名称:voltdb,代码行数:101,代码来源:insertexecutor.cpp


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