Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/pre-commit-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
workflow_dispatch:
pull_request:
branches:
- '**'
- "**"
merge_group:
branches: [ main ]
branches: [main]
# schedule:
# - cron: "0 0 * * *"

Expand All @@ -17,19 +17,22 @@ concurrency:
jobs:
formatting-checks:
runs-on: ubuntu-22.04
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1

steps:
- uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
dotnet-version: "9.0.x"

- name: Setup Python environment (for pre-commit)
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.10"

- name: Clean dotnet temporary folder
run: |
Expand Down
59 changes: 44 additions & 15 deletions src/Apache.IoTDB/DataStructure/ByteBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

using System;
using System.Linq;
using System.Text;

namespace Apache.IoTDB.DataStructure
Expand Down Expand Up @@ -70,9 +69,12 @@ public bool GetBool()
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
Expand All @@ -85,9 +87,12 @@ 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
Expand All @@ -100,9 +105,12 @@ 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
Expand All @@ -114,9 +122,12 @@ 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
Expand Down Expand Up @@ -173,7 +184,10 @@ 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);
Expand All @@ -184,7 +198,10 @@ 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);
Expand All @@ -195,7 +212,10 @@ 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);
Expand All @@ -206,7 +226,10 @@ 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);
Expand All @@ -217,7 +240,10 @@ 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);
Expand Down Expand Up @@ -248,7 +274,10 @@ 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);
Expand Down
Loading