public unsafe void WriteObject(BinSerializer bs) { bs.Write(WaitHandle.ToInt64()); bs.Write(RaftGroupId); bs.Write(DataCF); bs.Write(KeySize); var span = new ReadOnlySpan <byte>(KeyPtr.ToPointer(), (int)KeySize); bs.Stream.Write(span); }
public unsafe void ReadObject(BinSerializer bs) { WaitHandle = new IntPtr(bs.ReadInt64()); RaftGroupId = bs.ReadUInt64(); DataCF = bs.ReadInt32(); KeySize = bs.ReadUInt32(); KeyPtr = Marshal.AllocHGlobal((int)KeySize); var span = new Span <byte>(KeyPtr.ToPointer(), (int)KeySize); bs.Stream.Read(span); }
KeyPtr[] CreateKeyPtrs() { int singlePaiKeyCount = setSingle.Count; int[] singlePaiKey = setSingle.ToArray(); List <KeyPtr> keyPtrList = new List <KeyPtr>(); SingleKey singleKey; KeyPtr keyPtr; for (int i = 0; i < singlePaiKey.Length; i++) { if (dictLaiziSingleKeys == null || !dictLaiziSingleKeys.ContainsKey(singlePaiKey[i])) { keyPtr = new KeyPtr(); keyPtr.key = singlePaiKey[i]; keyPtr.idx = 0; keyPtrList.Add(keyPtr); } else { singleKey = dictLaiziSingleKeys[singlePaiKey[i]]; if (singleKey.count == 2) { keyPtr = new KeyPtr(); keyPtr.key = singlePaiKey[i]; keyPtr.idx = 1; keyPtrList.Add(keyPtr); } keyPtr = new KeyPtr(); keyPtr.key = singlePaiKey[i]; keyPtr.idx = 0; keyPtrList.Add(keyPtr); } } return(keyPtrList.ToArray()); }
uint CombLaiZiToDataByKey(uint laziData, KeyPtr keyPtr) { if (!dictLaiziSingleKeys.ContainsKey(keyPtr.key)) { return(laziData); } SingleKey singleKey = dictLaiziSingleKeys[keyPtr.key]; byte lazi; if (keyPtr.idx == 0) { lazi = singleKey.key1; } else { lazi = singleKey.key2; } return(CombLaiZiToData(laziData, lazi)); }