Skip to content

Commit 7a83fdc

Browse files
committed
Fix the use of raw integers for Arrow status codes
1 parent 38a6079 commit 7a83fdc

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

cpp/Enums.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ namespace
9797
static_assert(::arrow::TimeUnit::type::MILLI == 1);
9898
static_assert(::arrow::TimeUnit::type::MICRO == 2);
9999
static_assert(::arrow::TimeUnit::type::NANO == 3);
100-
}
101100

101+
// Arrow StatusCode values that should be kept up to date with ArrowStatusCode.cs
102+
static_assert((int) ::arrow::StatusCode::OutOfMemory == 1);
103+
static_assert((int) ::arrow::StatusCode::IOError == 5);
104+
static_assert((int) ::arrow::StatusCode::UnknownError == 9);
105+
}
102106
}

csharp/ArrowStatusCode.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace ParquetSharp
2+
{
3+
/// <summary>
4+
/// Subset of Arrow StatusCode enums used from ParquetSharp.
5+
/// </summary>
6+
internal enum ArrowStatusCode
7+
{
8+
OutOfMemory = 1,
9+
IOError = 5,
10+
UnknownError = 9,
11+
}
12+
}

csharp/IO/ManagedRandomAccessFile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,16 @@ private byte HandleException(Exception error, out string? exception)
168168
if (error is OutOfMemoryException)
169169
{
170170
exception = _exceptionMessage = null;
171-
return 1;
171+
return (byte) ArrowStatusCode.OutOfMemory;
172172
}
173173
if (error is IOException)
174174
{
175175
exception = _exceptionMessage = error.ToString();
176-
return 5;
176+
return (byte) ArrowStatusCode.IOError;
177177
}
178178

179179
exception = _exceptionMessage = error.ToString();
180-
return 9;
180+
return (byte) ArrowStatusCode.UnknownError;
181181
}
182182

183183
[DllImport(ParquetDll.Name)]

0 commit comments

Comments
 (0)