Skip to content

Commit 4a76c9c

Browse files
committed
Change ulong to int in vector writer
1 parent 69e7119 commit 4a76c9c

9 files changed

+34
-34
lines changed

DuckDB.NET.Data/DuckDBAppenderRow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ public class DuckDBAppenderRow
1010
private int columnIndex = 0;
1111
private readonly string qualifiedTableName;
1212
private readonly VectorDataWriterBase[] vectorWriters;
13-
private readonly ulong rowIndex;
13+
private readonly int rowIndex;
1414

1515
internal DuckDBAppenderRow(string qualifiedTableName, VectorDataWriterBase[] vectorWriters, ulong rowIndex)
1616
{
1717
this.qualifiedTableName = qualifiedTableName;
1818
this.vectorWriters = vectorWriters;
19-
this.rowIndex = rowIndex;
19+
this.rowIndex = (int)rowIndex;
2020
}
2121

2222
public void EndRow()

DuckDB.NET.Data/Internal/Writer/BooleanVectorDataWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace DuckDB.NET.Data.Internal.Writer;
55

66
internal sealed unsafe class BooleanVectorDataWriter(IntPtr vector, void* vectorData, DuckDBType columnType) : VectorDataWriterBase(vector, vectorData, columnType)
77
{
8-
internal override bool AppendBool(bool value, ulong rowIndex) => AppendValueInternal(value, rowIndex);
8+
internal override bool AppendBool(bool value, int rowIndex) => AppendValueInternal(value, rowIndex);
99
}

DuckDB.NET.Data/Internal/Writer/DateTimeVectorDataWriter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ namespace DuckDB.NET.Data.Internal.Writer;
55

66
internal sealed unsafe class DateTimeVectorDataWriter(IntPtr vector, void* vectorData, DuckDBType columnType) : VectorDataWriterBase(vector, vectorData, columnType)
77
{
8-
internal override bool AppendDateTime(DateTime value, ulong rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToTimestamp(DuckDBTimestamp.FromDateTime(value)), rowIndex);
8+
internal override bool AppendDateTime(DateTime value, int rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToTimestamp(DuckDBTimestamp.FromDateTime(value)), rowIndex);
99

1010
#if NET6_0_OR_GREATER
11-
internal override bool AppendDateOnly(DateOnly value, ulong rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToDate(value), rowIndex);
11+
internal override bool AppendDateOnly(DateOnly value, int rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToDate(value), rowIndex);
1212

13-
internal override bool AppendTimeOnly(TimeOnly value, ulong rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToTime(value), rowIndex);
13+
internal override bool AppendTimeOnly(TimeOnly value, int rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToTime(value), rowIndex);
1414
#endif
1515

16-
internal override bool AppendDateOnly(DuckDBDateOnly value, ulong rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToDate(value), rowIndex);
16+
internal override bool AppendDateOnly(DuckDBDateOnly value, int rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToDate(value), rowIndex);
1717

18-
internal override bool AppendTimeOnly(DuckDBTimeOnly value, ulong rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToTime(value), rowIndex);
18+
internal override bool AppendTimeOnly(DuckDBTimeOnly value, int rowIndex) => AppendValueInternal(NativeMethods.DateTimeHelpers.DuckDBToTime(value), rowIndex);
1919
}

