• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Giorgi / DuckDB.NET / 10928927861

18 Sep 2024 07:34PM UTC coverage: 89.835%. Remained the same
10928927861

push

github

Giorgi
Make properties read-only

918 of 1052 branches covered (87.26%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 1 file covered. (0.0%)

1910 of 2096 relevant lines covered (91.13%)

885429.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/DuckDB.NET.Bindings/DuckDBNativeObjects.cs
1
using System;
2
using System.Diagnostics.CodeAnalysis;
3
using System.Numerics;
4
using System.Runtime.InteropServices;
5

6
namespace DuckDB.NET.Native;
7

8
public enum DuckDBState
9
{
10
    Success = 0,
11
    Error = 1
12
}
13

14
public enum DuckDBType
15
{
16
    Invalid = 0,
17
    // bool
18
    Boolean = 1,
19
    // int8_t
20
    TinyInt = 2,
21
    // int16_t
22
    SmallInt = 3,
23
    // int32_t
24
    Integer = 4,
25
    // int64_t
26
    BigInt = 5,
27
    // uint8_t
28
    UnsignedTinyInt = 6,
29
    // uint16_t
30
    UnsignedSmallInt = 7,
31
    // uint32_t
32
    UnsignedInteger = 8,
33
    // uint64_t
34
    UnsignedBigInt = 9,
35
    // float
36
    Float = 10,
37
    // double
38
    Double = 11,
39
    // duckdb_timestamp
40
    Timestamp = 12,
41
    // duckdb_date
42
    Date = 13,
43
    // duckdb_time
44
    Time = 14,
45
    // duckdb_interval
46
    Interval = 15,
47
    // duckdb_hugeint
48
    HugeInt = 16,
49
    // duckdb_uhugeint
50
    UnsignedHugeInt = 32,
51
    // const char*
52
    Varchar = 17,
53
    // duckdb_blob
54
    Blob = 18,
55
    //decimal
56
    Decimal = 19,
57
    // duckdb_timestamp, in seconds
58
    TimestampS = 20,
59
    // duckdb_timestamp, in milliseconds
60
    TimestampMs = 21,
61
    // duckdb_timestamp, in nanoseconds
62
    TimestampNs = 22,
63
    // enum type, only useful as logical type
64
    Enum = 23,
65
    // list type, only useful as logical type
66
    List = 24,
67
    // duckdb_array, only useful as logical type
68
    Array = 33,
69
    // struct type, only useful as logical type
70
    Struct = 25,
71
    // map type, only useful as logical type
72
    Map = 26,
73
    // duckdb_hugeint
74
    Uuid = 27,
75
    // union type, only useful as logical type
76
    Union = 28,
77
    // duckdb_bit
78
    Bit = 29,
79
    // duckdb_time_tz
80
    TimeTz = 30,
81
    // duckdb_timestamp
82
    TimestampTz = 31,
83
    // ANY type
84
    Any = 34,
85
    // duckdb_varint
86
    VarInt = 35,
87
}
88

89
[StructLayout(LayoutKind.Sequential)]
90
public struct DuckDBResult : IDisposable
91
{
92
    [Obsolete]
93
    private long ColumnCount;
94

95
    [Obsolete]
96
    private long RowCount;
97

98
    [Obsolete]
99
    private long RowsChanged;
100

101
    [Obsolete]
102
    private IntPtr columns;
103

104
    [Obsolete]
105
    private IntPtr ErrorMessage;
106

107
    private IntPtr internal_data;
108

109
    public void Dispose()
110
    {
111
        NativeMethods.Query.DuckDBDestroyResult(ref this);
187,170✔
112
    }
187,170✔
113
}
114

115
[StructLayout(LayoutKind.Sequential)]
116
public struct DuckDBDate
117
{
118
    public int Days { get; set; }
×
119
}
120

121
[StructLayout(LayoutKind.Sequential)]
122
public struct DuckDBTime
123
{
124
    public long Micros { get; set; }
60✔
125
}
126

127
[StructLayout(LayoutKind.Sequential)]
128
public struct DuckDBTimeTzStruct
129
{
130
    public ulong Bits { get; set; }
×
131
}
132

133
[StructLayout(LayoutKind.Sequential)]
134
public struct DuckDBTimeTz
135
{
136
    public DuckDBTimeOnly Time { get; set; }
102✔
137
    public int Offset { get; set; }
102✔
138
}
139

140
[StructLayout(LayoutKind.Sequential)]
141
public struct DuckDBTimestampStruct
142
{
143
    public long Micros { get; set; }
46,770✔
144

145
    public readonly DateTime ToDateTime()
146
    {
147
        var ticks = Micros * 10 + Utils.UnixEpochTicks;
15,438✔
148
        return new DateTime(ticks);
15,438✔
149
    }
150
}
151

152
[StructLayout(LayoutKind.Sequential)]
153
public readonly struct DuckDBBlob : IDisposable
154
{
155
    public IntPtr Data { get; }
×
156

157
    public long Size { get; }
×
158

159
    public void Dispose()
160
    {
161
        NativeMethods.Helpers.DuckDBFree(Data);
×
162
    }
×
163
}
164

165
[StructLayout(LayoutKind.Sequential)]
166
public struct DuckDBListEntry(ulong offset, ulong length)
167
{
168
    public ulong Offset { get; private set; } = offset;
1,897,849✔
169
    public ulong Length { get; private set; } = length;
1,897,882✔
170
}
171

172
public struct DuckDBString
173
{
174
    public _value_e__Union value;
175

176
    private const int InlineStringMaxLength = 12;
177

178
    public readonly int Length => (int)value.inlined.length;
2,934,063✔
179

180
    public readonly unsafe sbyte* Data
181
    {
182
        get
183
        {
184
            if (Length <= InlineStringMaxLength)
1,124,109✔
185
            {
368,678✔
186
                fixed (sbyte* pointerToFirst = value.inlined.inlined)
368,678✔
187
                {
188
                    return pointerToFirst;
368,678✔
189
                }
190
            }
191
            else
192
            {
193
                return value.pointer.ptr;
755,431✔
194
            }
195
        }
196
    }
197

198
    [StructLayout(LayoutKind.Explicit)]
199
    public partial struct _value_e__Union
200
    {
201
        [FieldOffset(0)]
202
        public DuckDBStringPointer pointer;
203

204
        [FieldOffset(0)]
205
        public DuckDBStringInlined inlined;
206

207
        public unsafe partial struct DuckDBStringPointer
208
        {
209
            public uint length;
210

211
            public fixed sbyte prefix[4];
212

213
            public sbyte* ptr;
214
        }
215

216
        public unsafe partial struct DuckDBStringInlined
217
        {
218
            public uint length;
219

220
            public fixed sbyte inlined[12];
221
        }
222
    }
223
}
224

225
[StructLayout(LayoutKind.Sequential)]
226
public struct DuckDBQueryProgressType
227
{
NEW
228
    public double Percentage { get; }
×
NEW
229
    public ulong RowsProcessed { get; }
×
NEW
230
    public ulong TotalRowsToProcess { get; }
×
231
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc