SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
blobbs.cpp
Go to the documentation of this file.
1 // Blob-Pointer
3 const int TBlobPt::Flags=24;
4 
5 void TBlobPt::PutFlag(const int& FlagN, const bool& Val){
6  EAssert((0<=FlagN)&&(FlagN<Flags));
7  switch (FlagN/8){
8  case 0: FSet1.SetBit(7-FlagN%8, Val); break;
9  case 1: FSet2.SetBit(7-FlagN%8, Val); break;
10  case 2: FSet3.SetBit(7-FlagN%8, Val); break;
11  default: Fail;
12  }
13 }
14 
15 bool TBlobPt::IsFlag(const int& FlagN) const {
16  EAssert((0<=FlagN)&&(FlagN<Flags));
17  switch (FlagN/8){
18  case 0: return FSet1.GetBit(7-FlagN%8);
19  case 1: return FSet2.GetBit(7-FlagN%8);
20  case 2: return FSet3.GetBit(7-FlagN%8);
21  default: Fail; return false;
22  }
23 }
24 
25 void TBlobPt::PutFSet(const int& FSetN, const TB8Set& FSet){
26  switch (FSetN){
27  case 1: FSet1=FSet; break;
28  case 2: FSet2=FSet; break;
29  case 3: FSet3=FSet; break;
30  default: Fail;
31  }
32 }
33 
34 TB8Set TBlobPt::GetFSet(const int& FSetN){
35  switch (FSetN){
36  case 1: return FSet1;
37  case 2: return FSet2;
38  case 3: return FSet3;
39  default: Fail; return TB8Set();
40  }
41 }
42 
44  TChA ChA;
45  ChA+='[';
46  if (Empty()){
47  ChA+="Null";
48  } else {
49  ChA+=TUInt::GetStr(uint(Seg)); ChA+=':'; ChA+=TUInt::GetStr(Addr);
50  for (int FlagN=0; FlagN<Flags; FlagN++){
51  if (IsFlag(FlagN)){
52  ChA+='{'; ChA+=TInt::GetStr(FlagN); ChA+='}';}
53  }
54  }
55  ChA+=']';
56  return ChA;
57 }
58 
60 // Blob-Base
61 const int TBlobBs::MnBlobBfL=16;
62 const int TBlobBs::MxBlobFLen=1000000000;
63 
64 void TBlobBs::PutVersionStr(const PFRnd& FBlobBs){
65  FBlobBs->PutStr(GetVersionStr());
66 }
67 
68 void TBlobBs::AssertVersionStr(const PFRnd& FBlobBs){
69  TStr CorrVersionStr=GetVersionStr();
70  bool IsOk=false;
71  TStr TestVersionStr=FBlobBs->GetStr(CorrVersionStr.Len(), IsOk);
72  EAssert(IsOk && (CorrVersionStr==TestVersionStr));
73 }
74 
76  TStr StateStr;
77  switch (BlobBsState){
78  case bbsOpened: StateStr="Opened"; break;
79  case bbsClosed: StateStr="Closed"; break;
80  default: Fail; return TStr();
81  }
82  EAssert(StateStr.Len()==GetStateStrLen());
83  return StateStr;
84 }
85 
86 void TBlobBs::PutBlobBsStateStr(const PFRnd& FBlobBs, const TBlobBsState& State){
87  FBlobBs->PutStr(GetBlobBsStateStr(State));
88 }
89 
91  const PFRnd& FBlobBs, const TBlobBsState& State){
92  TStr CorrStateStr=GetBlobBsStateStr(State);
93  bool IsOk;
94  TStr TestStateStr=FBlobBs->GetStr(GetStateStrLen(), IsOk);
95  if (!(IsOk && (CorrStateStr==TestStateStr))) {
96  TExcept::ThrowFull("Error in AssertBlobBsStateStr!", TStr(__FILE__)+" line "+TInt::GetStr(__LINE__));
97  }
98 }
99 
100 const TStr TBlobBs::MxSegLenVNm="MxSegLen";
101 
102 void TBlobBs::PutMxSegLen(const PFRnd& FBlobBs, const int& MxSegLen){
103  FBlobBs->PutStr(MxSegLenVNm);
104  FBlobBs->PutInt(MxSegLen);
105 }
106 
107 int TBlobBs::GetMxSegLen(const PFRnd& FBlobBs){
108  EAssert(FBlobBs->GetStr(MxSegLenVNm.Len())==MxSegLenVNm);
109  return FBlobBs->GetInt();
110 }
111 
112 const TStr TBlobBs::BlockLenVNm="BlockLenV";
113 
114 void TBlobBs::GenBlockLenV(TIntV& BlockLenV){
115  BlockLenV.Clr();
116  for (int P2Exp=0; P2Exp<TB4Def::MxP2Exp; P2Exp++){
117  BlockLenV.Add(TInt(TB4Def::GetP2(P2Exp)));}
118  EAssert(int(BlockLenV.Last())<2000000000);
119 
120  {for (int Len=10; Len<100; Len+=10){BlockLenV.Add(Len);}}
121  {for (int Len=100; Len<10000; Len+=100){BlockLenV.Add(Len);}}
122  {for (int Len=10000; Len<100000; Len+=1000){BlockLenV.Add(Len);}}
123  {for (int Len=100000; Len<1000000; Len+=25000){BlockLenV.Add(Len);}}
124  {for (int Len=1000000; Len<10000000; Len+=1000000){BlockLenV.Add(Len);}}
125  {for (int Len=10000000; Len<100000000; Len+=10000000){BlockLenV.Add(Len);}}
126 
127  BlockLenV.Sort();
128 }
129 
130 void TBlobBs::PutBlockLenV(const PFRnd& FBlobBs, const TIntV& BlockLenV){
131  FBlobBs->PutStr(BlockLenVNm);
132  FBlobBs->PutInt(BlockLenV.Len());
133  for (int BlockLenN=0; BlockLenN<BlockLenV.Len(); BlockLenN++){
134  FBlobBs->PutInt(BlockLenV[BlockLenN]);}
135  FBlobBs->PutInt(-1);
136 }
137 
138 void TBlobBs::GetBlockLenV(const PFRnd& FBlobBs, TIntV& BlockLenV){
139  EAssert(FBlobBs->GetStr(BlockLenVNm.Len())==BlockLenVNm);
140  BlockLenV.Gen(FBlobBs->GetInt());
141  for (int BlockLenN=0; BlockLenN<BlockLenV.Len(); BlockLenN++){
142  BlockLenV[BlockLenN]=FBlobBs->GetInt();}
143  EAssert(FBlobBs->GetInt()==-1);
144 }
145 
146 const TStr TBlobBs::FFreeBlobPtVNm="FFreeBlobPtV";
147 
148 void TBlobBs::GenFFreeBlobPtV(const TIntV& BlockLenV, TBlobPtV& FFreeBlobPtV){
149  FFreeBlobPtV.Gen(BlockLenV.Len()+1);
150 }
151 
152 void TBlobBs::PutFFreeBlobPtV(const PFRnd& FBlobBs, const TBlobPtV& FFreeBlobPtV){
153  FBlobBs->PutStr(FFreeBlobPtVNm);
154  FBlobBs->PutInt(FFreeBlobPtV.Len());
155  for (int BlockLenN=0; BlockLenN<FFreeBlobPtV.Len(); BlockLenN++){
156  FFreeBlobPtV[BlockLenN].Save(FBlobBs);}
157  FBlobBs->PutInt(-1);
158 }
159 
160 void TBlobBs::GetFFreeBlobPtV(const PFRnd& FBlobBs, TBlobPtV& FFreeBlobPtV){
162  FFreeBlobPtV.Gen(FBlobBs->GetInt());
163  for (int FFreeBlobPtN=0; FFreeBlobPtN<FFreeBlobPtV.Len(); FFreeBlobPtN++){
164  FFreeBlobPtV[FFreeBlobPtN]=TBlobPt::Load(FBlobBs);}
165  EAssert(FBlobBs->GetInt()==-1);
166 }
167 
169  const int& BfL, const TIntV& BlockLenV, int& MxBfL, int& FFreeBlobPtN){
170  int BlockLenN=0;
171  while ((BlockLenN<BlockLenV.Len())&&(BfL>BlockLenV[BlockLenN])){
172  BlockLenN++;}
173  EAssert(BlockLenN<BlockLenV.Len());
174  MxBfL=BlockLenV[BlockLenN]; FFreeBlobPtN=BlockLenN;
175 }
176 
177 void TBlobBs::PutBlobTag(const PFRnd& FBlobBs, const TBlobTag& BlobTag){
178  switch (BlobTag){
179  case btBegin: FBlobBs->PutUInt(GetBeginBlobTag()); break;
180  case btEnd: FBlobBs->PutUInt(GetEndBlobTag()); break;
181  default: Fail;
182  }
183 }
184 
185 void TBlobBs::AssertBlobTag(const PFRnd& FBlobBs, const TBlobTag& BlobTag){
186  switch (BlobTag){
187  case btBegin: EAssert(FBlobBs->GetUInt()==GetBeginBlobTag()); break;
188  case btEnd: EAssert(FBlobBs->GetUInt()==GetEndBlobTag()); break;
189  default: TExcept::Throw("Error asserting BlobTag");
190  }
191 }
192 
193 void TBlobBs::PutBlobState(const PFRnd& FBlobBs, const TBlobState& State){
194  FBlobBs->PutCh(char(State));
195 }
196 
198  return TBlobState(int(FBlobBs->GetCh()));
199 }
200 
201 void TBlobBs::AssertBlobState(const PFRnd& FBlobBs, const TBlobState& State){
202  EAssert(TBlobState(FBlobBs->GetCh())==State);
203 }
204 
205 void TBlobBs::AssertBfCsEqFlCs(const TCs& BfCs, const TCs& FCs){
206  if (BfCs!=FCs){
207  printf("[%d:%d]\n", BfCs.Get(), FCs.Get());}
208  //EAssert(BfCs==FCs);
209 }
210 
212 // General-Blob-Base
214  TStr NrBlobBsFNm=BlobBsFNm;
215  if (NrBlobBsFNm.GetFExt().Empty()){
216  NrBlobBsFNm=NrBlobBsFNm+".gbb";}
217  return NrBlobBsFNm;
218 }
219 
221  const TStr& BlobBsFNm, const TFAccess& _Access, const int& _MxSegLen):
222  TBlobBs(), FBlobBs(), Access(_Access), MxSegLen(_MxSegLen),
223  BlockLenV(), FFreeBlobPtV(TB4Def::B4Bits), FirstBlobPt(){
224  if (MxSegLen==-1){MxSegLen=MxBlobFLen;}
225  TStr NrBlobBsFNm=GetNrBlobBsFNm(BlobBsFNm);
226  switch (Access){
227  case faCreate:
228  FBlobBs=TFRnd::New(NrBlobBsFNm, faCreate, true); break;
229  case faUpdate:
230  case faRdOnly:
231  case faRestore:
232  FBlobBs=TFRnd::New(NrBlobBsFNm, faUpdate, true); break;
233  default: Fail;
234  }
235  if (FBlobBs->Empty()){
236  FBlobBs->SetFPos(0);
244  } else {
245  FBlobBs->SetFPos(0);
247  int FPos=FBlobBs->GetFPos();
248  if (Access!=faRestore){
250  if (Access!=faRdOnly){
251  FBlobBs->SetFPos(FPos);
253  }
257  }
259  FBlobBs->Flush();
260 }
261 
263  if (Access!=faRdOnly){
264  FBlobBs->SetFPos(0);
270  }
271  FBlobBs->Flush();
272  FBlobBs=NULL;
273 }
274 
277  int BfL=SIn->Len();
278  int MxBfL; int FFreeBlobPtN;
279  GetAllocInfo(BfL, BlockLenV, MxBfL, FFreeBlobPtN);
280  TBlobPt BlobPt; TCs Cs;
281  if (FFreeBlobPtV[FFreeBlobPtN].Empty()){
282  int FLen=FBlobBs->GetFLen();
283  if (FLen<=MxSegLen){
284  EAssert(FLen<=MxBlobFLen);
285  BlobPt=TBlobPt(FLen);
286  FBlobBs->SetFPos(BlobPt.GetAddr());
288  FBlobBs->PutInt(MxBfL);
290  FBlobBs->PutInt(BfL);
291  FBlobBs->PutSIn(SIn, Cs);
292  FBlobBs->PutCh(TCh::NullCh, MxBfL-BfL);
293  FBlobBs->PutCs(Cs);
295  }
296  } else {
297  BlobPt=FFreeBlobPtV[FFreeBlobPtN];
298  FBlobBs->SetFPos(BlobPt.GetAddr());
300  int MxBfL=FBlobBs->GetInt();
301  int FPos=FBlobBs->GetFPos();
303  FFreeBlobPtV[FFreeBlobPtN]=TBlobPt::LoadAddr(FBlobBs);
304  FBlobBs->SetFPos(FPos);
306  FBlobBs->PutInt(BfL);
307  FBlobBs->PutSIn(SIn, Cs);
308  FBlobBs->PutCh(TCh::NullCh, MxBfL-BfL);
309  FBlobBs->PutCs(Cs);
311  }
312  FBlobBs->Flush();
313  return BlobPt;
314 }
315 
316 TBlobPt TGBlobBs::PutBlob(const TBlobPt& BlobPt, const PSIn& SIn){
318  int BfL=SIn->Len();
319 
320  FBlobBs->SetFPos(BlobPt.GetAddr());
322  int MxBfL=FBlobBs->GetInt();
324  if (BfL>MxBfL){
325  DelBlob(BlobPt);
326  return PutBlob(SIn);
327  } else {
328  TCs Cs;
329  FBlobBs->PutInt(BfL);
330  FBlobBs->PutSIn(SIn, Cs);
331  FBlobBs->PutCh(TCh::NullCh, MxBfL-BfL);
332  FBlobBs->PutCs(Cs);
334  FBlobBs->Flush();
335  return BlobPt;
336  }
337 }
338 
340  FBlobBs->SetFPos(BlobPt.GetAddr());
342  int MxBfL=FBlobBs->GetInt();
344  int BfL=FBlobBs->GetInt();
345  TCs BfCs; PSIn SIn=FBlobBs->GetSIn(BfL, BfCs);
346  FBlobBs->MoveFPos(MxBfL-BfL);
347  TCs FCs=FBlobBs->GetCs();
349  AssertBfCsEqFlCs(BfCs, FCs);
350  return SIn;
351 }
352 
353 void TGBlobBs::DelBlob(const TBlobPt& BlobPt){
355  FBlobBs->SetFPos(BlobPt.GetAddr());
357  int MxBfL=FBlobBs->GetInt();
358  int FPos=FBlobBs->GetFPos();
360  /*int BfL=*/FBlobBs->GetInt();
361  FBlobBs->SetFPos(FPos);
363  int _MxBfL; int FFreeBlobPtN;
364  GetAllocInfo(MxBfL, BlockLenV, _MxBfL, FFreeBlobPtN);
365  EAssert(MxBfL==_MxBfL);
366  FFreeBlobPtV[FFreeBlobPtN].SaveAddr(FBlobBs);
367  FFreeBlobPtV[FFreeBlobPtN]=BlobPt;
368  FBlobBs->PutCh(TCh::NullCh, MxBfL+sizeof(TCs));
370  FBlobBs->Flush();
371 }
372 
374  return FirstBlobPt;
375 }
376 
377 bool TGBlobBs::FNextBlobPt(TBlobPt& TrvBlobPt, TBlobPt& BlobPt, PSIn& BlobSIn){
378  forever {
379  uint TrvBlobAddr=TrvBlobPt.GetAddr();
380  if (TrvBlobAddr>=uint(FBlobBs->GetFLen())){
381  TrvBlobPt.Clr(); BlobPt.Clr(); BlobSIn=NULL;
382  return false;
383  } else {
384  FBlobBs->SetFPos(TrvBlobAddr);
386  int MxBfL=FBlobBs->GetInt();
387  TBlobState BlobState=GetBlobState(FBlobBs);
388  switch (BlobState){
389  case bsActive:{
390  int BfL=FBlobBs->GetInt();
391  TCs BfCs; BlobSIn=FBlobBs->GetSIn(BfL, BfCs);
392  FBlobBs->MoveFPos(MxBfL-BfL);
393  TCs FCs=FBlobBs->GetCs();
395  AssertBfCsEqFlCs(BfCs, FCs);
396  BlobPt=TrvBlobPt;
397  TrvBlobPt=TBlobPt(FBlobBs->GetFPos());
398  return true;}
399  case bsFree:
400  FBlobBs->MoveFPos(sizeof(uint)+MxBfL+sizeof(TCs));
402  TrvBlobPt=TBlobPt(FBlobBs->GetFPos());
403  break;
404  default: Fail; return false;
405  }
406  }
407  }
408 }
409 
410 bool TGBlobBs::Exists(const TStr& BlobBsFNm){
411  TStr NrBlobBsFNm=GetNrBlobBsFNm(BlobBsFNm);
412  return TFile::Exists(NrBlobBsFNm);
413 }
414 
416 // Multiple-File-Blob-Base
418  const TStr& BlobBsFNm, TStr& NrFPath, TStr& NrFMid){
419  NrFPath=TStr::GetNrFPath(BlobBsFNm.GetFPath());
420  NrFMid=TStr::GetNrFMid(BlobBsFNm.GetFMid());
421 }
422 
424  const TStr& NrFPath, const TStr& NrFMid){
425  return NrFPath+NrFMid+".mbb";
426 }
427 
429  const TStr& NrFPath, const TStr& NrFMid, const int& SegN){
430  return NrFPath+NrFMid+".mbb"+""+TStr::GetNrNumFExt(SegN);
431 }
432 
433 void TMBlobBs::LoadMain(int& Segs){
436  EAssert(Lx.GetVarStr("Version")==GetVersionStr());
437  MxSegLen=Lx.GetVarInt("MxSegLen");
438  Segs=Lx.GetVarInt("Segments");
439 }
440 
441 void TMBlobBs::SaveMain() const {
444  Lx.PutVarStr("Version", GetVersionStr());
445  Lx.PutVarInt("MxSegLen", MxSegLen);
446  Lx.PutVarInt("Segments", SegV.Len());
447 }
448 
450  const TStr& BlobBsFNm, const TFAccess& _Access, const int& _MxSegLen):
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 }
502 
504  if (Access!=faRdOnly){
505  SaveMain();
506  }
507 }
508 
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 }
528 
529 TBlobPt TMBlobBs::PutBlob(const TBlobPt& BlobPt, const PSIn& SIn){
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 }
540 
542  int SegN=BlobPt.GetSeg();
543  return SegV[SegN]->GetBlob(BlobPt);
544 }
545 
546 void TMBlobBs::DelBlob(const TBlobPt& BlobPt){
547  int SegN=BlobPt.GetSeg();
548  SegV[SegN]->DelBlob(BlobPt);
549 }
550 
552  return SegV[0]->GetFirstBlobPt();
553 }
554 
556  return SegV[0]->FFirstBlobPt();
557 }
558 
559 bool TMBlobBs::FNextBlobPt(TBlobPt& TrvBlobPt, TBlobPt& BlobPt, PSIn& BlobSIn){
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 }
575 
576 bool TMBlobBs::Exists(const TStr& BlobBsFNm){
577  TStr NrFPath; TStr NrFMid; GetNrFPathFMid(BlobBsFNm, NrFPath, NrFMid);
578  TStr MainFNm=GetMainFNm(NrFPath, NrFMid);
579  return TFile::Exists(MainFNm);
580 }
void DelBlob(const TBlobPt &BlobPt)
Definition: blobbs.cpp:546
TGBlobBs(const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1)
Definition: blobbs.cpp:220
void DelBlob(const TBlobPt &BlobPt)
Definition: blobbs.cpp:353
TFAccess Access
Definition: blobbs.h:157
Definition: lx.h:248
TStr GetStr(const int &StrLen)
Definition: fl.cpp:879
static PFRnd New(const TStr &FNm, const TFAccess &FAccess, const bool &CreateIfNo=true, const int &HdLen=-1, const int &RecLen=-1)
Definition: fl.h:505
uchar Seg
Definition: blobbs.h:9
void Clr()
Definition: blobbs.h:50
void GenFFreeBlobPtV(const TIntV &BlockLenV, TBlobPtV &FFreeBlobPtV)
Definition: blobbs.cpp:148
TStr GetStr() const
Definition: dt.h:1105
void AssertVersionStr(const PFRnd &FBlobBs)
Definition: blobbs.cpp:68
TB8Set FSet3
Definition: blobbs.h:11
Definition: bits.h:166
TBlobPt FFirstBlobPt()
Definition: blobbs.cpp:555
static void GetNrFPathFMid(const TStr &BlobBsFNm, TStr &NrFPath, TStr &NrFMid)
Definition: blobbs.cpp:417
static TBlobPt Load(const PFRnd &FRnd)
Definition: blobbs.h:62
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
int Len() const
Definition: dt.h:487
uint GetBeginBlobTag()
Definition: blobbs.h:127
TStr GetFMid() const
Definition: dt.cpp:1403
uchar GetSeg() const
Definition: blobbs.h:52
void PutSeg(const uchar &_Seg)
Definition: blobbs.h:51
Definition: fl.h:347
void SaveMain() const
Definition: blobbs.cpp:441
void PutBlobTag(const PFRnd &FBlobBs, const TBlobTag &BlobTag)
Definition: blobbs.cpp:177
Definition: blobbs.h:86
TB8Set GetFSet(const int &FSetN)
Definition: blobbs.cpp:34
static bool Exists(const TStr &FNm)
Definition: fl.cpp:941
void PutBlobState(const PFRnd &FBlobBs, const TBlobState &State)
Definition: blobbs.cpp:193
TStr GetFPath() const
Definition: dt.cpp:1389
void SetBit(const int &BitN, const bool &Bool)
Definition: bits.h:199
void GetFFreeBlobPtV(const PFRnd &FBlobBs, TBlobPtV &FFreeBlobPtV)
Definition: blobbs.cpp:160
#define forever
Definition: bd.h:6
Definition: blobbs.h:86
static TStr GetSegFNm(const TStr &NrFPath, const TStr &NrFMid, const int &SegN)
Definition: blobbs.cpp:428
unsigned int uint
Definition: bd.h:11
void Flush()
Definition: fl.cpp:851
int GetStateStrLen()
Definition: blobbs.h:106
#define Fail
Definition: bd.h:238
void PutInt(const int &Int)
Definition: fl.h:546
bool FNextBlobPt(TBlobPt &TrvBlobPt, TBlobPt &BlobPt, PSIn &BlobSIn)
Definition: blobbs.cpp:377
int GetFLen()
Definition: fl.cpp:810
static const char NullCh
Definition: dt.h:943
TStr GetVarStr(const TStr &VarNm, const bool &NewLn=true)
Definition: lx.h:228
Definition: bits.h:119
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
static bool Exists(const TStr &BlobBsFNm)
Definition: blobbs.cpp:410
TBlobTag
Definition: blobbs.h:86
void PutVersionStr(const PFRnd &FBlobBs)
Definition: blobbs.cpp:64
void AssertBlobBsStateStr(const PFRnd &FBlobBs, const TBlobBsState &State)
Definition: blobbs.cpp:90
TBlobState GetBlobState(const PFRnd &FBlobBs)
Definition: blobbs.cpp:197
void PutSIn(const PSIn &SIn, TCs &Cs)
Definition: fl.cpp:889
static TStr GetNrFMid(const TStr &FMid)
Definition: dt.cpp:1445
Definition: fl.h:347
static const int MxP2Exp
Definition: bits.h:55
int Get() const
Definition: fl.h:25
TBlobBsState
Definition: blobbs.h:85
TStr GetFExt() const
Definition: dt.cpp:1421
uint Addr
Definition: blobbs.h:10
Definition: blobbs.h:89
void LoadMain(int &Segs)
Definition: blobbs.cpp:433
void PutUInt(const uint &UInt)
Definition: fl.h:548
void GetAllocInfo(const int &BfL, const TIntV &BlockLenV, int &MxBfL, int &FFreeBlobPtN)
Definition: blobbs.cpp:168
uint GetEndBlobTag()
Definition: blobbs.h:128
bool IsFlag(const int &FlagN) const
Definition: blobbs.cpp:15
void PutMxSegLen(const PFRnd &FBlobBs, const int &MxSegLen)
Definition: blobbs.cpp:102
int GetVarInt(const TStr &VarNm, const bool &NewLn=true)
Definition: lx.h:222
void AssertBfCsEqFlCs(const TCs &BfCs, const TCs &FCs)
Definition: blobbs.cpp:205
void PutFlag(const int &FlagN, const bool &Val)
Definition: blobbs.cpp:5
TBlobState
Definition: blobbs.h:87
void Save(TSOut &SOut) const
Definition: ds.h:885
void PutFSet(const int &FSetN, const TB8Set &FSet)
Definition: blobbs.cpp:25
char GetCh()
Definition: fl.h:543
void PutCs(const TCs &Cs)
Definition: fl.h:539
void AssertBlobTag(const PFRnd &FBlobBs, const TBlobTag &BlobTag)
Definition: blobbs.cpp:185
int MxSegLen
Definition: blobbs.h:158
static PSIn New(const TStr &FNm)
Definition: fl.cpp:290
void PutFFreeBlobPtV(const PFRnd &FBlobBs, const TBlobPtV &FFreeBlobPtV)
Definition: blobbs.cpp:152
TBlobPt FirstBlobPt
Definition: blobbs.h:161
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:953
~TGBlobBs()
Definition: blobbs.cpp:262
static void DelWc(const TStr &WcStr, const bool &RecurseDirP=false)
Definition: fl.cpp:1049
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1218
static TStr GetNrBlobBsFNm(const TStr &BlobBsFNm)
Definition: blobbs.cpp:213
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
Definition: fl.h:347
uint GetAddr() const
Definition: blobbs.h:54
void MoveFPos(const int &DFPos)
Definition: fl.cpp:798
PFRnd FBlobBs
Definition: blobbs.h:156
void GenBlockLenV(TIntV &BlockLenV)
Definition: blobbs.cpp:114
void GetBlockLenV(const PFRnd &FBlobBs, TIntV &BlockLenV)
Definition: blobbs.cpp:138
TIntV BlockLenV
Definition: blobbs.h:159
TBlobPt PutBlob(const PSIn &SIn)
Definition: blobbs.cpp:509
Definition: lx.h:129
TStr GetStr() const
Definition: dt.h:1187
Definition: lx.h:251
static const TStr MxSegLenVNm
Definition: blobbs.h:110
PSIn GetBlob(const TBlobPt &BlobPt)
Definition: blobbs.cpp:541
const TVal & Last() const
Returns a reference to the last element of the vector.
Definition: ds.h:539
PSIn GetBlob(const TBlobPt &BlobPt)
Definition: blobbs.cpp:339
void SetFPos(const int &FPos)
Definition: fl.cpp:792
static PBlobBs New(const TStr &BlobBsFNm, const TFAccess &Access=faRdOnly, const int &MxSegLen=-1)
Definition: blobbs.h:166
static void ThrowFull(const TStr &MsgStr, const TStr &LocStr)
Definition: ut.h:198
static TStr GetNrFPath(const TStr &FPath)
Definition: dt.cpp:1430
TFAccess Access
Definition: blobbs.h:190
int GetInt()
Definition: fl.h:547
void PutBlobBsStateStr(const PFRnd &FBlobBs, const TBlobBsState &State)
Definition: blobbs.cpp:86
TBlobPt GetFirstBlobPt()
Definition: blobbs.cpp:551
unsigned char uchar
Definition: bd.h:10
void PutCh(const char &Ch)
Definition: fl.h:541
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
TCs GetCs()
Definition: fl.h:540
int CurSegN
Definition: blobbs.h:194
void PutStr(const TStr &Str)
Definition: fl.cpp:864
Definition: dt.h:1042
TB8Set FSet2
Definition: blobbs.h:11
bool FNextBlobPt(TBlobPt &TrvBlobPt, TBlobPt &BlobPt, PSIn &BlobSIn)
Definition: blobbs.cpp:559
Definition: dt.h:201
static const TStr BlockLenVNm
Definition: blobbs.h:114
#define EAssert(Cond)
Definition: bd.h:280
bool GetBit(const int &BitN) const
Definition: bits.h:201
bool Empty() const
Definition: blobbs.h:49
virtual TStr GetVersionStr() const =0
TBlobPt PutBlob(const PSIn &SIn)
Definition: blobbs.cpp:275
void PutBlockLenV(const PFRnd &FBlobBs, const TIntV &BlockLenV)
Definition: blobbs.cpp:130
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
Definition: blobbs.h:5
Definition: bits.h:51
Definition: lx.h:249
PSIn GetSIn(const int &SInLen, TCs &Cs)
Definition: fl.cpp:898
static TStr GetNrNumFExt(const int &FExtN)
Definition: dt.cpp:1460
static const int MnBlobBfL
Definition: blobbs.h:91
TStr NrFMid
Definition: blobbs.h:192
static bool Exists(const TStr &BlobBsFNm)
Definition: blobbs.cpp:576
void AssertBlobState(const PFRnd &FBlobBs, const TBlobState &State)
Definition: blobbs.cpp:201
Definition: lx.h:248
~TMBlobBs()
Definition: blobbs.cpp:503
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
void PutVarInt(const TStr &VarNm, const int &Int, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.h:324
int MxSegLen
Definition: blobbs.h:191
void PutVarStr(const TStr &VarNm, const TStr &Str, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.h:334
int GetFPos()
Definition: fl.cpp:804
TBlobPt FFirstBlobPt()
Definition: blobbs.cpp:373
static const int Flags
Definition: blobbs.h:8
int GetMxSegLen(const PFRnd &FBlobBs)
Definition: blobbs.cpp:107
static TBlobPt LoadAddr(const PFRnd &FRnd, const uchar &Seg=0)
Definition: blobbs.h:71
virtual int Len() const =0
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:559
Definition: blobbs.h:87
Definition: fl.h:11
static uint GetP2(const int &P2Exp)
Definition: bits.cpp:91
TStr GetStr() const
Definition: blobbs.cpp:43
TFAccess
Definition: fl.h:347
Definition: fl.h:347
uint GetUInt()
Definition: fl.h:549
static const TStr FFreeBlobPtVNm
Definition: blobbs.h:119
TStr GetBlobBsStateStr(const TBlobBsState &BlobBsState)
Definition: blobbs.cpp:75
TMBlobBs(const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1)
Definition: blobbs.cpp:449
bool Empty()
Definition: fl.h:519
TB8Set FSet1
Definition: blobbs.h:11
TBlobPtV FFreeBlobPtV
Definition: blobbs.h:160