Example #1
0
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="parser"></param>
        private unsafe void update(ref OperationParameter.NodeParser parser)
        {
            int index = parser.GetValueData(-1);

            if ((uint)index < count)
            {
                byte *read = parser.Read;
                if (parser.LoadValueData() && !parser.IsEnd)
                {
                    valueType updateValue = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                    if (parser.LoadValueData() && parser.ValueData.Type == ValueData.DataType.UInt)
                    {
                        valueType[] array = arrays[index >> FragmentArray.ArrayShift];
                        valueType   value = array[index &= FragmentArray.ArraySizeAnd];
                        uint        type  = parser.ValueData.Int64.UInt;
                        OperationUpdater.LogicType logicType = (OperationUpdater.LogicType)(byte)(type >> 16);
                        if (logicType != OperationUpdater.LogicType.None && parser.LoadValueData() && parser.IsEnd)
                        {
                            if (OperationUpdater.Data <valueType> .IsLogicData(logicType, value, ValueData.Data <valueType> .GetData(ref parser.ValueData)))
                            {
                                logicType = OperationUpdater.LogicType.None;
                            }
                            else
                            {
                                parser.ReturnParameter.ReturnType = ReturnType.Success;
                                ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                                return;
                            }
                        }
                        if (logicType == OperationUpdater.LogicType.None && parser.IsEnd)
                        {
                            switch (parser.ReturnParameter.ReturnType = OperationUpdater.Data <valueType> .UpdateData((OperationUpdater.OperationType)(ushort) type, ref value, updateValue))
                            {
                            case ReturnType.Success:
                                array[index] = value;
                                parser.UpdateOperation(read, value, OperationParameter.OperationType.SetValue);
                                goto SETDATA;

                            case ReturnType.Unknown:
                                parser.ReturnParameter.ReturnType = ReturnType.Success;
SETDATA:
                                ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                                return;
                            }
                            return;
                        }
                    }
                }
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ArrayIndexOutOfRange;
            }
        }
Example #2
0
        /// <summary>
        /// 设置数据
        /// </summary>
        /// <param name="parser"></param>
        private void setValue(ref OperationParameter.NodeParser parser)
        {
            int index = parser.GetValueData(-1);

            if (index >= 0 && parser.LoadValueData() && parser.IsEnd)
            {
                if (parser.ValueData.Type == ValueData.Data <valueType> .DataType)
                {
                    valueType value = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                    if (index >= array.Length)
                    {
                        array = array.copyNew(Math.Max(index + 1, array.Length << 1), array.Length);
                    }
                    array[index]       = value;
                    parser.IsOperation = true;
                    if (index >= count)
                    {
                        count = index + 1;
                    }
                    parser.ReturnParameter.ReturnParameterSet(true);
                }
                else
                {
                    parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
                }
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ArrayIndexOutOfRange;
            }
        }
Example #3
0
        /// <summary>
        /// 后置插入数据
        /// </summary>
        /// <param name="parser"></param>
        private void insertAfter(ref OperationParameter.NodeParser parser)
        {
            int index = parser.GetValueData(int.MinValue);
            LinkNode <valueType> node = getNode(index);

            if (node != null)
            {
                if (parser.LoadValueData() && parser.IsEnd && parser.ValueData.Type == ValueData.Data <valueType> .DataType)
                {
                    LinkNode <valueType> newNode = new LinkNode <valueType>(node, node.Next, ValueData.Data <valueType> .GetData(ref parser.ValueData));
                    if (node.InsertAfter(newNode))
                    {
                        end = newNode;
                    }
                    ++count;
                    parser.SetOperationReturnParameter();
                }
                else
                {
                    parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
                }
            }
            else if ((count | (index ^ -1)) == 0)
            {
                if (parser.LoadValueData() && parser.IsEnd && parser.ValueData.Type == ValueData.Data <valueType> .DataType)
                {
                    setHeadEnd(ref parser, ValueData.Data <valueType> .GetData(ref parser.ValueData));
                }
                else
                {
                    parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
                }
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.LinkIndexOutOfRange;
            }
        }
        /// <summary>
        /// 设置数据
        /// </summary>
        /// <param name="parser"></param>
        private void setValue(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key) && parser.LoadValueData() && parser.IsEnd && parser.ValueData.Type == ValueData.Data <valueType> .DataType)
            {
                fragmentDictionary[key] = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                parser.SetOperationReturnParameter();
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
Example #5
0
        /// <summary>
        /// 设置数据
        /// </summary>
        /// <param name="parser"></param>
        private void setValue(ref OperationParameter.NodeParser parser)
        {
            keyType key;

            if (HashCodeKey <keyType> .Get(ref parser, out key) && parser.LoadValueData() && parser.IsEnd && parser.ValueData.Type == ValueData.Data <valueType> .DataType)
            {
                valueType value = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                heap.Push(key, ref value);
                parser.SetOperationReturnParameter();
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
Example #6
0
 /// <summary>
 /// 获取队列数据 读文件索引
 /// </summary>
 /// <param name="parser"></param>
 /// <returns></returns>
 private int getReaderIndex(ref OperationParameter.NodeParser parser)
 {
     if (parser.ValueData.Type == ValueData.DataType.Int)
     {
         int index = parser.ValueData.Int64.Int;
         if (parser.LoadValueData() && parser.IsEnd)
         {
             if ((uint)index >= ReaderConfig.MaxReaderCount)
             {
                 parser.ReturnParameter.ReturnType = ReturnType.MessageQueueReaderIndexOutOfRange;
             }
             return(index);
         }
     }
     parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
     return(-1);
 }
Example #7
0
 /// <summary>
 /// 查询数据
 /// </summary>
 /// <param name="parser">参数解析</param>
 internal void Query(ref OperationParameter.NodeParser parser)
 {
     if (parser.LoadValueData())
     {
         if (parser.IsEnd)
         {
             QueryEnd(ref parser);
         }
         else
         {
             Node node = GetQueryNext(ref parser);
             if (node != null)
             {
                 node.Query(ref parser);
             }
         }
     }
     else
     {
         parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
     }
 }
Example #8
0
        /// <summary>
        /// 设置数据
        /// </summary>
        /// <param name="parser"></param>
        private void setValue(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key) && parser.LoadValueData() && parser.IsEnd && parser.ValueData.Type == ValueData.Data <valueType> .DataType)
            {
                valueType value = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, valueType> dictionary = dictionarys[key.HashCode & 0xff];
                if (dictionary == null)
                {
                    dictionarys[key.HashCode & 0xff] = dictionary = AutoCSer.DictionaryCreator <HashCodeKey <keyType> > .Create <valueType>();
                }
                int count = dictionary.Count;
                dictionary[key] = value;
                this.count     += dictionary.Count - count;
                parser.SetOperationReturnParameter();
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
Example #9
0
        /// <summary>
        /// 设置数据
        /// </summary>
        /// <param name="parser"></param>
        private void setValue(ref OperationParameter.NodeParser parser)
        {
            int indexParameter = parser.GetValueData(-1);

            if (indexParameter >= 0 && parser.LoadValueData() && parser.IsEnd)
            {
                if (parser.ValueData.Type == ValueData.Data <valueType> .DataType)
                {
                    valueType value = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                    int arrayIndex = indexParameter >> FragmentArray.ArrayShift;
                    if (arrayIndex >= arrays.Length)
                    {
                        valueType[][] newArrays = arrays.copyNew(arrayIndex + 1, arrays.Length);
                        for (int newIndex = arrays.Length; newIndex != newArrays.Length; newArrays[newIndex++] = new valueType[FragmentArray.ArraySize])
                        {
                            ;
                        }
                        arrays = newArrays;
                    }
                    arrays[arrayIndex][indexParameter & FragmentArray.ArraySizeAnd] = value;
                    if (indexParameter >= count)
                    {
                        count = indexParameter + 1;
                    }
                    parser.SetOperationReturnParameter();
                }
                else
                {
                    parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
                }
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ArrayIndexOutOfRange;
            }
        }
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="parser"></param>
        private unsafe void update(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                valueType value;
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, valueType> dictionary;
                if (fragmentDictionary.TryGetValue(key, out value, out dictionary))
                {
                    byte *read = parser.Read;
                    if (parser.LoadValueData() && !parser.IsEnd)
                    {
                        valueType updateValue = ValueData.Data <valueType> .GetData(ref parser.ValueData);

                        if (parser.LoadValueData() && parser.ValueData.Type == ValueData.DataType.UInt)
                        {
                            uint type = parser.ValueData.Int64.UInt;
                            OperationUpdater.LogicType logicType = (OperationUpdater.LogicType)(byte)(type >> 16);
                            if (logicType != OperationUpdater.LogicType.None && parser.LoadValueData() && parser.IsEnd)
                            {
                                if (OperationUpdater.Data <valueType> .IsLogicData(logicType, value, ValueData.Data <valueType> .GetData(ref parser.ValueData)))
                                {
                                    logicType = OperationUpdater.LogicType.None;
                                }
                                else
                                {
                                    parser.ReturnParameter.ReturnType = ReturnType.Success;
                                    ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                                    return;
                                }
                            }
                            if (logicType == OperationUpdater.LogicType.None && parser.IsEnd)
                            {
                                switch (parser.ReturnParameter.ReturnType = OperationUpdater.Data <valueType> .UpdateData((OperationUpdater.OperationType)(ushort) type, ref value, updateValue))
                                {
                                case ReturnType.Success:
                                    dictionary[key] = value;
                                    parser.UpdateOperation(read, value, OperationParameter.OperationType.SetValue);
                                    goto SETDATA;

                                case ReturnType.Unknown:
                                    parser.ReturnParameter.ReturnType = ReturnType.Success;
SETDATA:
                                    ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value);

                                    return;
                                }
                                return;
                            }
                        }
                    }
                }
                else
                {
                    parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
                    return;
                }
            }
            parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
        }