private void ChangeRandomNode(GraphDatabaseService db, int nodeCount, RandomValues random)
 {
     try
     {
         using (Transaction tx = Db.beginTx())
         {
             long     nodeId = random.Next(nodeCount);
             Node     node   = Db.getNodeById(nodeId);
             object[] keys   = Iterables.asCollection(node.PropertyKeys).ToArray();
             string   key    = ( string )random.Among(keys);
             if (random.NextFloat() < 0.1)
             {                             // REMOVE
                 node.RemoveProperty(key);
             }
             else
             {                             // CHANGE
                 node.SetProperty(key, random.NextValue().asObject());
             }
             tx.Success();
         }
     }
     catch (NotFoundException)
     {               // It's OK, it happens if some other thread deleted that property in between us reading it and
         // removing or setting it
     }
 }
Beispiel #2
0
        public virtual T Random(RandomValues random)
        {
            float value      = random.NextFloat();
            float comparison = 0.5f;

            foreach (T item in _items)
            {
                if (value >= comparison)
                {
                    return(item);
                }
                comparison /= 2f;
            }
            return(_items[_items.Length - 1]);
        }
 internal override object Miss(RandomValues random, object id, float chance)
 {
     return(random.NextFloat() < chance ? "_" + id : id);
 }
 internal override object Miss(RandomValues random, object id, float chance)
 {
     return(random.NextFloat() < chance ? (long?)id + 100_000_000 : id);
 }