本文整理汇总了C++中AlignedBuilder类的典型用法代码示例。如果您正苦于以下问题:C++ AlignedBuilder类的具体用法?C++ AlignedBuilder怎么用?C++ AlignedBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AlignedBuilder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: journal
void Journal::journal(const AlignedBuilder& b) {
try {
mutex::scoped_lock lk(_lfMutex);
if( _lf == 0 )
open();
written += b.len();
_lf->synchronousAppend((void *) b.buf(), b.len());
}
catch(std::exception& e) {
log() << "warning exception in dur::journal " << e.what() << endl;
}
}
示例2: prepBasicWrite_inlock
/** put the basic write operation into the buffer (bb) to be journaled */
static void prepBasicWrite_inlock(AlignedBuilder&bb, const WriteIntent *i, RelativePath& lastDbPath) {
size_t ofs = 1;
MongoMMF *mmf = findMMF_inlock(i->start(), /*out*/ofs);
if( unlikely(!mmf->willNeedRemap()) ) {
// tag this mmf as needed a remap of its private view later.
// usually it will already be dirty/already set, so we do the if above first
// to avoid possibility of cpu cache line contention
mmf->willNeedRemap() = true;
}
// since we have already looked up the mmf, we go ahead and remember the write view location
// so we don't have to find the MongoMMF again later in WRITETODATAFILES()
//
// this was for WRITETODATAFILES_Impl2 so commented out now
//
/*
dassert( i->w_ptr == 0 );
i->w_ptr = ((char*)mmf->view_write()) + ofs;
*/
JEntry e;
e.len = min(i->length(), (unsigned)(mmf->length() - ofs)); //dont write past end of file
assert( ofs <= 0x80000000 );
e.ofs = (unsigned) ofs;
e.setFileNo( mmf->fileSuffixNo() );
if( mmf->relativePath() == local ) {
e.setLocalDbContextBit();
}
else if( mmf->relativePath() != lastDbPath ) {
lastDbPath = mmf->relativePath();
JDbContext c;
bb.appendStruct(c);
bb.appendStr(lastDbPath.toString());
}
bb.appendStruct(e);
#if defined(_EXPERIMENTAL)
i->ofsInJournalBuffer = bb.len();
#endif
bb.appendBuf(i->start(), e.len);
if (unlikely(e.len != (unsigned)i->length())) {
log() << "journal info splitting prepBasicWrite at boundary" << endl;
// This only happens if we write to the last byte in a file and
// the fist byte in another file that is mapped adjacently. I
// think most OSs leave at least a one page gap between
// mappings, but better to be safe.
WriteIntent next ((char*)i->start() + e.len, i->length() - e.len);
prepBasicWrite_inlock(bb, &next, lastDbPath);
}
}
示例3: journal
void Journal::journal(const AlignedBuilder& b) {
try {
mutex::scoped_lock lk(_curLogFileMutex);
if( _curLogFile == 0 )
open();
stats.curr._journaledBytes += b.len();
_written += b.len();
_curLogFile->synchronousAppend((void *) b.buf(), b.len());
}
catch(std::exception& e) {
log() << "warning exception in dur::journal " << e.what() << endl;
}
}
示例4: resetLogBuffer
static void resetLogBuffer(/*out*/JSectHeader& h, AlignedBuilder& bb) {
bb.reset();
h.setSectionLen(0xffffffff); // total length, will fill in later
h.seqNumber = getLastDataFileFlushTime();
h.fileId = j.curFileId();
}
示例5: _serialize
void DropDbOp::_serialize(AlignedBuilder& ab) {
ab.appendNum((unsigned long long) 0); // reserved for future use
ab.appendNum((unsigned long long) 0); // reserved for future use
ab.appendStr(_db);
ab.appendStr(""); // reserved
}
示例6: serialize
void DurOp::serialize(AlignedBuilder& ab) {
ab.appendNum(_opcode);
_serialize(ab);
}
示例7: WRITETODATAFILES_Impl1
static void WRITETODATAFILES_Impl1(const JSectHeader& h, AlignedBuilder& uncompressed) {
LockMongoFilesShared lk;
MONGO_LOG(3) << "journal WRITETODATAFILES 1" << endl;
RecoveryJob::get().processSection(&h, uncompressed.buf(), uncompressed.len(), 0);
MONGO_LOG(3) << "journal WRITETODATAFILES 2" << endl;
}
示例8: PREPLOGBUFFER
/** caller handles locking */
static bool PREPLOGBUFFER(AlignedBuilder& bb) {
bb.reset();
unsigned *lenInBlockHeader;
{
// JSectHeader
bb.appendStr("\nHH\n", false);
lenInBlockHeader = (unsigned *) bb.skip(4);
}
string lastFilePath;
{
scoped_lock lk(privateViews._mutex());
for( vector<WriteIntent>::iterator i = wi._writes.begin(); i != wi._writes.end(); i++ ) {
size_t ofs;
MongoMMF *mmf = privateViews._find(i->p, ofs);
if( mmf == 0 ) {
journalingFailure("view pointer cannot be resolved");
}
else {
if( !mmf->dirty() )
mmf->dirty() = true; // usually it will already be dirty so don't bother writing then
{
size_t ofs = ((char *)i->p) - ((char*)mmf->getView().p);
i->w_ptr = ((char*)mmf->view_write()) + ofs;
}
if( mmf->filePath() != lastFilePath ) {
lastFilePath = mmf->filePath();
JDbContext c;
bb.appendStruct(c);
bb.appendStr(lastFilePath);
}
JEntry e;
e.len = i->len;
e.fileNo = mmf->fileSuffixNo();
bb.appendStruct(e);
bb.appendBuf(i->p, i->len);
}
}
}
{
JSectFooter f;
f.hash = 0;
bb.appendStruct(f);
}
{
unsigned L = (bb.len() + 8191) & 0xffffe000; // fill to alignment
dassert( L >= (unsigned) bb.len() );
*lenInBlockHeader = L;
unsigned padding = L - bb.len();
bb.skip(padding);
dassert( bb.len() % 8192 == 0 );
}
return true;
}