SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TMBlobBs Class Reference

#include <blobbs.h>

Inheritance diagram for TMBlobBs:
Collaboration diagram for TMBlobBs:

Public Member Functions

 TMBlobBs (const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1)
 
 ~TMBlobBs ()
 
TMBlobBsoperator= (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)
 
- Public Member Functions inherited from TBlobBs
 UndefCopyAssign (TBlobBs)
 
 TBlobBs ()
 
virtual ~TBlobBs ()
 
 TBlobBs (TSIn &)
 
void Save (TSOut &) const
 
void PutVersionStr (const PFRnd &FBlobBs)
 
void AssertVersionStr (const PFRnd &FBlobBs)
 
TStr GetBlobBsStateStr (const TBlobBsState &BlobBsState)
 
int GetStateStrLen ()
 
void PutBlobBsStateStr (const PFRnd &FBlobBs, const TBlobBsState &State)
 
void AssertBlobBsStateStr (const PFRnd &FBlobBs, const TBlobBsState &State)
 
void PutMxSegLen (const PFRnd &FBlobBs, const int &MxSegLen)
 
int GetMxSegLen (const PFRnd &FBlobBs)
 
void GenBlockLenV (TIntV &BlockLenV)
 
void PutBlockLenV (const PFRnd &FBlobBs, const TIntV &BlockLenV)
 
void GetBlockLenV (const PFRnd &FBlobBs, TIntV &BlockLenV)
 
void GenFFreeBlobPtV (const TIntV &BlockLenV, TBlobPtV &FFreeBlobPtV)
 
void PutFFreeBlobPtV (const PFRnd &FBlobBs, const TBlobPtV &FFreeBlobPtV)
 
void GetFFreeBlobPtV (const PFRnd &FBlobBs, TBlobPtV &FFreeBlobPtV)
 
void GetAllocInfo (const int &BfL, const TIntV &BlockLenV, int &MxBfL, int &FFreeBlobPtN)
 
uint GetBeginBlobTag ()
 
uint GetEndBlobTag ()
 
void PutBlobTag (const PFRnd &FBlobBs, const TBlobTag &BlobTag)
 
void AssertBlobTag (const PFRnd &FBlobBs, const TBlobTag &BlobTag)
 
void PutBlobState (const PFRnd &FBlobBs, const TBlobState &State)
 
TBlobState GetBlobState (const PFRnd &FBlobBs)
 
void AssertBlobState (const PFRnd &FBlobBs, const TBlobState &State)
 
void AssertBfCsEqFlCs (const TCs &BfCs, const TCs &FCs)
 
TBlobPt PutBlob (const TStr &Str)
 
bool FNextBlobPt (TBlobPt &TrvBlobPt, 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)
 
- Static Public Member Functions inherited from TBlobBs
static PBlobBs Load (TSIn &)
 

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
 

Additional Inherited Members

- Static Public Attributes inherited from TBlobBs
static const int MnBlobBfL =16
 
static const int MxBlobFLen =1000000000
 
static const TStr MxSegLenVNm ="MxSegLen"
 
static const TStr BlockLenVNm ="BlockLenV"
 
static const TStr FFreeBlobPtVNm ="FFreeBlobPtV"
 

Detailed Description

Definition at line 188 of file blobbs.h.

Constructor & Destructor Documentation

TMBlobBs::TMBlobBs ( const TStr BlobBsFNm,
const TFAccess _Access = faRdOnly,
const int &  _MxSegLen = -1 
)

Definition at line 449 of file blobbs.cpp.

References Access, TVec< TVal, TSizeTy >::Add(), TFile::DelWc(), TFile::Exists(), faCreate, Fail, faRdOnly, faRestore, faUpdate, forever, GetMainFNm(), GetNrFPathFMid(), GetSegFNm(), LoadMain(), TBlobBs::MxBlobFLen, MxSegLen, TGBlobBs::New(), NrFMid, NrFPath, SaveMain(), and SegV.

Referenced by New().

