Beispiel #1
0
        public unsafe void Populate()
        {
            Empty context;

            // Prepare the dataset
            var inputArray = new Input[numOps];

            for (int i = 0; i < numOps; i++)
            {
                inputArray[i].adId.adId           = i % numUniqueKeys;
                inputArray[i].numClicks.numClicks = 1;
            }

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

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

            fixed(Input *input = inputArray)
            {
                for (int i = 0; i < numOps; i++)
                {
                    fht.RMW(&((input + i)->adId), input + i, &context, i);

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

                        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();
        }