Types for Simulated LoganBerry DB
LBAttributeType: TYPE = ATOM;
LBAttributeValue: TYPE = ROPE;
LBAttribute:
TYPE =
RECORD[
type: LBAttributeType,
value: LBAttributeValue
];
LBEntry: TYPE = LIST OF LBAttribute;
LBLog: TYPE = LIST OF LBEntry;
Operations
OffLineAndKeep: AlgebraClasses.UnaryOp;
Input is an OnlineObject, output is an OffLineObject. Check whether already OffLine by seeing if primaryKey field is nonNIL. If not, then generate appropriate data, and store in LB DB, and make an entry for it in global registry of offline objects which are currently online (i.e. leave it Online).
OffLineAndFree: AlgebraClasses.UnaryOp;
Input is an OnlineObject, output is an OffLineObject. Check whether already OffLine by seeing if primaryKey field is nonNIL. If not, then generate appropriate data, and store in LB DB. Do not make an entry for it in global registry of offline objects which are currently online, so when no other pointers to it remain it will be collected.
OnlineASObject:
PROC [in: AlgebraClasses.Object, tryToLink:
BOOL ←
FALSE, reUse: OnLineObject ←
NIL]
RETURNS [out: AlgebraClasses.Object];
Checks OnlineASObjects to see if already online; if so, return it and exit. If not, load it and make an entry for it in global registry of offline objects which are currently online.
If tryToLink = TRUE, then for each field which contains one or more (necessarily offline) AS objects, look for those objects in OnlineASObjects, and if found, put pointers to their online versions in the output object. If tryToLink = FALSE, then all such fields are left containing offline objects.
Note that this only unwinds (i.e. onlines) pointers to offline Objects to one level, i.e. conceivably we could unwind such pointers until every Object accessible from the output object was online.
If reUse#NIL, then we can avoid an Alloc. First check for presence of that object in global registry; if so, delete it. It is users responsibility to guarantee correctness of a reUse#NIL call.
ObjectName: AlgebraClasses.UnaryOp;
Selector. RETURN[OnlineASObject[arg].name];
ObjectFlavor: AlgebraClasses.UnaryOp;
Selector. RETURN[OnlineASObject[arg].flavor];
ObjectClass: AlgebraClasses.UnaryOp;
Selector. RETURN[OnlineASObject[arg].class];
ObjectData: AlgebraClasses.UnaryOp;
Selector. RETURN[OnlineASObject[arg].data];
BinaryOp: AlgebraClasses.BinaryOp;