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

Giorgi / DuckDB.NET / 10460156994

19 Aug 2024 08:05PM UTC coverage: 89.935% (-0.3%) from 90.251%
10460156994

push

github

Giorgi
Check for null

878 of 1006 branches covered (87.28%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

18 existing lines in 4 files now uncovered.

1767 of 1935 relevant lines covered (91.32%)

819430.97 hits per line

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

81.82
/DuckDB.NET.Data/Internal/Writer/VectorDataWriterBase.cs
1
using System;
2
using System.Collections;
3
using System.Collections.Generic;
4
using System.Numerics;
5
using DuckDB.NET.Native;
6

7
namespace DuckDB.NET.Data.Internal.Writer;
8

9
internal unsafe class VectorDataWriterBase(IntPtr vector, void* vectorData, DuckDBType columnType) : IDisposable
855✔
10
{
11
    private ulong* validity;
12

13
    internal IntPtr Vector => vector;
797,825✔
14
    internal DuckDBType ColumnType => columnType;
3,663,147✔
15

16
    public void AppendNull(int rowIndex)
17
    {
18
        if (validity == default)
5,260,963✔
19
        {
20
            NativeMethods.Vectors.DuckDBVectorEnsureValidityWritable(Vector);
759✔
21
            validity = NativeMethods.Vectors.DuckDBVectorGetValidity(Vector);
759✔
22
        }
23

24
        NativeMethods.ValidityMask.DuckDBValiditySetRowValidity(validity, (ulong)rowIndex, false);
5,260,963✔
25
    }
5,260,963✔
26

27
    public void AppendValue<T>(T value, int rowIndex)
28
    {
29
        if (value == null)
26,181,440✔
30
        {
31
            AppendNull(rowIndex);
5,260,963✔
32
            return;
5,260,963✔
33
        }
34

35
        _ = value switch
20,920,477!
36
        {
20,920,477✔
37
            bool val => AppendBool(val, rowIndex),
1,125,074✔
38

20,920,477✔
39
            sbyte val => AppendNumeric(val, rowIndex),
1,122,169✔
40
            short val => AppendNumeric(val, rowIndex),
1,120,890✔
41
            int val => AppendNumeric(val, rowIndex),
1,551,708✔
42
            long val => AppendNumeric(val, rowIndex),
1,123,490✔
43
            byte val => AppendNumeric(val, rowIndex),
1,125,650✔
44
            ushort val => AppendNumeric(val, rowIndex),
1,129,941✔
45
            uint val => AppendNumeric(val, rowIndex),
1,119,277✔
46
            ulong val => AppendNumeric(val, rowIndex),
1,116,510✔
47
            float val => AppendNumeric(val, rowIndex),
1,130,609✔
48
            double val => AppendNumeric(val, rowIndex),
1,119,939✔
49
            
20,920,477✔
50
            decimal val => AppendDecimal(val, rowIndex),
1,127,010✔
51
            BigInteger val => AppendBigInteger(val, rowIndex),
1,492,193✔
52

20,920,477✔
53
            Enum val => AppendEnum(val, rowIndex),
560,327✔
54

20,920,477✔
55
            string val => AppendString(val, rowIndex),
1,348,732✔
56
            Guid val => AppendGuid(val, rowIndex),
1,140,309✔
57
            DateTime val => AppendDateTime(val, rowIndex),
764,913✔
58
            TimeSpan val => AppendTimeSpan(val, rowIndex),
751,121✔
UNCOV
59
            DuckDBDateOnly val => AppendDateOnly(val, rowIndex),
×
UNCOV
60
            DuckDBTimeOnly val => AppendTimeOnly(val, rowIndex),
×
61
#if NET6_0_OR_GREATER
20,920,477✔
62
            DateOnly val => AppendDateOnly(val, rowIndex),
60✔
63
            TimeOnly val => AppendTimeOnly(val, rowIndex),
60✔
64
#endif
20,920,477✔
65
            DateTimeOffset val => AppendDateTimeOffset(val, rowIndex),
60✔
66
            ICollection val => AppendCollection(val, rowIndex),
950,435✔
67
            _ => ThrowException<T>()
×
68
        };
20,920,477✔
69
    }
×
70

71
    internal virtual bool AppendBool(bool value, int rowIndex) => ThrowException<bool>();
×
72

73
    internal virtual bool AppendDecimal(decimal value, int rowIndex) => ThrowException<decimal>();
×
74

75
    internal virtual bool AppendTimeSpan(TimeSpan value, int rowIndex) => ThrowException<TimeSpan>();
×
76

77
    internal virtual bool AppendGuid(Guid value, int rowIndex) => ThrowException<Guid>();
×
78

79
    internal virtual bool AppendBlob(byte* value, int length, int rowIndex) => ThrowException<byte[]>();
×
80

81
    internal virtual bool AppendString(string value, int rowIndex) => ThrowException<string>();
×
82

UNCOV
83
    internal virtual bool AppendDateTime(DateTime value, int rowIndex) => ThrowException<DateTime>();
×
84

85
#if NET6_0_OR_GREATER
86
    internal virtual bool AppendDateOnly(DateOnly value, int rowIndex) => ThrowException<DateOnly>();
×
87

UNCOV
88
    internal virtual bool AppendTimeOnly(TimeOnly value, int rowIndex) => ThrowException<TimeOnly>();
×
89
#endif
90

91
    internal virtual bool AppendDateOnly(DuckDBDateOnly value, int rowIndex) => ThrowException<DuckDBDateOnly>();
×
92

93
    internal virtual bool AppendTimeOnly(DuckDBTimeOnly value, int rowIndex) => ThrowException<DuckDBTimeOnly>();
×
94

UNCOV
95
    internal virtual bool AppendDateTimeOffset(DateTimeOffset value, int rowIndex) => ThrowException<DateTimeOffset>();
×
96

97
    internal virtual bool AppendNumeric<T>(T value, int rowIndex) where T : unmanaged => ThrowException<T>();
3✔
98

99
    internal virtual bool AppendBigInteger(BigInteger value, int rowIndex) => ThrowException<BigInteger>();
×
100

UNCOV
101
    internal virtual bool AppendEnum<TEnum>(TEnum value, int rowIndex) where TEnum : Enum => ThrowException<TEnum>();
×
102

UNCOV
103
    internal virtual bool AppendCollection(ICollection value, int rowIndex) => ThrowException<bool>();
×
104

105
    private bool ThrowException<T>()
106
    {
107
        throw new InvalidOperationException($"Cannot write {typeof(T).Name} to {columnType} column");
3✔
108
    }
109

110
    internal bool AppendValueInternal<T>(T value, int rowIndex) where T : unmanaged
111
    {
112
        ((T*)vectorData)[rowIndex] = value;
20,121,491✔
113
        return true;
20,121,491✔
114
    }
115

116
    internal void InitializerWriter()
117
    {
118
        validity = default;
1,689✔
119
        vectorData = NativeMethods.Vectors.DuckDBVectorGetData(Vector);
1,689✔
120
    }
1,689✔
121

122
    public virtual void Dispose()
123
    {
124
        
125
    }
531✔
126
}
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