예제 #1
0
 public override RecordGenerators_Generator <PropertyRecord> Property()
 {
     return((recordSize, format, recordId) =>
     {
         PropertyRecord record = new PropertyRecord(recordId);
         int maxProperties = _random.intBetween(1, 4);
         StandaloneDynamicRecordAllocator stringAllocator = new StandaloneDynamicRecordAllocator();
         StandaloneDynamicRecordAllocator arrayAllocator = new StandaloneDynamicRecordAllocator();
         record.InUse = true;
         int blocksOccupied = 0;
         for (int i = 0; i < maxProperties && blocksOccupied < 4;)
         {
             PropertyBlock block = new PropertyBlock();
             // Dynamic records will not be written and read by the property record format,
             // that happens in the store where it delegates to a "sub" store.
             PropertyStore.EncodeValue(block, _random.Next(_tokenBits), _random.nextValue(), stringAllocator, arrayAllocator, true);
             int tentativeBlocksWithThisOne = blocksOccupied + block.ValueBlocks.length;
             if (tentativeBlocksWithThisOne <= 4)
             {
                 record.addPropertyBlock(block);
                 blocksOccupied = tentativeBlocksWithThisOne;
             }
         }
         record.PrevProp = RandomLongOrOccasionallyNull(_propertyBits);
         record.NextProp = RandomLongOrOccasionallyNull(_propertyBits);
         return record;
     });
 }