DuckDB.NET.Data/Internal/Writer/DecimalVectorDataWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal sealed unsafe class DecimalVectorDataWriter(IntPtr vector, void* vector
99
private readonly byte scale = NativeMethods.LogicalType.DuckDBDecimalScale(logicalType);
1010
private readonly DuckDBType decimalType = NativeMethods.LogicalType.DuckDBDecimalInternalType(logicalType);
1111

12-
internal override bool AppendDecimal(decimal value, ulong rowIndex)
12+
internal override bool AppendDecimal(decimal value, int rowIndex)
1313
{
1414
var power = Math.Pow(10, scale);
1515

DuckDB.NET.Data/Internal/Writer/GuidVectorDataWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ namespace DuckDB.NET.Data.Internal.Writer;
66

77
internal sealed unsafe class GuidVectorDataWriter(IntPtr vector, void* vectorData, DuckDBType columnType) : VectorDataWriterBase(vector, vectorData, columnType)
88
{
9-
internal override bool AppendGuid(Guid value, ulong rowIndex) => AppendValueInternal(value.ToHugeInt(), rowIndex);
9+
internal override bool AppendGuid(Guid value, int rowIndex) => AppendValueInternal(value.ToHugeInt(), rowIndex);
1010
}

DuckDB.NET.Data/Internal/Writer/IntervalVectorDataWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ namespace DuckDB.NET.Data.Internal.Writer;
66

77
internal sealed unsafe class IntervalVectorDataWriter(IntPtr vector, void* vectorData, DuckDBType columnType) : VectorDataWriterBase(vector, vectorData, columnType)
88
{
9-
internal override bool AppendTimeSpan(TimeSpan value, ulong rowIndex) => AppendValueInternal((DuckDBInterval)value, rowIndex);
9+
internal override bool AppendTimeSpan(TimeSpan value, int rowIndex) => AppendValueInternal((DuckDBInterval)value, rowIndex);
1010
}

DuckDB.NET.Data/Internal/Writer/NumericVectorDataWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace DuckDB.NET.Data.Internal.Writer;
66

77
internal sealed unsafe class NumericVectorDataWriter(IntPtr vector, void* vectorData, DuckDBType columnType) : VectorDataWriterBase(vector, vectorData, columnType)
88
{
9-
internal override bool AppendNumeric<T>(T value, ulong rowIndex) => AppendValueInternal(value, rowIndex);
9+
internal override bool AppendNumeric<T>(T value, int rowIndex) => AppendValueInternal(value, rowIndex);
1010

11-
internal override bool AppendBigInteger(BigInteger value, ulong rowIndex) => AppendValueInternal<DuckDBHugeInt>(new DuckDBHugeInt(value), rowIndex);
11+
internal override bool AppendBigInteger(BigInteger value, int rowIndex) => AppendValueInternal<DuckDBHugeInt>(new DuckDBHugeInt(value), rowIndex);
1212
}

DuckDB.NET.Data/Internal/Writer/StringVectorDataWriter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ namespace DuckDB.NET.Data.Internal.Writer;
55

66
internal sealed unsafe class StringVectorDataWriter(IntPtr vector, void* vectorData, DuckDBType columnType) : VectorDataWriterBase(vector, vectorData, columnType)
77
{
8-
internal override bool AppendString(string value, ulong rowIndex)
8+
internal override bool AppendString(string value, int rowIndex)
99
{
1010
using var unmanagedString = value.ToUnmanagedString();
11-
NativeMethods.Vectors.DuckDBVectorAssignStringElement(base.Vector, rowIndex, unmanagedString);
11+
NativeMethods.Vectors.DuckDBVectorAssignStringElement(base.Vector, (ulong)rowIndex, unmanagedString);
1212
return true;
1313
}
1414

15-
internal override bool AppendBlob(byte* value, int length, ulong rowIndex)
15+
internal override bool AppendBlob(byte* value, int length, int rowIndex)
1616
{
17-
NativeMethods.Vectors.DuckDBVectorAssignStringElementLength(Vector, rowIndex, value, length);
17+
NativeMethods.Vectors.DuckDBVectorAssignStringElementLength(Vector, (ulong)rowIndex, value, length);
1818
return true;
1919
}
2020
}

DuckDB.NET.Data/Internal/Writer/VectorDataWriterBase.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ internal unsafe class VectorDataWriterBase(IntPtr vector, void* vectorData, Duck
99
private unsafe ulong* validity;
1010
internal IntPtr Vector { get; } = vector;
1111

12-
public unsafe void AppendNull(ulong rowIndex)
12+
public unsafe void AppendNull(int rowIndex)
1313
{
1414
if (validity == default)
1515
{
1616
NativeMethods.Vectors.DuckDBVectorEnsureValidityWritable(Vector);
1717
validity = NativeMethods.Vectors.DuckDBVectorGetValidity(Vector);
1818
}
1919

20-
NativeMethods.ValidityMask.DuckDBValiditySetRowValidity(validity, rowIndex, false);
20+
NativeMethods.ValidityMask.DuckDBValiditySetRowValidity(validity, (ulong)rowIndex, false);
2121
}
2222

23-
public unsafe void AppendValue<T>(T value, ulong rowIndex)
23+
public unsafe void AppendValue<T>(T value, int rowIndex)
2424
{
2525
if (value == null)
2626
{
@@ -60,40 +60,40 @@ public unsafe void AppendValue<T>(T value, ulong rowIndex)
6060
};
6161
}
6262

63-
internal virtual bool AppendBool(bool value, ulong rowIndex) => ThrowException<bool>();
63+
internal virtual bool AppendBool(bool value, int rowIndex) => ThrowException<bool>();
6464

65-
internal virtual bool AppendDecimal(decimal value, ulong rowIndex) => ThrowException<decimal>();
65+
internal virtual bool AppendDecimal(decimal value, int rowIndex) => ThrowException<decimal>();
6666

67-
internal virtual bool AppendTimeSpan(TimeSpan value, ulong rowIndex) => ThrowException<TimeSpan>();
67+
internal virtual bool AppendTimeSpan(TimeSpan value, int rowIndex) => ThrowException<TimeSpan>();
6868

69-
internal virtual bool AppendGuid(Guid value, ulong rowIndex) => ThrowException<Guid>();
69+
internal virtual bool AppendGuid(Guid value, int rowIndex) => ThrowException<Guid>();
7070

71-
internal virtual bool AppendBlob(byte* value, int length, ulong rowIndex) => ThrowException<byte[]>();
71+
internal virtual bool AppendBlob(byte* value, int length, int rowIndex) => ThrowException<byte[]>();
7272

73-
internal virtual bool AppendString(string value, ulong rowIndex) => ThrowException<string>();
73+
internal virtual bool AppendString(string value, int rowIndex) => ThrowException<string>();
7474

75-
internal virtual bool AppendDateTime(DateTime value, ulong rowIndex) => ThrowException<DateTime>();
75+
internal virtual bool AppendDateTime(DateTime value, int rowIndex) => ThrowException<DateTime>();
7676

7777
#if NET6_0_OR_GREATER
78-
internal virtual bool AppendDateOnly(DateOnly value, ulong rowIndex) => ThrowException<DateOnly>();
78+
internal virtual bool AppendDateOnly(DateOnly value, int rowIndex) => ThrowException<DateOnly>();
7979

80-
internal virtual bool AppendTimeOnly(TimeOnly value, ulong rowIndex) => ThrowException<TimeOnly>();
80+
internal virtual bool AppendTimeOnly(TimeOnly value, int rowIndex) => ThrowException<TimeOnly>();
8181
#endif
8282

83-
internal virtual bool AppendDateOnly(DuckDBDateOnly value, ulong rowIndex) => ThrowException<DuckDBDateOnly>();
83+
internal virtual bool AppendDateOnly(DuckDBDateOnly value, int rowIndex) => ThrowException<DuckDBDateOnly>();
8484

85-
internal virtual bool AppendTimeOnly(DuckDBTimeOnly value, ulong rowIndex) => ThrowException<DuckDBTimeOnly>();
85+
internal virtual bool AppendTimeOnly(DuckDBTimeOnly value, int rowIndex) => ThrowException<DuckDBTimeOnly>();
8686

87-
internal virtual bool AppendNumeric<T>(T value, ulong rowIndex) where T : unmanaged => ThrowException<T>();
87+
internal virtual bool AppendNumeric<T>(T value, int rowIndex) where T : unmanaged => ThrowException<T>();
8888

89-
internal virtual bool AppendBigInteger(BigInteger value, ulong rowIndex) => ThrowException<BigInteger>();
89+
internal virtual bool AppendBigInteger(BigInteger value, int rowIndex) => ThrowException<BigInteger>();
9090

9191
private bool ThrowException<T>()
9292
{
9393
throw new InvalidOperationException($"Cannot write {typeof(T).Name} to {columnType} column");
9494
}
9595

96-
internal unsafe bool AppendValueInternal<T>(T value, ulong rowIndex) where T : unmanaged
96+
internal unsafe bool AppendValueInternal<T>(T value, int rowIndex) where T : unmanaged
9797
{
9898
((T*)vectorData)[rowIndex] = value;
9999
return true;

0 commit comments

Comments
 (0)