This is an automated email from the ASF dual-hosted git repository. critas pushed a commit to branch dev/1.3_fix_session_pool_leak in repository https://gitbox.apache.org/repos/asf/iotdb-client-csharp.git
commit 4a78ff85741f5c47dd552d4bbf1bc812003934b0 Author: CritasWang <[email protected]> AuthorDate: Fri Feb 6 14:05:44 2026 +0800 fix ByteBuffer build error ,use Array.Reverse() --- src/Apache.IoTDB/DataStructure/ByteBuffer.cs | 68 ++++++++++++++++++---------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/src/Apache.IoTDB/DataStructure/ByteBuffer.cs b/src/Apache.IoTDB/DataStructure/ByteBuffer.cs index a3e1823..091080c 100644 --- a/src/Apache.IoTDB/DataStructure/ByteBuffer.cs +++ b/src/Apache.IoTDB/DataStructure/ByteBuffer.cs @@ -18,7 +18,6 @@ */ using System; -using System.Linq; using System.Text; namespace Apache.IoTDB.DataStructure @@ -70,9 +69,12 @@ namespace Apache.IoTDB.DataStructure public int GetInt() { var intBuff = _buffer[_readPos..(_readPos + 4)]; - if (_isLittleEndian) intBuff = intBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(intBuff); + } #if NET461_OR_GREATER || NETSTANDARD2_0 - var intValue = BitConverter.ToInt32(intBuff,0); + var intValue = BitConverter.ToInt32(intBuff, 0); #else var intValue = BitConverter.ToInt32(intBuff); #endif @@ -84,10 +86,12 @@ namespace Apache.IoTDB.DataStructure public long GetLong() { var longBuff = _buffer[_readPos..(_readPos + 8)]; - - if (_isLittleEndian) longBuff = longBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(longBuff); + } #if NET461_OR_GREATER || NETSTANDARD2_0 - var longValue = BitConverter.ToInt64(longBuff,0); + var longValue = BitConverter.ToInt64(longBuff, 0); #else var longValue = BitConverter.ToInt64(longBuff); #endif @@ -99,10 +103,12 @@ namespace Apache.IoTDB.DataStructure public float GetFloat() { var floatBuff = _buffer[_readPos..(_readPos + 4)]; - - if (_isLittleEndian) floatBuff = floatBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(floatBuff); + } #if NET461_OR_GREATER || NETSTANDARD2_0 - var floatValue = BitConverter.ToSingle(floatBuff,0); + var floatValue = BitConverter.ToSingle(floatBuff, 0); #else var floatValue = BitConverter.ToSingle(floatBuff); #endif @@ -113,10 +119,12 @@ namespace Apache.IoTDB.DataStructure public double GetDouble() { var doubleBuff = _buffer[_readPos..(_readPos + 8)]; - - if (_isLittleEndian) doubleBuff = doubleBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(doubleBuff); + } #if NET461_OR_GREATER || NETSTANDARD2_0 - var doubleValue = BitConverter.ToDouble(doubleBuff,0); + var doubleValue = BitConverter.ToDouble(doubleBuff, 0); #else var doubleValue = BitConverter.ToDouble(doubleBuff); #endif @@ -162,8 +170,10 @@ namespace Apache.IoTDB.DataStructure public void AddBool(bool value) { var boolBuffer = BitConverter.GetBytes(value); - - if (_isLittleEndian) boolBuffer = boolBuffer.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(boolBuffer); + } ExtendBuffer(boolBuffer.Length); boolBuffer.CopyTo(_buffer, _writePos); @@ -173,8 +183,10 @@ namespace Apache.IoTDB.DataStructure public void AddInt(int value) { var intBuff = BitConverter.GetBytes(value); - - if (_isLittleEndian) intBuff = intBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(intBuff); + } ExtendBuffer(intBuff.Length); intBuff.CopyTo(_buffer, _writePos); @@ -184,8 +196,10 @@ namespace Apache.IoTDB.DataStructure public void AddLong(long value) { var longBuff = BitConverter.GetBytes(value); - - if (_isLittleEndian) longBuff = longBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(longBuff); + } ExtendBuffer(longBuff.Length); longBuff.CopyTo(_buffer, _writePos); @@ -195,8 +209,10 @@ namespace Apache.IoTDB.DataStructure public void AddFloat(float value) { var floatBuff = BitConverter.GetBytes(value); - - if (_isLittleEndian) floatBuff = floatBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(floatBuff); + } ExtendBuffer(floatBuff.Length); floatBuff.CopyTo(_buffer, _writePos); @@ -206,8 +222,10 @@ namespace Apache.IoTDB.DataStructure public void AddDouble(double value) { var doubleBuff = BitConverter.GetBytes(value); - - if (_isLittleEndian) doubleBuff = doubleBuff.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(doubleBuff); + } ExtendBuffer(doubleBuff.Length); doubleBuff.CopyTo(_buffer, _writePos); @@ -237,8 +255,10 @@ namespace Apache.IoTDB.DataStructure public void AddChar(char value) { var charBuf = BitConverter.GetBytes(value); - - if (_isLittleEndian) charBuf = charBuf.Reverse().ToArray(); + if (_isLittleEndian) + { + Array.Reverse(charBuf); + } ExtendBuffer(charBuf.Length); charBuf.CopyTo(_buffer, _writePos);