450  :
451  TBlobBs(), Access(_Access), MxSegLen(_MxSegLen),
452  NrFPath(), NrFMid(), SegV(), CurSegN(0){
453  if (MxSegLen==-1){MxSegLen=MxBlobFLen;}
454  GetNrFPathFMid(BlobBsFNm, NrFPath, NrFMid);
455  switch (Access){
456  case faCreate:{
457  TFile::DelWc(BlobBsFNm+".*");
458  TStr SegFNm=GetSegFNm(NrFPath, NrFMid, 0);
459  PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen);
460  SegV.Add(Seg);
461  SaveMain(); break;}
462  case faUpdate:
463  case faRdOnly:{
464  int Segs; LoadMain(Segs);
465  for (int SegN=0; SegN<Segs; SegN++){
466  TStr SegFNm=GetSegFNm(NrFPath, NrFMid, SegN);
467  SegV.Add(TGBlobBs::New(SegFNm, Access, MxSegLen));
468  }
469  break;}
470  case faRestore:{
471  // assume no segments
472  int Segs=-1;
473  // if main-file exists
475  // load main file
476  int _Segs; LoadMain(_Segs);
477  // load segment-files which exist
478  Segs=0;
479  forever {
480  // get segment file-name
481  TStr SegFNm=GetSegFNm(NrFPath, NrFMid, Segs);
482  // if segment-file exists then add segment else break check-loop
483  if (TFile::Exists(SegFNm)){
484  SegV.Add(TGBlobBs::New(SegFNm, Access, MxSegLen));
485  Segs++;
486  } else {
487  break;
488  }
489  }
490  }
491  // if no segments exist then create blob-base from scratch
492  if (Segs==-1){
493  TStr SegFNm=GetSegFNm(NrFPath, NrFMid, 0);
494  PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen);
495  SegV.Add(Seg);
496  SaveMain();
497  }
498  break;}
499  default: Fail;
500  }
501 }
static void GetNrFPathFMid(const TStr &BlobBsFNm, TStr &NrFPath, TStr &NrFMid)
Definition: blobbs.cpp:417
Definition: fl.h:347
void SaveMain() const
Definition: blobbs.cpp:441
static bool Exists(const TStr &FNm)
Definition: fl.cpp:1156
#define forever
Definition: bd.h:6
static TStr GetSegFNm(const TStr &NrFPath, const TStr &NrFMid, const int &SegN)
Definition: blobbs.cpp:428
#define Fail
Definition: bd.h:238
Definition: fl.h:347
void LoadMain(int &Segs)
Definition: blobbs.cpp:433
TBlobBs()
Definition: blobbs.h:95
static void DelWc(const TStr &WcStr, const bool &RecurseDirP=false)
Definition: fl.cpp:1264
Definition: fl.h:347
static PBlobBs New(const TStr &BlobBsFNm, const TFAccess &Access=faRdOnly, const int &MxSegLen=-1)
Definition: blobbs.h:166
TFAccess Access
Definition: blobbs.h:190
TStr NrFPath
Definition: blobbs.h:192
TBlobBsV SegV
Definition: blobbs.h:193
static TStr GetMainFNm(const TStr &NrFPath, const TStr &NrFMid)
Definition: blobbs.cpp:423
int CurSegN
Definition: blobbs.h:194
Definition: dt.h:412
TStr NrFMid
Definition: blobbs.h:192
Definition: bd.h:196
int MxSegLen
Definition: blobbs.h:191
static const int MxBlobFLen
Definition: blobbs.h:92
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
Definition: fl.h:347

Here is the call graph for this function:

Here is the caller graph for this function:

TMBlobBs::~TMBlobBs ( )

Definition at line 503 of file blobbs.cpp.

References Access, faRdOnly, and SaveMain().

503  {
504  if (Access!=faRdOnly){
505  SaveMain();
506  }
507 }
void SaveMain() const
Definition: blobbs.cpp:441
Definition: fl.h:347
TFAccess Access
Definition: blobbs.h:190

Here is the call graph for this function:

Member Function Documentation

void TMBlobBs::DelBlob ( const TBlobPt BlobPt)
virtual

Implements TBlobBs.

Definition at line 546 of file blobbs.cpp.

References TBlobPt::GetSeg(), and SegV.

546  {
547  int SegN=BlobPt.GetSeg();
548  SegV[SegN]->DelBlob(BlobPt);
549 }
uchar GetSeg() const
Definition: blobbs.h:52
TBlobBsV SegV
Definition: blobbs.h:193

Here is the call graph for this function:

bool TMBlobBs::Exists ( const TStr BlobBsFNm)
static

Definition at line 576 of file blobbs.cpp.

References TFile::Exists(), GetMainFNm(), GetNrFPathFMid(), NrFMid, and NrFPath.

576  {
577  TStr NrFPath; TStr NrFMid; GetNrFPathFMid(BlobBsFNm, NrFPath, NrFMid);
578  TStr MainFNm=GetMainFNm(NrFPath, NrFMid);
579  return TFile::Exists(MainFNm);
580 }
static void GetNrFPathFMid(const TStr &BlobBsFNm, TStr &NrFPath, TStr &NrFMid)
Definition: blobbs.cpp:417
static bool Exists(const TStr &FNm)
Definition: fl.cpp:1156
TStr NrFPath
Definition: blobbs.h:192
static TStr GetMainFNm(const TStr &NrFPath, const TStr &NrFMid)
Definition: blobbs.cpp:423
Definition: dt.h:412
TStr NrFMid
Definition: blobbs.h:192

Here is the call graph for this function:

TBlobPt TMBlobBs::FFirstBlobPt ( )
virtual

Implements TBlobBs.

Definition at line 555 of file blobbs.cpp.

References SegV.

555  {
556  return SegV[0]->FFirstBlobPt();
557 }
TBlobBsV SegV
Definition: blobbs.h:193
bool TMBlobBs::FNextBlobPt ( TBlobPt TrvBlobPt,
TBlobPt BlobPt,
PSIn BlobSIn 
)
virtual

Implements TBlobBs.

Definition at line 559 of file blobbs.cpp.

References TBlobPt::GetSeg(), TVec< TVal, TSizeTy >::Len(), TBlobPt::PutSeg(), and SegV.

559  {
560  uchar SegN=TrvBlobPt.GetSeg();
561  if (SegV[SegN]->FNextBlobPt(TrvBlobPt, BlobPt, BlobSIn)){
562  TrvBlobPt.PutSeg(SegN);
563  BlobPt.PutSeg(SegN);
564  return true;
565  } else
566  if (SegN==SegV.Len()-1){
567  return false;
568  } else {
569  SegN++;
570  TrvBlobPt=SegV[SegN]->FFirstBlobPt();
571  TrvBlobPt.PutSeg(SegN);
572  return FNextBlobPt(TrvBlobPt, BlobPt, BlobSIn);
573  }
574 }
uchar GetSeg() const
Definition: blobbs.h:52
void PutSeg(const uchar &_Seg)
Definition: blobbs.h:51
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
unsigned char uchar
Definition: bd.h:10
TBlobBsV SegV
Definition: blobbs.h:193
bool FNextBlobPt(TBlobPt &TrvBlobPt, TBlobPt &BlobPt, PSIn &BlobSIn)
Definition: blobbs.cpp:559

Here is the call graph for this function:

PSIn TMBlobBs::GetBlob ( const TBlobPt BlobPt)
virtual

Implements TBlobBs.

Definition at line 541 of file blobbs.cpp.

References TBlobPt::GetSeg(), and SegV.

541  {
542  int SegN=BlobPt.GetSeg();
543  return SegV[SegN]->GetBlob(BlobPt);
544 }
uchar GetSeg() const
Definition: blobbs.h:52
TBlobBsV SegV
Definition: blobbs.h:193

Here is the call graph for this function:

TBlobPt TMBlobBs::GetFirstBlobPt ( )
virtual

Implements TBlobBs.

Definition at line 551 of file blobbs.cpp.

References SegV.

551  {
552  return SegV[0]->GetFirstBlobPt();
553 }
TBlobBsV SegV
Definition: blobbs.h:193
TStr TMBlobBs::GetMainFNm ( const TStr NrFPath,
const TStr NrFMid 
)
staticprivate

Definition at line 423 of file blobbs.cpp.

Referenced by Exists(), LoadMain(), SaveMain(), and TMBlobBs().

424  {
425  return NrFPath+NrFMid+".mbb";
426 }

Here is the caller graph for this function:

void TMBlobBs::GetNrFPathFMid ( const TStr BlobBsFNm,
TStr NrFPath,
TStr NrFMid 
)
staticprivate

Definition at line 417 of file blobbs.cpp.

References TStr::GetFMid(), TStr::GetFPath(), TStr::GetNrFMid(), and TStr::GetNrFPath().

Referenced by Exists(), and TMBlobBs().

418  {
419  NrFPath=TStr::GetNrFPath(BlobBsFNm.GetFPath());
420  NrFMid=TStr::GetNrFMid(BlobBsFNm.GetFMid());
421 }
TStr GetFMid() const
Definition: dt.cpp:1403
TStr GetFPath() const
Definition: dt.cpp:1389
static TStr GetNrFMid(const TStr &FMid)
Definition: dt.cpp:1445
static TStr GetNrFPath(const TStr &FPath)
Definition: dt.cpp:1430

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TMBlobBs::GetSegFNm ( const TStr NrFPath,
const TStr NrFMid,
const int &  SegN 
)
staticprivate

Definition at line 428 of file blobbs.cpp.

References TStr::GetNrNumFExt().

Referenced by PutBlob(), and TMBlobBs().

429  {
430  return NrFPath+NrFMid+".mbb"+""+TStr::GetNrNumFExt(SegN);
431 }
static TStr GetNrNumFExt(const int &FExtN)
Definition: dt.cpp:1460

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TMBlobBs::GetVersionStr ( ) const
inlinevirtual

Implements TBlobBs.

Definition at line 210 of file blobbs.h.

Referenced by LoadMain(), and SaveMain().

210  {
211  return TStr("Multiple-File Blob Base Format 1.0");}
Definition: dt.h:412

Here is the caller graph for this function:

void TMBlobBs::LoadMain ( int &  Segs)
private

Definition at line 433 of file blobbs.cpp.

References EAssert, GetMainFNm(), TILx::GetVarInt(), TILx::GetVarStr(), GetVersionStr(), MxSegLen, TFIn::New(), NrFMid, NrFPath, oloCsSens, oloFrcEoln, and oloSigNum.

Referenced by TMBlobBs().

433  {
436  EAssert(Lx.GetVarStr("Version")==GetVersionStr());
437  MxSegLen=Lx.GetVarInt("MxSegLen");
438  Segs=Lx.GetVarInt("Segments");
439 }
Definition: lx.h:248
Definition: bits.h:119
static PSIn New(const TStr &FNm)
Definition: fl.cpp:290
Definition: lx.h:129
TStr NrFPath
Definition: blobbs.h:192
static TStr GetMainFNm(const TStr &NrFPath, const TStr &NrFMid)
Definition: blobbs.cpp:423
TStr GetVersionStr() const
Definition: blobbs.h:210
#define EAssert(Cond)
Definition: bd.h:280
Definition: lx.h:249
TStr NrFMid
Definition: blobbs.h:192
Definition: lx.h:248
int MxSegLen
Definition: blobbs.h:191

Here is the call graph for this function:

Here is the caller graph for this function:

static PBlobBs TMBlobBs::New ( const TStr BlobBsFNm,
const TFAccess Access = faRdOnly,
const int &  MxSegLen = -1 
)
inlinestatic

Definition at line 203 of file blobbs.h.

References TMBlobBs().

204  {
205  return PBlobBs(new TMBlobBs(BlobBsFNm, Access, MxSegLen));}
TFAccess Access
Definition: blobbs.h:190
TPt< TBlobBs > PBlobBs
Definition: blobbs.h:89
int MxSegLen
Definition: blobbs.h:191
TMBlobBs(const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1)
Definition: blobbs.cpp:449

Here is the call graph for this function:

TMBlobBs& TMBlobBs::operator= ( const TMBlobBs )
inline

Definition at line 208 of file blobbs.h.

References Fail.

208 {Fail; return *this;}
#define Fail
Definition: bd.h:238
TBlobPt TMBlobBs::PutBlob ( const PSIn SIn)
virtual

Implements TBlobBs.

Definition at line 509 of file blobbs.cpp.

References Access, TVec< TVal, TSizeTy >::Add(), CurSegN, EAssert, TBlobPt::Empty(), faCreate, faRestore, faUpdate, GetSegFNm(), TVec< TVal, TSizeTy >::Len(), MxSegLen, TGBlobBs::New(), NrFMid, NrFPath, TBlobPt::PutSeg(), and SegV.

Referenced by PutBlob().

