Пример #1
0
        unsafe public static void Generate(ref Docid2Long docid2Long,
                                           Data.DBProvider dbProvider, Data.Field[] orderByFields, long score)
        {
            int *p = dbProvider.GetPayloadDataWithShareLock(docid2Long.DocId);

            if (p == null)
            {
                throw new Data.DataException(string.Format("DocId={0} does not exist in Payload",
                                                           docid2Long.DocId));
            }

            for (int i = 0; i < orderByFields.Length; i++)
            {
                Data.Field field = orderByFields[i];

                long value;

                if (field.Name == "score")
                {
                    value = score;
                }
                else if (field.Name == "docid")
                {
                    value = docid2Long.DocId;
                }
                else
                {
                    value = Data.DataTypeConvert.GetLongAnyWay(field.DataType, p,
                                                               field.TabIndex, field.SubTabIndex, field.DataLength);
                }

                switch (i)
                {
                case 0:
                    docid2Long.Value1 = value;
                    break;

                case 1:
                    docid2Long.Value2 = value;
                    break;

                case 2:
                    docid2Long.Value3 = value;
                    break;

                default:
                    throw new Data.DataException("Order by fields length for optimization must be <= 3");
                }
            }
        }