本文整理汇总了C++中HDB::findBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ HDB::findBlock方法的具体用法?C++ HDB::findBlock怎么用?C++ HDB::findBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HDB
的用法示例。
在下文中一共展示了HDB::findBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
Int32
HDBNode::write(HDBHandle& hdl, EWriteHeaderFlag onlyHeader)
{
if (!m_pdata)
{
OW_THROW(HDBException, "Internal error: Cannot write null node");
}
bool newRecord = false;
m_pdata->m_blk.keyLength = m_pdata->m_key.length() + 1;
m_pdata->m_blk.dataLength = m_pdata->m_bfrLen + m_pdata->m_key.length() + 1;
File file = hdl.getFile();
HDB* phdb = hdl.getHDB();
int totalSize = m_pdata->m_blk.dataLength + sizeof(m_pdata->m_blk);
m_pdata->m_blk.isFree = false;
if (m_pdata->m_offset <= 0) // Is this a new node?
{
newRecord = true;
m_pdata->m_blk.size = totalSize;
m_pdata->m_offset = phdb->findBlock(file, totalSize);
if (m_pdata->m_blk.parent <= 0)
{
phdb->addRootNode(file, m_pdata->m_blk, m_pdata->m_offset);
}
else
{
HDB::writeBlock(m_pdata->m_blk, file, m_pdata->m_offset);
}
// Add this entry to the index
if (!hdl.addIndexEntry(m_pdata->m_key.c_str(), m_pdata->m_offset))
{
OW_THROW(HDBException, "Failed to write index entry");
}
}
else
{
// If the size required to hold this node has increased,
// then delete the old block and add a new one.
if (totalSize > int(m_pdata->m_blk.size))
{
HDBBlock node = m_pdata->m_blk;
phdb->addBlockToFreeList(file, node, m_pdata->m_offset); // delete old
m_pdata->m_blk.size = totalSize;
updateOffsets(hdl, phdb->findBlock(file, totalSize));
}
HDB::writeBlock(m_pdata->m_blk, file, m_pdata->m_offset);
}
if (onlyHeader == false || newRecord == true)
{
// Now write key and data for node
if (file.write(m_pdata->m_key.c_str(), m_pdata->m_key.length()+1)
!= m_pdata->m_key.length()+1)
{
OW_THROW_ERRNO_MSG(HDBException, "Failed to write node key");
}
if (file.write(m_pdata->m_bfr, m_pdata->m_bfrLen)
!= size_t(m_pdata->m_bfrLen))
{
OW_THROW_ERRNO_MSG(HDBException, "Failed to write node data");
}
}
m_pdata->m_version = hdl.registerWrite();
return m_pdata->m_offset;
}