示例#1
0
void BDB_RecoverEnv(const string& path,
                    bool          fatal_recover)
{
    DB_ENV  *dbenv;
    int      ret;
    if ((ret = db_env_create(&dbenv, 0)) != 0) {
        string msg =
            "Cannot create environment " + string(db_strerror(ret));
        BDB_THROW(eInvalidOperation, msg);
    }

    dbenv->set_errfile(dbenv, stderr);
    //if (verbose)
    //  (void)dbenv->set_verbose(dbenv, DB_VERB_RECOVERY, 1);

    u_int32_t flags = 0;
    flags |= DB_CREATE | DB_INIT_LOG |
           DB_INIT_MPOOL | DB_INIT_TXN | DB_USE_ENVIRON;
    flags |= fatal_recover ? DB_RECOVER_FATAL : DB_RECOVER;
    flags |= DB_PRIVATE;

    if ((ret = dbenv->open(dbenv, path.c_str(), flags, 0)) != 0) {
        dbenv->close(dbenv, 0);
        string msg =
            "Cannot open environment " + string(db_strerror(ret));
        BDB_THROW(eInvalidOperation, msg);
    }
    ret = dbenv->close(dbenv, 0);
}
示例#2
0
bool
CBDB_ExtBlobMap::GetBlobLoc(Uint4    blob_id,
                            Uint8*   offset,
                            Uint8*   size) const
{
    for (size_t i = 0; i < m_BlobMap.size(); ++i) {
        if (m_BlobMap[i].blob_id == blob_id) {
            const SBlobLoc& bl = m_BlobMap[i];
            if (bl.blob_location_table.size() == 0) {
                _ASSERT(0);
                continue;
            }
            if (bl.blob_location_table.size() != 1) {
                string msg = "Not a single chunk BLOB :" +
                                    NStr::UIntToString(blob_id);
                BDB_THROW(eTooManyChunks, msg);
            }

            if (offset) {
                *offset = bl.blob_location_table[0].offset;
            }
            if (size) {
                *size = bl.blob_location_table[0].size;
            }
            return true;
        }
    } // for
    return false;
}
示例#3
0
CBDB_QueryNode::ELogicalType CBDB_QueryNode::GetLogicType() const
{
    if (m_NodeType == eLogical) {
        return m_SubType.LogicalType;
    }
    // Caller asking to get sub-type as logical when the node type is not
    BDB_THROW(eQueryError, "Incorrect query node type");
}
示例#4
0
CBDB_QueryNode::EOperatorType CBDB_QueryNode::GetOperatorType() const
{
    if (m_NodeType == eOperator) {
        return m_SubType.OperatorType;
    }
    // Caller asking to get sub-type as operator when the node type is not
    BDB_THROW(eQueryError, "Incorrect query node type");
}
示例#5
0
void CBDB_ExtBlobMap::Add(Uint4 blob_id, Uint8 offset, Uint8 size)
{
    if (HasBlob(blob_id)) {
        string msg = "BLOB id already exists:" + NStr::UIntToString(blob_id);
        BDB_THROW(eIdConflict, msg);
    }

    m_BlobMap.push_back(SBlobLoc(blob_id, offset, size));
}
示例#6
0
void CBDB_BlobMetaContainer::GetLoc(Uint8* offset, Uint8* size)
{
    if (m_Loc.size() == 0) {
        _ASSERT(0);
    }
    if (m_Loc.size() != 1) {
        string msg = "Not a single chunk BLOB";
        BDB_THROW(eTooManyChunks, msg);
    }
    if (offset) {
        *offset = m_Loc[0].offset;
    }
    if (size) {
        *size = m_Loc[0].size;
    }
}