Archive

Archive element used in the DART Recorder

Members

Functions

isAdd
bool isAdd()

Checks if the archive is an add-type

isRecord
bool isRecord()

Check if the filed archive is of type T

isRemove
bool isRemove(GetType get_type)

Checks the translate function get_type result in a remove-type

isRemove
bool isRemove()

Checks if the archive type is a remove-type

isStub
bool isStub()

Check if archive is a stub

store
const(Document) store()

Generates Document to be store in the BlockFile

toDoc
const(Document) toDoc()

Convert archive to a Document

Variables

filed
Document filed;

The actual data strute stored

fingerprint
const(Fingerprint) fingerprint;

Stub hash-pointer used in sharding

type
const(Type) type;

Acrhive type

Examples

// Archive
   //    import std.stdio;
   import std.format;
   import std.string : representation;
   import tagion.dart.DARTFakeNet;
   import tagion.hibon.HiBONJSON;

   auto net = new DARTFakeNet;
   auto manufactor = RecordFactory(net);

   static assert(isHiBONRecord!Archive);
   Document filed_doc; // This is the data which is filed in the DART
   {
       auto hibon = new HiBON;
       hibon["#text"] = "Some text";
       filed_doc = Document(hibon);
   }
   immutable filed_doc_fingerprint = net.calcHash(filed_doc);
   immutable filed_doc_dart_index = net.dartIndex(filed_doc);

   Archive a;
   { // Simple archive
       a = new Archive(net, filed_doc);
       assert(a.fingerprint == filed_doc_fingerprint);
       assert(a.dart_index == filed_doc_dart_index);
       assert(a.filed == filed_doc);
       assert(a.type is Archive.Type.NONE);

       const archived_doc = a.toDoc;
       assert(archived_doc[Archive.archiveLabel].get!Document == filed_doc);
       const result_a = new Archive(net, archived_doc);
       assert(result_a.fingerprint == a.fingerprint);
       assert(a.dart_index == filed_doc_dart_index);
       assert(result_a.filed == a.filed);
       assert(result_a.type == a.type);
       assert(result_a.store == filed_doc);

   }

   a.changeType(Archive.Type.ADD);
   { // Simple archive with ADD/REMOVE Type
       // a=new Archive(net, filed_doc);
       assert(a.fingerprint == filed_doc_fingerprint);
       const archived_doc = a.toDoc;

       { // Same type
           const result_a = new Archive(net, archived_doc);
           assert(result_a.fingerprint == a.fingerprint);
           assert(result_a.filed == a.filed);
           assert(result_a.type == a.type);
           assert(result_a.store == filed_doc);
       }

   }