本文整理汇总了C++中AutoHD::free方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoHD::free方法的具体用法?C++ AutoHD::free怎么用?C++ AutoHD::free使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoHD
的用法示例。
在下文中一共展示了AutoHD::free方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setValsProc
bool ModVArchEl::setValsProc( TValBuf &buf, int64_t beg, int64_t end )
{
if(needMeta && (needMeta=!readMeta())) return false;
//Check border
if(!buf.vOK(beg,end)) return false;
beg = vmax(beg, buf.begin());
end = vmin(end, buf.end());
beg = (beg/period())*period();
end = (end/period())*period();
//Table struct init
TConfig cfg((archive().valType()==TFld::Real) ? (&mod->vlRealEl()) :
(archive().valType()==TFld::String) ? (&mod->vlStrEl()) : &mod->vlIntEl());
AutoHD<TTable> tbl = SYS->db().at().open(archivator().addr()+"."+archTbl(), true);
if(tbl.freeStat()) return false;
//Write data to table
for(int64_t ctm; beg <= end; beg++) {
switch(archive().valType()) {
case TFld::Boolean: cfg.cfg("VAL").setI(buf.getB(&beg,true)); break;
case TFld::Integer: cfg.cfg("VAL").setI(buf.getI(&beg,true)); break;
case TFld::Real: cfg.cfg("VAL").setR(buf.getR(&beg,true)); break;
case TFld::String: cfg.cfg("VAL").setS(buf.getS(&beg,true)); break;
default: break;
}
ctm = (beg/period())*period();
cfg.cfg("TM").setI(ctm/1000000);
cfg.cfg("TMU").setI(ctm%1000000);
tbl.at().fieldSet(cfg);
//Archive time border update
mBeg = mBeg ? vmin(mBeg,ctm) : ctm;
mEnd = mEnd ? vmax(mEnd,ctm) : ctm;
}
//Archive size limit process
if((mEnd-mBeg) > (int64_t)(archivator().maxSize()*3600e6)) {
int64_t n_end = ((mEnd-(int64_t)(archivator().maxSize()*3600e6))/period())*period();
for(int64_t t_c = vmax(mBeg,n_end-3600ll*period()); t_c < n_end; t_c += period()) {
cfg.cfg("TM").setI(t_c/1000000, true);
cfg.cfg("TMU").setI(t_c%1000000, true);
tbl.at().fieldDel(cfg);
}
mBeg = n_end;
}
tbl.free();
SYS->db().at().close(archivator().addr()+"."+archTbl());
//Update archive info
cfg.setElem(&mod->archEl());
cfg.cfgViewAll(false);
cfg.cfg("TBL").setS(archTbl(), true);
cfg.cfg("BEGIN").setS(ll2s(mBeg), true);
cfg.cfg("END").setS(ll2s(mEnd), true);
cfg.cfg("PRM1").setS(ll2s(mPer), true);
return SYS->db().at().dataSet(archivator().addr()+"."+mod->mainTbl(),"",cfg,false,true);
}
示例2: put
bool ModMArch::put( vector<TMess::SRec> &mess, bool force )
{
if(needMeta && (needMeta=!readMeta())) return false;
TMArchivator::put(mess, force); //Allow redundancy
if(!runSt) throw TError(nodePath().c_str(), _("The archive is not started!"));
AutoHD<TTable> tbl = SYS->db().at().open(addr()+"."+archTbl(), true);
if(tbl.freeStat()) return false;
TConfig cfg(&reqEl);
int64_t t_cnt = TSYS::curTime();
for(unsigned i_m = 0; i_m < mess.size(); i_m++) {
if(!chkMessOK(mess[i_m].categ,mess[i_m].level)) continue;
//Put record to DB
cfg.cfg("MIN").setI(mess[i_m].time/60);
cfg.cfg("TM").setI(mess[i_m].time);
cfg.cfg("TMU").setI(mess[i_m].utime);
cfg.cfg("CATEG").setS(mess[i_m].categ);
cfg.cfg("MESS").setS(mess[i_m].mess);
cfg.cfg("LEV").setI(mess[i_m].level);
tbl.at().fieldSet(cfg);
//Archive time border update
mBeg = mBeg ? vmin(mBeg,mess[i_m].time) : mess[i_m].time;
mEnd = mEnd ? vmax(mEnd,mess[i_m].time) : mess[i_m].time;
}
//Archive size limit process
if(maxSize() && (mEnd-mBeg) > (time_t)(maxSize()*86400)) {
time_t nEnd = mEnd - (time_t)(maxSize()*86400);
cfg.cfg("TM").setKeyUse(false);
for(int tC = mBeg/60; tC < nEnd/60; tC++) {
cfg.cfg("MIN").setI(tC, true);
tbl.at().fieldDel(cfg);
}
mBeg = nEnd;
}
tbl.free();
//SYS->db().at().close(addr()+"."+archTbl()); //!!! No close the table manually
//Update archive info
cfg.setElem(&mod->archEl());
cfg.cfgViewAll(false);
cfg.cfg("TBL").setS(archTbl(),true);
cfg.cfg("BEGIN").setS(i2s(mBeg),true);
cfg.cfg("END").setS(i2s(mEnd),true);
bool rez = SYS->db().at().dataSet(addr()+"."+mod->mainTbl(),"",cfg,false,true);
tmProc = TSYS::curTime() - t_cnt; tmProcMax = vmax(tmProcMax, tmProc);
return rez;
}
示例3: messPut
void TSocketIn::messPut( int sock, string &request, string &answer, string sender, AutoHD<TProtocolIn> &prot_in )
{
AutoHD<TProtocol> proto;
string n_pr = mod->modId()+"_"+id()+"_"+TSYS::int2str(sock);
try
{
proto = SYS->protocol().at().modAt(protocol());
if( prot_in.freeStat() )
{
if( !proto.at().openStat(n_pr) ) proto.at().open( n_pr, workId() );
prot_in = proto.at().at( n_pr );
}
if( prot_in.at().mess(request,answer,sender) ) return;
prot_in.free();
if( proto.at().openStat(n_pr) ) proto.at().close(n_pr);
}catch(TError err)
{
prot_in.free();
if( !proto.freeStat() && proto.at().openStat(n_pr) ) proto.at().close( n_pr );
mess_err(nodePath().c_str(),"%s",err.mess.c_str() );
mess_err(nodePath().c_str(),_("Error request to protocol."));
}
}
示例4: put
bool ModMArch::put( vector<TMess::SRec> &mess )
{
if(!run_st) throw TError(nodePath().c_str(), _("Archive is not started!"));
AutoHD<TTable> tbl = SYS->db().at().open(addr()+"."+archTbl(), true);
if(tbl.freeStat()) return false;
TConfig cfg(&mod->messEl());
int64_t t_cnt = TSYS::curTime();
for(unsigned i_m = 0; i_m < mess.size(); i_m++) {
if(!chkMessOK(mess[i_m].categ,mess[i_m].level)) continue;
//Put record to DB
cfg.cfg("TM").setI(mess[i_m].time);
cfg.cfg("TMU").setI(mess[i_m].utime);
cfg.cfg("CATEG").setS(mess[i_m].categ);
cfg.cfg("MESS").setS(mess[i_m].mess);
cfg.cfg("LEV").setI(mess[i_m].level);
tbl.at().fieldSet(cfg);
//Archive time border update
mBeg = mBeg ? vmin(mBeg,mess[i_m].time) : mess[i_m].time;
mEnd = mEnd ? vmax(mEnd,mess[i_m].time) : mess[i_m].time;
}
//Archive size limit process
if((mEnd-mBeg) > (time_t)(maxSize()*3600)) {
time_t n_end = mEnd-(time_t)(maxSize()*3600);
for(time_t t_c = vmax(mBeg,n_end-3600); t_c < n_end; t_c++) {
cfg.cfg("TM").setI(t_c,true);
tbl.at().fieldDel(cfg);
}
mBeg = n_end;
}
tbl.free();
SYS->db().at().close(addr()+"."+archTbl());
//Update archive info
cfg.setElem(&mod->archEl());
cfg.cfgViewAll(false);
cfg.cfg("TBL").setS(archTbl(),true);
cfg.cfg("BEGIN").setS(i2s(mBeg),true);
cfg.cfg("END").setS(i2s(mEnd),true);
bool rez = SYS->db().at().dataSet(addr()+"."+mod->mainTbl(),"",cfg,false,true);
tm_calc = 1e-3*(TSYS::curTime()-t_cnt);
return rez;
}