示例#1
0
        public void ObjectInMemWriteRead2()
        {
            var key1 = new MyKey {
                key = 8999998
            };
            var input1 = new MyInput {
                value = 23
            };

            fht.RMW(key1, input1, null, 0);

            var key2 = new MyKey {
                key = 8999999
            };
            var input2 = new MyInput {
                value = 24
            };

            fht.RMW(key2, input2, null, 0);

            MyOutput output = new MyOutput();

            fht.Read(key1, null, ref output, null, 0);

            Assert.IsTrue(output.value.value == input1.value);

            fht.Read(key2, null, ref output, null, 0);
            Assert.IsTrue(output.value.value == input2.value);
        }
示例#2
0
        public unsafe void Populate()
        {
            // Prepare the dataset
            var inputArray = new Tuple <AdId, Input> [numOps];

            for (int i = 0; i < numOps; i++)
            {
                inputArray[i] = new Tuple <AdId, Input>
                                    (new AdId {
                    adId = i % numUniqueKeys
                }, new Input {
                    numClicks = 1
                });
            }

            // Register thread with FASTER
            fht.StartSession();

            // Prpcess the batch of input data
            bool first = true;

            for (int i = 0; i < numOps; i++)
            {
                fht.RMW(inputArray[i].Item1, inputArray[i].Item2, default(Empty), i);

                if ((i + 1) % checkpointInterval == 0)
                {
                    if (first)
                    {
                        while (!fht.TakeFullCheckpoint(out token))
                        {
                            fht.Refresh();
                        }
                    }
                    else
                    {
                        while (!fht.TakeFullCheckpoint(out Guid nextToken))
                        {
                            fht.Refresh();
                        }
                    }

                    fht.CompleteCheckpoint(true);

                    first = false;
                }

                if (i % completePendingInterval == 0)
                {
                    fht.CompletePending(false);
                }
                else if (i % refreshInterval == 0)
                {
                    fht.Refresh();
                }
            }


            // Make sure operations are completed
            fht.CompletePending(true);

            // Deregister thread from FASTER
            fht.StopSession();
        }