IN [3..13) => {
-- make new doc with a contents
newDID: DID;
doc: Document;
didStuff: LIST OF DIDStuff;
contents: YggRep.TypedPrimitiveElement;
vDoc: YggRep.VDoc;
trans: YggTransaction.TransID;
trans ← GetNextTrans[] ;
[newDID, doc, didStuff] ← GetNextDIDWithEmptyDoc[];
vDoc ← YggRep.VolatizeFromDID[trans, newDID, readWrite, [write, wait]];
contents ← MakeUpTPE[];
didStuff.first.contents ← contents;
vDoc.contents ← contents;
vDoc.contentsChanged ← TRUE;
DoCommit[trans];
IF noisy THEN out.PutF["Make new doc: did= %g\n", IO.card[newDID.didLow] ];
};
IN [8..16) => {
-- volatalize and look up old did
rand: INT;
lokd: LIST OF DIDStuff;
IF NumberOfKnownDIDs <= 0 THEN LOOP;
rand ← Random.ChooseInt[randomStream, 0, MIN[16384, NumberOfKnownDIDs]];
FOR lokd ← KnownDIDs, lokd.rest
UNTIL lokd =
NIL
DO
rand ← rand - 1;
IF rand <= 0 THEN EXIT;
ENDLOOP;
IF lokd = NIL THEN LOOP;
CheckADID[lokd];
IF noisy THEN out.PutF["look up old did: did= %g\n", IO.card[lokd.first.did.didLow] ];
};
IN [16..24) => {
-- add attribute to did
rand: INT;
trans: YggTransaction.TransID;
lokd: LIST OF DIDStuff;
attrName: ROPE;
noAttrVals: INT ;
property: YggRep.Attribute;
fieldTaken: ARRAY [1..5] OF BOOL ← ALL[FALSE];
vDoc: YggRep.VDoc ← NIL;
IF NumberOfKnownDIDs <= 0 THEN LOOP;
rand ← Random.ChooseInt[randomStream, 0, MIN[16384, NumberOfKnownDIDs]];
FOR lokd ← KnownDIDs, lokd.rest UNTIL lokd = NIL DO
rand ← rand - 1;
IF rand <= 0 THEN EXIT;
ENDLOOP;
IF lokd = NIL THEN LOOP;
trans ← GetNextTrans[] ;
vDoc ← YggRep.VolatizeFromDID[transID: trans, did: lokd.first.did,
access: readWrite, lock: [write, wait], metaAttributesOnly: FALSE];
IF ~YggDID.EqualDIDs[vDoc.did, lokd.first.did] THEN ERROR;
IF vDoc.contents.docType # lokd.first.contents.docType THEN ERROR;
FOR tryNo: INT IN [0..7] DO
propExists: BOOL ← FALSE;
rand ← Random.ChooseInt[randomStream, 0, 8];
attrName ← attrNameArray[rand];
FOR aL:
LIST
OF YggRep.Attribute ← vDoc.attributes, aL.rest
UNTIL aL =
NIL
DO
IF Rope.Equal[aL.first.attributeName, attrName]
THEN {
propExists ← TRUE;
EXIT;
};
ENDLOOP;
IF ~propExists THEN EXIT;
attrName ← NIL;
ENDLOOP;
IF attrName = NIL THEN {DoCommit[trans]; LOOP;};
noAttrVals ← Random.ChooseInt[randomStream, 1, 5];
property.value ← NIL;
FOR attrValNo: INT IN [0..noAttrVals) DO
attrVal: YggRep.AttributeValue;
fni: INT;
fni ← noAttrVals ← Random.ChooseInt[randomStream, 1, 5];
IF fieldTaken[fni] THEN LOOP;
fieldTaken[fni] ← TRUE;
attrVal.fieldName ← fieldNameArray[fni];
attrVal.valueSet ← NIL;
FOR tpeNo: INT IN [1..fni] DO
attrVal.valueSet ← CONS[MakeUpTPE[], attrVal.valueSet];
ENDLOOP;
property.value ← CONS[attrVal, property.value];
ENDLOOP;
property.attributeName ← attrName;
vDoc.attributes ← CONS[property, vDoc.attributes];
lokd.first.attributes ← CONS[property, lokd.first.attributes];
vDoc.namesOfAttributesChanged ← LIST[attrName];
DoCommit[trans];
IF noisy THEN out.PutF["add attribute to old did: did= %g\n", IO.card[lokd.first.did.didLow]];
};