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


C++ SharedDatabase::areSnapshotsEnabled方法代码示例

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


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

示例1: visit

void CmdInterpreter::visit(ProxyCmdRollback &cmd)
{
    TxnHandle *pTxnHandle = getTxnHandle(cmd.getTxnHandle());
    SharedDatabase pDb = pTxnHandle->pDb;

    // block checkpoints during this method
    bool txnBlocksCheckpoint = !pTxnHandle->readOnly && pDb->shouldForceTxns();
    SXMutexSharedGuard actionMutexGuard(
        pDb->getCheckpointThread()->getActionMutex());

    if (pDb->areSnapshotsEnabled()) {
        SnapshotRandomAllocationSegment *pSegment =
            SegmentFactory::dynamicCast<SnapshotRandomAllocationSegment *>(
                pTxnHandle->pSnapshotSegment);
        pSegment->rollbackChanges();
    }

    if (cmd.getSvptHandle()) {
        SavepointId svptId = getSavepointId(cmd.getSvptHandle());
        pTxnHandle->pTxn->rollback(&svptId);
    } else {
        pTxnHandle->pTxn->rollback();
        deleteAndNullify(pTxnHandle);
        if (txnBlocksCheckpoint && !pDb->areSnapshotsEnabled()) {
            // Implement rollback by simulating crash recovery,
            // reverting all pages modified by transaction.  No need
            // to do this when snapshots are in use because no permanent
            // pages were modified.
            pDb->recoverOnline();
        }
    }
}
开发者ID:Jach,项目名称:luciddb,代码行数:32,代码来源:CmdInterpreter.cpp

示例2: beginTxn

void CmdInterpreter::beginTxn(ProxyBeginTxnCmd &cmd, bool readOnly, TxnId csn)
{
    assert(readOnly || csn == NULL_TXN_ID);

    // block checkpoints during this method
    DbHandle *pDbHandle = getDbHandle(cmd.getDbHandle());
    SharedDatabase pDb = pDbHandle->pDb;

    SXMutexSharedGuard actionMutexGuard(
        pDb->getCheckpointThread()->getActionMutex());

    std::auto_ptr<TxnHandle> pTxnHandle(newTxnHandle());
    JniUtil::incrementHandleCount(TXNHANDLE_TRACE_TYPE_STR, pTxnHandle.get());
    pTxnHandle->pDb = pDb;
    pTxnHandle->readOnly = readOnly;
    // TODO:  CacheAccessor factory
    pTxnHandle->pTxn = pDb->getTxnLog()->newLogicalTxn(pDb->getCache());
    pTxnHandle->pResourceGovernor = pDbHandle->pResourceGovernor;

    // NOTE:  use a null scratchAccessor; individual ExecStreamGraphs
    // will have their own
    SegmentAccessor scratchAccessor;

    pTxnHandle->pFtrsTableWriterFactory = SharedFtrsTableWriterFactory(
        new FtrsTableWriterFactory(
            pDb,
            pDb->getCache(),
            pDb->getTypeFactory(),
            scratchAccessor));

    // If snapshots are enabled, set up 2 snapshot segments -- one of which
    // only reads committed data.  This will be used for streams that need to
    // read a snapshot of the data before other portions of the stream graph
    // have modified the segment.
    if (pDb->areSnapshotsEnabled()) {
        if (csn == NULL_TXN_ID) {
            csn = pTxnHandle->pTxn->getTxnId();
        }
        pTxnHandle->pSnapshotSegment =
            pDb->getSegmentFactory()->newSnapshotRandomAllocationSegment(
                pDb->getDataSegment(),
                pDb->getDataSegment(),
                csn,
                false);
        pTxnHandle->pReadCommittedSnapshotSegment =
            pDb->getSegmentFactory()->newSnapshotRandomAllocationSegment(
                pDb->getDataSegment(),
                pDb->getDataSegment(),
                csn,
                true);
    } else {
        assert(csn == NULL_TXN_ID);
    }

    setTxnHandle(cmd.getResultHandle(), pTxnHandle.release());
}
开发者ID:Jach,项目名称:luciddb,代码行数:56,代码来源:CmdInterpreter.cpp

示例3: pEnv

extern "C" JNIEXPORT void JNICALL
Java_net_sf_farrago_fennel_FennelStorage_tupleStreamGraphOpen(
    JNIEnv *pEnvInit, jclass, jlong hStreamGraph, jlong hTxn,
    jobject hJavaStreamMap, jobject hJavaErrorTarget)
{
    JniEnvRef pEnv(pEnvInit);
    try {
        CmdInterpreter::StreamGraphHandle &streamGraphHandle =
            CmdInterpreter::getStreamGraphHandleFromLong(hStreamGraph);
        CmdInterpreter::TxnHandle &txnHandle =
            CmdInterpreter::getTxnHandleFromLong(hTxn);
        // Provide runtime context for stream open(), which a scheduler may
        // defer until after our java caller returns: hence the global ref.
        if (streamGraphHandle.javaRuntimeContext) {
            // TODO jvs 13-May-2010:  Use a shared pointer for this
            // like we do with ErrorTarget, and track its JNI handle.
            pEnv->DeleteGlobalRef(streamGraphHandle.javaRuntimeContext);
            streamGraphHandle.javaRuntimeContext = NULL;
        }
        streamGraphHandle.javaRuntimeContext =
            pEnv->NewGlobalRef(hJavaStreamMap);
        streamGraphHandle.pExecStreamGraph->setTxn(txnHandle.pTxn);

        // When snapshots are enabled, switch the delegating segment so
        // the stream graph accesses the snapshot segment associated with
        // the current txn
        SharedDatabase pDb = txnHandle.pDb;
        if (pDb->areSnapshotsEnabled()) {
            DynamicDelegatingSegment *pSegment =
                SegmentFactory::dynamicCast<DynamicDelegatingSegment *>(
                    streamGraphHandle.pSegment);
            pSegment->setDelegatingSegment(
                WeakSegment(txnHandle.pSnapshotSegment));
            pSegment =
                SegmentFactory::dynamicCast<DynamicDelegatingSegment *>(
                    streamGraphHandle.pReadCommittedSegment);
            pSegment->setDelegatingSegment(
                WeakSegment(txnHandle.pReadCommittedSnapshotSegment));
        }
        streamGraphHandle.pExecStreamGraph->setErrorTarget(
            CmdInterpreter::newErrorTarget(hJavaErrorTarget));
        txnHandle.pResourceGovernor->requestResources(
            *(streamGraphHandle.pExecStreamGraph));
        streamGraphHandle.pExecStreamGraph->open();
        if (streamGraphHandle.pScheduler.unique()) {
            streamGraphHandle.pScheduler->start();
        }
    } catch (std::exception &ex) {
        pEnv.handleExcn(ex);
    }
}
开发者ID:Jach,项目名称:luciddb,代码行数:51,代码来源:NativeMethods.cpp


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