@@ -8,14 +8,12 @@ namespace DuckDB.NET.Data;
8
8
public class DuckDBAppenderRow
9
9
{
10
10
private int columnIndex = 0 ;
11
- private readonly Native . DuckDBAppender appender ;
12
11
private readonly string qualifiedTableName ;
13
12
private readonly VectorDataWriterBase [ ] vectorWriters ;
14
13
private readonly ulong rowIndex ;
15
14
16
- internal DuckDBAppenderRow ( Native . DuckDBAppender appender , string qualifiedTableName , VectorDataWriterBase [ ] vectorWriters , ulong rowIndex )
15
+ internal DuckDBAppenderRow ( string qualifiedTableName , VectorDataWriterBase [ ] vectorWriters , ulong rowIndex )
17
16
{
18
- this . appender = appender ;
19
17
this . qualifiedTableName = qualifiedTableName ;
20
18
this . vectorWriters = vectorWriters ;
21
19
this . rowIndex = rowIndex ;
@@ -29,9 +27,9 @@ public void EndRow()
29
27
}
30
28
}
31
29
32
- public DuckDBAppenderRow AppendNullValue ( ) => Append < int > ( null ) ; //Doesn't matter what type T we pass to Append when passing null.
30
+ public DuckDBAppenderRow AppendNullValue ( ) => AppendValueInternal < int ? > ( null ) ; //Doesn't matter what type T we pass to Append when passing null.
33
31
34
- public DuckDBAppenderRow AppendValue ( bool ? value ) => AppendValue2 ( value ) ;
32
+ public DuckDBAppenderRow AppendValue ( bool ? value ) => AppendValueInternal ( value ) ;
35
33
36
34
#if NET6_0_OR_GREATER
37
35
@@ -40,84 +38,68 @@ public void EndRow()
40
38
public DuckDBAppenderRow AppendValue ( Span < byte > value ) => AppendSpan ( value ) ;
41
39
#endif
42
40
43
- public DuckDBAppenderRow AppendValue ( string ? value ) => AppendValue2 ( value ) ;
41
+ public DuckDBAppenderRow AppendValue ( string ? value ) => AppendValueInternal ( value ) ;
44
42
45
- public DuckDBAppenderRow AppendValue ( decimal ? value ) => AppendValue2 ( value ) ;
43
+ public DuckDBAppenderRow AppendValue ( decimal ? value ) => AppendValueInternal ( value ) ;
46
44
47
- public DuckDBAppenderRow AppendValue ( Guid ? value ) => AppendValue2 ( value ) ;
45
+ public DuckDBAppenderRow AppendValue ( Guid ? value ) => AppendValueInternal ( value ) ;
48
46
49
- public DuckDBAppenderRow AppendValue ( BigInteger ? value , bool unsigned = false )
50
- {
51
- if ( value == null )
52
- {
53
- return AppendNullValue ( ) ;
54
- }
55
-
56
- if ( unsigned )
57
- {
58
- Append < DuckDBUHugeInt > ( new DuckDBUHugeInt ( value . Value ) ) ;
59
- }
60
- else
61
- {
62
- Append < DuckDBHugeInt > ( new DuckDBHugeInt ( value . Value ) ) ;
63
- }
64
-
65
- return this ;
66
- }
47
+ public DuckDBAppenderRow AppendValue ( BigInteger ? value ) => AppendValueInternal ( value ) ;
67
48
68
49
#region Append Signed Int
69
50
70
- public DuckDBAppenderRow AppendValue ( sbyte ? value ) => Append ( value ) ;
51
+ public DuckDBAppenderRow AppendValue ( sbyte ? value ) => AppendValueInternal ( value ) ;
71
52
72
- public DuckDBAppenderRow AppendValue ( short ? value ) => Append ( value ) ;
53
+ public DuckDBAppenderRow AppendValue ( short ? value ) => AppendValueInternal ( value ) ;
73
54
74
- public DuckDBAppenderRow AppendValue ( int ? value ) => Append ( value ) ;
55
+ public DuckDBAppenderRow AppendValue ( int ? value ) => AppendValueInternal ( value ) ;
75
56
76
- public DuckDBAppenderRow AppendValue ( long ? value ) => Append ( value ) ;
57
+ public DuckDBAppenderRow AppendValue ( long ? value ) => AppendValueInternal ( value ) ;
77
58
78
59
#endregion
79
60
80
61
#region Append Unsigned Int
81
62
82
- public DuckDBAppenderRow AppendValue ( byte ? value ) => Append ( value ) ;
63
+ public DuckDBAppenderRow AppendValue ( byte ? value ) => AppendValueInternal ( value ) ;
83
64
84
- public DuckDBAppenderRow AppendValue ( ushort ? value ) => Append ( value ) ;
65
+ public DuckDBAppenderRow AppendValue ( ushort ? value ) => AppendValueInternal ( value ) ;
85
66
86
- public DuckDBAppenderRow AppendValue ( uint ? value ) => Append ( value ) ;
67
+ public DuckDBAppenderRow AppendValue ( uint ? value ) => AppendValueInternal ( value ) ;
87
68
88
- public DuckDBAppenderRow AppendValue ( ulong ? value ) => Append ( value ) ;
69
+ public DuckDBAppenderRow AppendValue ( ulong ? value ) => AppendValueInternal ( value ) ;
89
70
90
71
#endregion
91
72
92
73
#region Append Float
93
74
94
- public DuckDBAppenderRow AppendValue ( float ? value ) => Append ( value ) ;
75
+ public DuckDBAppenderRow AppendValue ( float ? value ) => AppendValueInternal ( value ) ;
95
76
96
- public DuckDBAppenderRow AppendValue ( double ? value ) => Append ( value ) ;
77
+ public DuckDBAppenderRow AppendValue ( double ? value ) => AppendValueInternal ( value ) ;
97
78
98
79
#endregion
99
80
100
81
#region Append Temporal
101
82
#if NET6_0_OR_GREATER
102
- public DuckDBAppenderRow AppendValue ( DateOnly ? value ) => Append ( value == null ? ( DuckDBDate ? ) null : NativeMethods . DateTimeHelpers . DuckDBToDate ( value . Value ) ) ;
83
+ public DuckDBAppenderRow AppendValue ( DateOnly ? value ) => AppendValueInternal ( value ) ;
103
84
104
- public DuckDBAppenderRow AppendValue ( TimeOnly ? value ) => Append ( value == null ? ( DuckDBTime ? ) null : NativeMethods . DateTimeHelpers . DuckDBToTime ( value . Value ) ) ;
105
- #else
106
- public DuckDBAppenderRow AppendValue ( DuckDBDateOnly ? value ) => Append ( value == null ? ( DuckDBDate ? ) null : NativeMethods . DateTimeHelpers . DuckDBToDate ( value . Value ) ) ;
107
-
108
- public DuckDBAppenderRow AppendValue ( DuckDBTimeOnly ? value ) => Append ( value == null ? ( DuckDBTime ? ) null : NativeMethods . DateTimeHelpers . DuckDBToTime ( value . Value ) ) ;
85
+ public DuckDBAppenderRow AppendValue ( TimeOnly ? value ) => AppendValueInternal ( value ) ;
109
86
#endif
110
87
111
- public DuckDBAppenderRow AppendValue ( DateTime ? value ) => Append ( value == null ? ( DuckDBTimestampStruct ? ) null : NativeMethods . DateTimeHelpers . DuckDBToTimestamp ( DuckDBTimestamp . FromDateTime ( value . Value ) ) ) ;
88
+ public DuckDBAppenderRow AppendValue ( DuckDBDateOnly ? value ) => AppendValueInternal ( value ) ;
89
+
90
+ public DuckDBAppenderRow AppendValue ( DuckDBTimeOnly ? value ) => AppendValueInternal ( value ) ;
91
+
92
+
93
+ public DuckDBAppenderRow AppendValue ( DateTime ? value ) => AppendValueInternal ( value ) ;
112
94
113
95
public DuckDBAppenderRow AppendValue ( TimeSpan ? value )
114
96
{
115
- return AppendValue2 ( value ) ;
97
+ return AppendValueInternal ( value ) ;
116
98
}
117
99
118
100
#endregion
119
101
120
- private DuckDBAppenderRow AppendValue2 < T > ( T ? value )
102
+ private DuckDBAppenderRow AppendValueInternal < T > ( T ? value )
121
103
{
122
104
CheckColumnAccess ( ) ;
123
105
@@ -128,24 +110,6 @@ private DuckDBAppenderRow AppendValue2<T>(T? value)
128
110
return this ;
129
111
}
130
112
131
- private DuckDBAppenderRow Append < T > ( T ? value ) where T : unmanaged
132
- {
133
- CheckColumnAccess ( ) ;
134
-
135
- if ( value == null )
136
- {
137
- vectorWriters [ columnIndex ] . AppendNull ( rowIndex ) ;
138
- }
139
- else
140
- {
141
- vectorWriters [ columnIndex ] . AppendValueInternal ( value . Value , rowIndex ) ;
142
- }
143
-
144
- columnIndex ++ ;
145
-
146
- return this ;
147
- }
148
-
149
113
#if NET6_0_OR_GREATER
150
114
private unsafe DuckDBAppenderRow AppendSpan ( Span < byte > val )
151
115
{
0 commit comments