509  {
511  TBlobPt BlobPt=SegV[CurSegN]->PutBlob(SIn);
512  if (BlobPt.Empty()){
513  for (uchar SegN=0; SegN<SegV.Len(); SegN++){
514  BlobPt=SegV[CurSegN=SegN]->PutBlob(SIn);
515  if (!BlobPt.Empty()){break;}
516  }
517  if (BlobPt.Empty()){
518  TStr SegFNm=GetSegFNm(NrFPath, NrFMid, SegV.Len());
519  PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen);
520  CurSegN=SegV.Add(Seg); EAssert(CurSegN<=255);
521  BlobPt=SegV[CurSegN]->PutBlob(SIn);
522  }
523  }
524  if (!BlobPt.Empty()){
525  BlobPt.PutSeg(uchar(CurSegN));}
526  return BlobPt;
527 }
void PutSeg(const uchar &_Seg)
Definition: blobbs.h:51
Definition: fl.h:347
static TStr GetSegFNm(const TStr &NrFPath, const TStr &NrFMid, const int &SegN)
Definition: blobbs.cpp:428
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
Definition: fl.h:347
static PBlobBs New(const TStr &BlobBsFNm, const TFAccess &Access=faRdOnly, const int &MxSegLen=-1)
Definition: blobbs.h:166
TFAccess Access
Definition: blobbs.h:190
unsigned char uchar
Definition: bd.h:10
TStr NrFPath
Definition: blobbs.h:192
TBlobBsV SegV
Definition: blobbs.h:193
int CurSegN
Definition: blobbs.h:194
#define EAssert(Cond)
Definition: bd.h:280
bool Empty() const
Definition: blobbs.h:49
Definition: dt.h:412
Definition: blobbs.h:5
TStr NrFMid
Definition: blobbs.h:192
Definition: bd.h:196
int MxSegLen
Definition: blobbs.h:191
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
Definition: fl.h:347

Here is the call graph for this function:

Here is the caller graph for this function:

TBlobPt TMBlobBs::PutBlob ( const TBlobPt BlobPt,
const PSIn SIn 
)
virtual

Implements TBlobBs.

Definition at line 529 of file blobbs.cpp.

References Access, EAssert, TBlobPt::Empty(), faCreate, faRestore, faUpdate, TBlobPt::GetSeg(), PutBlob(), TBlobPt::PutSeg(), and SegV.

529  {
531  int SegN=BlobPt.GetSeg();
532  TBlobPt NewBlobPt=SegV[SegN]->PutBlob(BlobPt, SIn);
533  if (NewBlobPt.Empty()){
534  NewBlobPt=PutBlob(SIn);
535  } else {
536  NewBlobPt.PutSeg(BlobPt.GetSeg());
537  }
538  return NewBlobPt;
539 }
uchar GetSeg() const
Definition: blobbs.h:52
void PutSeg(const uchar &_Seg)
Definition: blobbs.h:51
Definition: fl.h:347
Definition: fl.h:347
TBlobPt PutBlob(const PSIn &SIn)
Definition: blobbs.cpp:509
TFAccess Access
Definition: blobbs.h:190
TBlobBsV SegV
Definition: blobbs.h:193
#define EAssert(Cond)
Definition: bd.h:280
bool Empty() const
Definition: blobbs.h:49
Definition: blobbs.h:5
Definition: fl.h:347

Here is the call graph for this function:

void TMBlobBs::SaveMain ( ) const
private

Definition at line 441 of file blobbs.cpp.

References GetMainFNm(), GetVersionStr(), TVec< TVal, TSizeTy >::Len(), MxSegLen, TFOut::New(), NrFMid, NrFPath, oloCsSens, oloFrcEoln, oloSigNum, TOLx::PutVarInt(), TOLx::PutVarStr(), and SegV.

Referenced by TMBlobBs(), and ~TMBlobBs().

441  {
444  Lx.PutVarStr("Version", GetVersionStr());
445  Lx.PutVarInt("MxSegLen", MxSegLen);
446  Lx.PutVarInt("Segments", SegV.Len());
447 }
Definition: lx.h:248
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
Definition: bits.h:119
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
Definition: lx.h:251
TStr NrFPath
Definition: blobbs.h:192
TBlobBsV SegV
Definition: blobbs.h:193
static TStr GetMainFNm(const TStr &NrFPath, const TStr &NrFMid)
Definition: blobbs.cpp:423
TStr GetVersionStr() const
Definition: blobbs.h:210
Definition: lx.h:249
TStr NrFMid
Definition: blobbs.h:192
Definition: bd.h:196
Definition: lx.h:248
int MxSegLen
Definition: blobbs.h:191

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

TFAccess TMBlobBs::Access
private

Definition at line 190 of file blobbs.h.

Referenced by PutBlob(), TMBlobBs(), and ~TMBlobBs().

int TMBlobBs::CurSegN
private

Definition at line 194 of file blobbs.h.

Referenced by PutBlob().

int TMBlobBs::MxSegLen
private

Definition at line 191 of file blobbs.h.

Referenced by LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().

TStr TMBlobBs::NrFMid
private

Definition at line 192 of file blobbs.h.

Referenced by Exists(), LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().

TStr TMBlobBs::NrFPath
private

Definition at line 192 of file blobbs.h.

Referenced by Exists(), LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().

TBlobBsV TMBlobBs::SegV
private

The documentation for this class was generated from the following files: