/// <summary> /// 查询数据 /// </summary> /// <param name="parser">参数解析</param> internal override void QueryEnd(ref OperationParameter.NodeParser parser) { HashCodeKey <keyType> key; switch (parser.OperationType) { case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(fragmentDictionary.Count); return; case OperationParameter.OperationType.GetValue: if (HashCodeKey <keyType> .Get(ref parser, out key)) { valueType value; if (fragmentDictionary.TryGetValue(key, out value)) { ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value); parser.ReturnParameter.ReturnType = ReturnType.Success; } else { parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey; } } return; case OperationParameter.OperationType.ContainsKey: if (HashCodeKey <keyType> .Get(ref parser, out key)) { parser.ReturnParameter.ReturnParameterSet(fragmentDictionary.ContainsKey(key)); } return; } parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError; }
/// <summary> /// 设置数据 /// </summary> /// <param name="parser"></param> private void setValue(ref OperationParameter.NodeParser parser) { HashCodeKey <valueType> key; if (HashCodeKey <valueType> .Get(ref parser, out key)) { hashSet.Add(key); parser.SetOperationReturnParameter(); } }
/// <summary> /// 查询数据 /// </summary> /// <param name="parser">参数解析</param> internal override void QueryEnd(ref OperationParameter.NodeParser parser) { keyType key; switch (parser.OperationType) { case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(Dictionary.Count); return; case OperationParameter.OperationType.GetValue: if (HashCodeKey <keyType> .Get(ref parser, out key)) { valueType value; if (Dictionary.TryGetValue(key, out value)) { ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value); parser.ReturnParameter.ReturnType = ReturnType.Success; } else { parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey; } } return; case OperationParameter.OperationType.ContainsKey: if (HashCodeKey <keyType> .Get(ref parser, out key)) { parser.ReturnParameter.ReturnParameterSet(Dictionary.ContainsKey(key)); } return; case OperationParameter.OperationType.GetValues: if (parser.OnReturn != null) { if (parser.ValueData.Type == ValueData.DataType.ULong) { ulong count = parser.ValueData.Int64.ULong; int skipCount = (int)(uint)count, getCount = (int)(uint)(count >> 32); if (skipCount >= 0 && getCount != 0) { parser.Cache.TcpServer.CallQueue.Add(new ServerCall.SearchTreeDictionaryGetter <keyType, valueType>(this, skipCount, getCount, ref parser)); } } parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError; } return; } parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError; }
/// <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; } }
/// <summary> /// 删除数据 /// </summary> /// <param name="parser"></param> private void remove(ref OperationParameter.NodeParser parser) { HashCodeKey <keyType> key; if (HashCodeKey <keyType> .Get(ref parser, out key)) { if (fragmentDictionary.Remove(key)) { parser.SetOperationReturnParameter(); } else { parser.ReturnParameter.ReturnParameterSet(false); } } }
/// <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; } }
/// <summary> /// 删除数据 /// </summary> /// <param name="parser"></param> private void remove(ref OperationParameter.NodeParser parser) { HashCodeKey <valueType> key; if (HashCodeKey <valueType> .Get(ref parser, out key)) { if (hashSet.Remove(key)) { parser.SetOperationReturnParameter(); } else { parser.ReturnParameter.ReturnParameterSet(false); } } }
/// <summary> /// 查询数据 /// </summary> /// <param name="parser">参数解析</param> internal override void QueryEnd(ref OperationParameter.NodeParser parser) { HashCodeKey <valueType> key; switch (parser.OperationType) { case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(hashSet.Count); return; case OperationParameter.OperationType.ContainsKey: if (HashCodeKey <valueType> .Get(ref parser, out key)) { parser.ReturnParameter.ReturnParameterSet(hashSet.Contains(key)); } return; } parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError; }
/// <summary> /// 删除数据 /// </summary> /// <param name="parser"></param> private void remove(ref OperationParameter.NodeParser parser) { HashCodeKey <keyType> key; if (HashCodeKey <keyType> .Get(ref parser, out key)) { System.Collections.Generic.Dictionary <HashCodeKey <keyType>, valueType> dictionary = dictionarys[key.HashCode & 0xff]; if (dictionary != null && dictionary.Remove(key)) { --count; parser.SetOperationReturnParameter(); } else { parser.ReturnParameter.ReturnParameterSet(false); } } }
/// <summary> /// 删除数据 /// </summary> /// <param name="parser"></param> private void remove(ref OperationParameter.NodeParser parser) { HashCodeKey <valueType> key; if (HashCodeKey <valueType> .Get(ref parser, out key)) { System.Collections.Generic.HashSet <HashCodeKey <valueType> > hashSet = hashSets[key.HashCode & 0xff]; if (hashSet != null && hashSet.Remove(key)) { --count; parser.SetOperationReturnParameter(); } else { parser.ReturnParameter.ReturnParameterSet(false); } } }
/// <summary> /// 查询数据 /// </summary> /// <param name="parser">参数解析</param> internal override void QueryEnd(ref OperationParameter.NodeParser parser) { HashCodeKey <valueType> key; switch (parser.OperationType) { case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(count); return; case OperationParameter.OperationType.ContainsKey: if (HashCodeKey <valueType> .Get(ref parser, out key)) { System.Collections.Generic.HashSet <HashCodeKey <valueType> > hashSet = hashSets[key.HashCode & 0xff]; parser.ReturnParameter.ReturnParameterSet(hashSet != null && hashSet.Contains(key)); } return; } parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError; }
/// <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; } }
/// <summary> /// 查询数据 /// </summary> /// <param name="parser">参数解析</param> internal override void QueryEnd(ref OperationParameter.NodeParser parser) { HashCodeKey <keyType> key; switch (parser.OperationType) { case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(count); return; case OperationParameter.OperationType.GetValue: if (HashCodeKey <keyType> .Get(ref parser, out key)) { System.Collections.Generic.Dictionary <HashCodeKey <keyType>, valueType> dictionary = dictionarys[key.HashCode & 0xff]; valueType value; if (dictionary != null && dictionary.TryGetValue(key, out value)) { ValueData.Data <valueType> .SetData(ref parser.ReturnParameter, value); parser.ReturnParameter.ReturnType = ReturnType.Success; } else { parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey; } } return; case OperationParameter.OperationType.ContainsKey: if (HashCodeKey <keyType> .Get(ref parser, out key)) { System.Collections.Generic.Dictionary <HashCodeKey <keyType>, valueType> dictionary = dictionarys[key.HashCode & 0xff]; parser.ReturnParameter.ReturnParameterSet(dictionary != null && dictionary.ContainsKey(key)); } return; } parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError; }
/// <summary> /// 设置数据 /// </summary> /// <param name="parser"></param> private void setValue(ref OperationParameter.NodeParser parser) { HashCodeKey <valueType> key; if (HashCodeKey <valueType> .Get(ref parser, out key)) { System.Collections.Generic.HashSet <HashCodeKey <valueType> > hashSet = hashSets[key.HashCode & 0xff]; if (hashSet == null) { hashSets[key.HashCode & 0xff] = hashSet = AutoCSer.HashSetCreator <HashCodeKey <valueType> > .Create(); } int count = hashSet.Count; hashSet.Add(key); if (hashSet.Count != count) { ++this.count; parser.SetOperationReturnParameter(); } else { parser.ReturnParameter.ReturnParameterSet(true); } } }
/// <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; }