Esempio n. 1
0
        unsafe private void TestFillPayloadRank(string tableName)
        {
            OutputMessage("TestGetDocIdReplaceFieldValue");

            AddColumn("Times");
            AddColumn("Elapse(ms)");
            AddColumn("ElapseOneTime(ms)");

            Data.DBProvider dbProvider = Data.DBProvider.GetDBProvider(Parameters[0], false);

            if (dbProvider == null)
            {
                throw new DataException(string.Format("Table name {0} does not exist!", Parameters[0]));
            }

            Random rand      = new Random();
            int    count     = 1000000;
            int    lastDocId = dbProvider.LastDocId;

            OriginalDocumentPositionList[] payloads = new OriginalDocumentPositionList[count];

            for (int i = 0; i < payloads.Length; i++)
            {
                payloads[i] = new OriginalDocumentPositionList(i * 10);
                payloads[i].CountAndWordCount = 1;
            }

            payloads[0].DocumentId = 8 * payloads.Length;

            Data.Field rankField = dbProvider.GetField("Rank");
            int        tab       = rankField.TabIndex;

            Stopwatch sw = new Stopwatch();

            //int docid = rand.Next(lastDocId);
            sw.Start();

            for (int j = 0; j < count / payloads.Length; j++)
            {
                dbProvider.FillPayloadRank(tab, count, payloads);
            }
            sw.Stop();

            OutputValue("Times", count);
            OutputValue("Elapse(ms)", sw.ElapsedMilliseconds);
            OutputValue("ElapseOneTime(ms)", (double)sw.ElapsedMilliseconds / count);
        }