|
SNAP Library 2.0, User Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <blobbs.h>
Inherits TBlobBs.
Public Member Functions | |
| TMBlobBs (const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1) | |
| ~TMBlobBs () | |
| TMBlobBs & | operator= (const TMBlobBs &) |
| TStr | GetVersionStr () const |
| TBlobPt | PutBlob (const PSIn &SIn) |
| TBlobPt | PutBlob (const TBlobPt &BlobPt, const PSIn &SIn) |
| PSIn | GetBlob (const TBlobPt &BlobPt) |
| void | DelBlob (const TBlobPt &BlobPt) |
| TBlobPt | GetFirstBlobPt () |
| TBlobPt | FFirstBlobPt () |
| bool | FNextBlobPt (TBlobPt &TrvBlobPt, TBlobPt &BlobPt, PSIn &BlobSIn) |
Static Public Member Functions | |
| static PBlobBs | New (const TStr &BlobBsFNm, const TFAccess &Access=faRdOnly, const int &MxSegLen=-1) |
| static bool | Exists (const TStr &BlobBsFNm) |
Private Member Functions | |
| void | LoadMain (int &Segs) |
| void | SaveMain () const |
Static Private Member Functions | |
| static void | GetNrFPathFMid (const TStr &BlobBsFNm, TStr &NrFPath, TStr &NrFMid) |
| static TStr | GetMainFNm (const TStr &NrFPath, const TStr &NrFMid) |
| static TStr | GetSegFNm (const TStr &NrFPath, const TStr &NrFMid, const int &SegN) |
Private Attributes | |
| TFAccess | Access |
| int | MxSegLen |
| TStr | NrFPath |
| TStr | NrFMid |
| TBlobBsV | SegV |
| int | CurSegN |
| TMBlobBs::TMBlobBs | ( | const TStr & | BlobBsFNm, |
| const TFAccess & | _Access = faRdOnly, |
||
| const int & | _MxSegLen = -1 |
||
| ) |
Definition at line 449 of file blobbs.cpp.
: TBlobBs(), Access(_Access), MxSegLen(_MxSegLen), NrFPath(), NrFMid(), SegV(), CurSegN(0){ if (MxSegLen==-1){MxSegLen=MxBlobFLen;} GetNrFPathFMid(BlobBsFNm, NrFPath, NrFMid); switch (Access){ case faCreate:{ TFile::DelWc(BlobBsFNm+".*"); TStr SegFNm=GetSegFNm(NrFPath, NrFMid, 0); PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen); SegV.Add(Seg); SaveMain(); break;} case faUpdate: case faRdOnly:{ int Segs; LoadMain(Segs); for (int SegN=0; SegN<Segs; SegN++){ TStr SegFNm=GetSegFNm(NrFPath, NrFMid, SegN); SegV.Add(TGBlobBs::New(SegFNm, Access, MxSegLen)); } break;} case faRestore:{ // assume no segments int Segs=-1; // if main-file exists if (TFile::Exists(GetMainFNm(NrFPath, NrFMid))){ // load main file int _Segs; LoadMain(_Segs); // load segment-files which exist Segs=0; forever { // get segment file-name TStr SegFNm=GetSegFNm(NrFPath, NrFMid, Segs); // if segment-file exists then add segment else break check-loop if (TFile::Exists(SegFNm)){ SegV.Add(TGBlobBs::New(SegFNm, Access, MxSegLen)); Segs++; } else { break; } } } // if no segments exist then create blob-base from scratch if (Segs==-1){ TStr SegFNm=GetSegFNm(NrFPath, NrFMid, 0); PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen); SegV.Add(Seg); SaveMain(); } break;} default: Fail; } }
Definition at line 503 of file blobbs.cpp.
| void TMBlobBs::DelBlob | ( | const TBlobPt & | BlobPt | ) | [virtual] |
Implements TBlobBs.
Definition at line 546 of file blobbs.cpp.
| bool TMBlobBs::Exists | ( | const TStr & | BlobBsFNm | ) | [static] |
Definition at line 576 of file blobbs.cpp.
{
TStr NrFPath; TStr NrFMid; GetNrFPathFMid(BlobBsFNm, NrFPath, NrFMid);
TStr MainFNm=GetMainFNm(NrFPath, NrFMid);
return TFile::Exists(MainFNm);
}
| TBlobPt TMBlobBs::FFirstBlobPt | ( | ) | [virtual] |
| bool TMBlobBs::FNextBlobPt | ( | TBlobPt & | TrvBlobPt, |
| TBlobPt & | BlobPt, | ||
| PSIn & | BlobSIn | ||
| ) | [virtual] |
Implements TBlobBs.
Definition at line 559 of file blobbs.cpp.
{
uchar SegN=TrvBlobPt.GetSeg();
if (SegV[SegN]->FNextBlobPt(TrvBlobPt, BlobPt, BlobSIn)){
TrvBlobPt.PutSeg(SegN);
BlobPt.PutSeg(SegN);
return true;
} else
if (SegN==SegV.Len()-1){
return false;
} else {
SegN++;
TrvBlobPt=SegV[SegN]->FFirstBlobPt();
TrvBlobPt.PutSeg(SegN);
return FNextBlobPt(TrvBlobPt, BlobPt, BlobSIn);
}
}
| PSIn TMBlobBs::GetBlob | ( | const TBlobPt & | BlobPt | ) | [virtual] |
Implements TBlobBs.
Definition at line 541 of file blobbs.cpp.
| TBlobPt TMBlobBs::GetFirstBlobPt | ( | ) | [virtual] |
Implements TBlobBs.
Definition at line 551 of file blobbs.cpp.
{
return SegV[0]->GetFirstBlobPt();
}
| TStr TMBlobBs::GetMainFNm | ( | const TStr & | NrFPath, |
| const TStr & | NrFMid | ||
| ) | [static, private] |
Definition at line 423 of file blobbs.cpp.
{
return NrFPath+NrFMid+".mbb";
}
| void TMBlobBs::GetNrFPathFMid | ( | const TStr & | BlobBsFNm, |
| TStr & | NrFPath, | ||
| TStr & | NrFMid | ||
| ) | [static, private] |
Definition at line 417 of file blobbs.cpp.
{
NrFPath=TStr::GetNrFPath(BlobBsFNm.GetFPath());
NrFMid=TStr::GetNrFMid(BlobBsFNm.GetFMid());
}
| TStr TMBlobBs::GetSegFNm | ( | const TStr & | NrFPath, |
| const TStr & | NrFMid, | ||
| const int & | SegN | ||
| ) | [static, private] |
Definition at line 428 of file blobbs.cpp.
{
return NrFPath+NrFMid+".mbb"+""+TStr::GetNrNumFExt(SegN);
}
| TStr TMBlobBs::GetVersionStr | ( | ) | const [inline, virtual] |
| void TMBlobBs::LoadMain | ( | int & | Segs | ) | [private] |
Definition at line 433 of file blobbs.cpp.
{
PSIn SIn=TFIn::New(GetMainFNm(NrFPath, NrFMid));
TILx Lx(SIn, TFSet()|oloFrcEoln|oloSigNum|oloCsSens);
EAssert(Lx.GetVarStr("Version")==GetVersionStr());
MxSegLen=Lx.GetVarInt("MxSegLen");
Segs=Lx.GetVarInt("Segments");
}
| static PBlobBs TMBlobBs::New | ( | const TStr & | BlobBsFNm, |
| const TFAccess & | Access = faRdOnly, |
||
| const int & | MxSegLen = -1 |
||
| ) | [inline, static] |
| TBlobPt TMBlobBs::PutBlob | ( | const PSIn & | SIn | ) | [virtual] |
Implements TBlobBs.
Definition at line 509 of file blobbs.cpp.
{
EAssert((Access==faCreate)||(Access==faUpdate)||(Access==faRestore));
TBlobPt BlobPt=SegV[CurSegN]->PutBlob(SIn);
if (BlobPt.Empty()){
for (uchar SegN=0; SegN<SegV.Len(); SegN++){
BlobPt=SegV[CurSegN=SegN]->PutBlob(SIn);
if (!BlobPt.Empty()){break;}
}
if (BlobPt.Empty()){
TStr SegFNm=GetSegFNm(NrFPath, NrFMid, SegV.Len());
PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen);
CurSegN=SegV.Add(Seg); EAssert(CurSegN<=255);
BlobPt=SegV[CurSegN]->PutBlob(SIn);
}
}
if (!BlobPt.Empty()){
BlobPt.PutSeg(uchar(CurSegN));}
return BlobPt;
}
| TBlobPt TMBlobBs::PutBlob | ( | const TBlobPt & | BlobPt, |
| const PSIn & | SIn | ||
| ) | [virtual] |
Implements TBlobBs.
Definition at line 529 of file blobbs.cpp.
| void TMBlobBs::SaveMain | ( | ) | const [private] |
Definition at line 441 of file blobbs.cpp.
{
PSOut SOut=TFOut::New(GetMainFNm(NrFPath, NrFMid));
TOLx Lx(SOut, TFSet()|oloFrcEoln|oloSigNum|oloCsSens);
Lx.PutVarStr("Version", GetVersionStr());
Lx.PutVarInt("MxSegLen", MxSegLen);
Lx.PutVarInt("Segments", SegV.Len());
}
TFAccess TMBlobBs::Access [private] |
int TMBlobBs::CurSegN [private] |
int TMBlobBs::MxSegLen [private] |
TStr TMBlobBs::NrFMid [private] |
TStr TMBlobBs::NrFPath [private] |
TBlobBsV TMBlobBs::SegV [private] |