Skip to content

Commit 959c99e

Browse files
authored
Add set_max_statistics_size to WriterProperties (#581)
1 parent 092d3df commit 959c99e

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

cpp/WriterPropertiesBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,9 @@ extern "C"
241241
{
242242
TRYCATCH(builder->disable_store_decimal_as_integer();)
243243
}
244+
245+
PARQUETSHARP_EXPORT ExceptionInfo* WriterPropertiesBuilder_Set_Max_Statistics_Size(WriterProperties::Builder* builder, size_t max_statistics_size)
246+
{
247+
TRYCATCH(builder->max_statistics_size(max_statistics_size);)
248+
}
244249
}

csharp.test/TestWriterProperties.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static void TestDefaultProperties()
2828
Assert.False(p.PageChecksumEnabled);
2929
Assert.That(p.MemoryPool.BackendName, Is.Not.Empty);
3030
Assert.False(p.StoreDecimalAsInteger);
31+
Assert.AreEqual(4096, p.MaxStatisticsSize(new ColumnPath("anypath")));
3132
}
3233

3334
[Test]
@@ -48,6 +49,7 @@ public static void TestPropertiesBuilder()
4849
.EnablePageChecksum()
4950
.MemoryPool(MemoryPool.SystemMemoryPool())
5051
.EnableStoreDecimalAsInteger()
52+
.SetMaxStatisticsSize(512)
5153
.Build();
5254

5355
Assert.AreEqual("Meeeee!!!", p.CreatedBy);
@@ -64,6 +66,7 @@ public static void TestPropertiesBuilder()
6466
Assert.True(p.PageChecksumEnabled);
6567
Assert.AreEqual("system", p.MemoryPool.BackendName);
6668
Assert.True(p.StoreDecimalAsInteger);
69+
Assert.AreEqual(512, p.MaxStatisticsSize(new ColumnPath("anypath")));
6770
}
6871

6972
[Test]

csharp/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ ParquetSharp.ReaderProperties.SetFooterReadSize(long size) -> void
1414
ParquetSharp.WriterProperties.StoreDecimalAsInteger.get -> bool
1515
ParquetSharp.WriterPropertiesBuilder.EnableStoreDecimalAsInteger() -> ParquetSharp.WriterPropertiesBuilder!
1616
ParquetSharp.WriterPropertiesBuilder.DisableStoreDecimalAsInteger() -> ParquetSharp.WriterPropertiesBuilder!
17+
ParquetSharp.WriterPropertiesBuilder.SetMaxStatisticsSize(ulong maxStatisticsSize) -> ParquetSharp.WriterPropertiesBuilder!

csharp/WriterProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public SortingColumn[] SortingColumns()
335335
private static extern IntPtr WriterProperties_Statistics_Enabled(IntPtr writerProperties, IntPtr path, [MarshalAs(UnmanagedType.I1)] out bool enabled);
336336

337337
[DllImport(ParquetDll.Name)]
338-
private static extern IntPtr WriterProperties_Max_Statistics_Size(IntPtr writerProperties, IntPtr path, [MarshalAs(UnmanagedType.I1)] out ulong maxStatisticsSize);
338+
private static extern IntPtr WriterProperties_Max_Statistics_Size(IntPtr writerProperties, IntPtr path, out ulong maxStatisticsSize);
339339

340340
[DllImport(ParquetDll.Name)]
341341
private static extern IntPtr WriterProperties_Sorting_Columns(IntPtr writerProperties, ref IntPtr columnIndices, ref IntPtr descending, ref IntPtr nullsFirst, ref int numColumns);

csharp/WriterPropertiesBuilder.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,19 @@ public WriterPropertiesBuilder MemoryPool(MemoryPool memoryPool)
549549
return this;
550550
}
551551

552+
/// <summary>
553+
/// Specify the maximum size in bytes for minimum and maximum values in page and column chunk statistics.
554+
/// Default 4 KiB.
555+
/// </summary>
556+
/// <param name="maxStatisticsSize">The max statistics size in bytes</param>
557+
/// <returns>This builder instance.</returns>
558+
public WriterPropertiesBuilder SetMaxStatisticsSize(ulong maxStatisticsSize)
559+
{
560+
ExceptionInfo.Check(WriterPropertiesBuilder_Set_Max_Statistics_Size(_handle.IntPtr, maxStatisticsSize));
561+
GC.KeepAlive(_handle);
562+
return this;
563+
}
564+
552565
private void ApplyDefaults()
553566
{
554567
OnDefaultProperty(DefaultWriterProperties.EnableDictionary, enabled =>
@@ -803,6 +816,9 @@ private static void OnDefaultRefProperty<T>(T? defaultPropertyValue, Action<T> s
803816
[DllImport(ParquetDll.Name)]
804817
private static extern IntPtr WriterPropertiesBuilder_Disable_Store_Decimal_As_Integer(IntPtr builder);
805818

819+
[DllImport(ParquetDll.Name)]
820+
private static extern IntPtr WriterPropertiesBuilder_Set_Max_Statistics_Size(IntPtr builder, ulong maxStatisticsSize);
821+
806822
private readonly ParquetHandle _handle;
807823
}
808824
}

0 commit comments

Comments
 (0)