From 36e8ccdb346d5c51a31820882f9d6e2c22ed6a5a Mon Sep 17 00:00:00 2001 From: Juan Escalada <97265671+jescalada@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:37:47 +0900 Subject: [PATCH] Documentation improvements: Encryption (#494) --- csharp/Arrow/FileReader.cs | 2 +- csharp/ColumnChunkMetaData.cs | 43 +++++++++++++++++ csharp/ColumnCryptoMetaData.cs | 22 ++++++++- csharp/ColumnDecryptionProperties.cs | 6 +++ csharp/ColumnDecryptionPropertiesBuilder.cs | 20 +++++++- csharp/ColumnEncryptionPropertiesBuilder.cs | 30 +++++++++++- csharp/FileDecryptionPropertiesBuilder.cs | 43 ++++++++++++++++- csharp/FileEncryptionProperties.cs | 23 ++++++++++ csharp/FileEncryptionPropertiesBuilder.cs | 51 ++++++++++++++++++++- csharp/IO/BufferOutputStream.cs | 11 +++++ csharp/IO/BufferReader.cs | 4 ++ csharp/IO/ResizableBuffer.cs | 12 +++++ csharp/RowGroupMetaData.cs | 28 +++++++++++ 13 files changed, 289 insertions(+), 6 deletions(-) diff --git a/csharp/Arrow/FileReader.cs b/csharp/Arrow/FileReader.cs index 0863ef57..ed5ff66b 100644 --- a/csharp/Arrow/FileReader.cs +++ b/csharp/Arrow/FileReader.cs @@ -8,7 +8,7 @@ namespace ParquetSharp.Arrow { /// - /// Reads Parquet files using the Arrow format + /// Reads Parquet files using the Arrow format. /// public class FileReader : IDisposable { diff --git a/csharp/ColumnChunkMetaData.cs b/csharp/ColumnChunkMetaData.cs index f8ac795e..51f70ed9 100644 --- a/csharp/ColumnChunkMetaData.cs +++ b/csharp/ColumnChunkMetaData.cs @@ -3,6 +3,14 @@ namespace ParquetSharp { + /// + /// Represents the metadata for a column chunk. + /// + /// + /// Provides access to the metadata for a column chunk and manages the associated native resources. + /// Because this class is a wrapper around C++ objects, it implements to release resources predictably. + /// Make sure to call or use a `using` statement for proper cleanup. + /// public sealed class ColumnChunkMetaData : IDisposable { internal ColumnChunkMetaData(IntPtr handle) @@ -15,8 +23,16 @@ public void Dispose() _handle.Dispose(); } + /// + /// Get the compression codec used for the column chunk. + /// + /// A value representing the compression codec used for the column chunk. public Compression Compression => ExceptionInfo.Return(_handle, ColumnChunkMetaData_Compression); + /// + /// Get the encryption metadata associated with the column. + /// + /// A object representing the encryption metadata for the column, or if no encryption metadata is available. public ColumnCryptoMetaData? CryptoMetadata { get @@ -26,6 +42,10 @@ public ColumnCryptoMetaData? CryptoMetadata } } + /// + /// Get the encodings used for the column chunk. + /// + /// An array of values representing the encodings used for the column chunk. public unsafe Encoding[] Encodings { get @@ -43,12 +63,35 @@ public unsafe Encoding[] Encodings } } + /// + /// Get the offset of the column chunk in the file. + /// public long FileOffset => ExceptionInfo.Return(_handle, ColumnChunkMetaData_File_Offset); + /// + /// Whether the column chunk statistics are present in the metadata. + /// public bool IsStatsSet => ExceptionInfo.Return(_handle, ColumnChunkMetaData_Is_Stats_Set); + /// + /// Get the total number of values in the column chunk. + /// public long NumValues => ExceptionInfo.Return(_handle, ColumnChunkMetaData_Num_Values); + /// + /// Get the total compressed size of the column chunk in bytes. + /// public long TotalCompressedSize => ExceptionInfo.Return(_handle, ColumnChunkMetaData_Total_Compressed_Size); + /// + /// Get the total uncompressed size of the column chunk in bytes. + /// public long TotalUncompressedSize => ExceptionInfo.Return(_handle, ColumnChunkMetaData_Total_Uncompressed_Size); + /// + /// Get the statistics for the column chunk. + /// + /// A object representing the statistics for the column chunk, or if no statistics are available. public Statistics? Statistics => Statistics.Create(ExceptionInfo.Return(_handle, ColumnChunkMetaData_Statistics)); + /// + /// Get the physical type of the column chunk. + /// + /// A value representing the physical type of the column chunk. public PhysicalType Type => ExceptionInfo.Return(_handle, ColumnChunkMetaData_Type); [DllImport(ParquetDll.Name)] diff --git a/csharp/ColumnCryptoMetaData.cs b/csharp/ColumnCryptoMetaData.cs index 22b43ae2..e97bb5c6 100644 --- a/csharp/ColumnCryptoMetaData.cs +++ b/csharp/ColumnCryptoMetaData.cs @@ -5,8 +5,13 @@ namespace ParquetSharp { /// - /// Metadata related to the encryption/decryption of a column. + /// Represents metadata related to the encryption and decryption of a Parquet column. + /// Provides access to encryption-specific properties for a column and manages the associated native resources. /// + /// + /// Because this class is a wrapper around C++ objects, it implements to release resources predictably. + /// Make sure to call or use a `using` statement for proper cleanup. + /// public sealed class ColumnCryptoMetaData : IDisposable { internal ColumnCryptoMetaData(IntPtr handle) @@ -19,8 +24,23 @@ public void Dispose() _handle.Dispose(); } + /// + /// Get the path in the schema that specifies the column. + /// + /// A that specifies the column's path in the schema. public ColumnPath ColumnPath => new ColumnPath(ExceptionInfo.Return(_handle, ColumnCryptoMetaData_Path_In_Schema)); + + /// + /// Whether the column is encrypted with the footer key. + /// + /// + /// if the column is encrypted with the footer key; otherwise, . + /// public bool EncryptedWithFooterKey => ExceptionInfo.Return(_handle, ColumnCryptoMetaData_Encrypted_With_Footer_Key); + + /// + /// Get the key metadata associated with the column. + /// public string KeyMetadata => ExceptionInfo.ReturnString(_handle, ColumnCryptoMetaData_Key_Metadata); [DllImport(ParquetDll.Name)] diff --git a/csharp/ColumnDecryptionProperties.cs b/csharp/ColumnDecryptionProperties.cs index a4bab739..56033601 100644 --- a/csharp/ColumnDecryptionProperties.cs +++ b/csharp/ColumnDecryptionProperties.cs @@ -18,7 +18,13 @@ public void Dispose() Handle.Dispose(); } + /// + /// Get the path of the column to decrypt. + /// public string ColumnPath => ExceptionInfo.ReturnString(Handle, ColumnDecryptionProperties_Column_Path, ColumnDecryptionProperties_Column_Path_Free); + /// + /// Get the key used to decrypt the column. + /// public byte[] Key => ExceptionInfo.Return(Handle, ColumnDecryptionProperties_Key).ToBytes(); public ColumnDecryptionProperties DeepClone() => new ColumnDecryptionProperties(ExceptionInfo.Return(Handle, ColumnDecryptionProperties_Deep_Clone)); diff --git a/csharp/ColumnDecryptionPropertiesBuilder.cs b/csharp/ColumnDecryptionPropertiesBuilder.cs index 02509dc0..4eeba7b5 100644 --- a/csharp/ColumnDecryptionPropertiesBuilder.cs +++ b/csharp/ColumnDecryptionPropertiesBuilder.cs @@ -5,15 +5,24 @@ namespace ParquetSharp { /// - /// Builder pattern for ColumnDecryptionProperties. + /// Builder pattern for creating and configuring objects. + /// Provides a fluent API for setting the decryption properties for a column in a Parquet file. /// public sealed class ColumnDecryptionPropertiesBuilder : IDisposable { + /// + /// Initializes a new instance of the class for a column specified by name. + /// + /// The name of the column to decrypt. public ColumnDecryptionPropertiesBuilder(string columnName) : this(Make(columnName)) { } + /// + /// Initializes a new instance of the class for a column specified by path. + /// + /// The object representing the column to decrypt. public ColumnDecryptionPropertiesBuilder(ColumnPath columnPath) : this(Make(columnPath)) { @@ -29,6 +38,11 @@ public void Dispose() _handle.Dispose(); } + /// + /// Set the decryption key for the column. + /// + /// A byte array containing the AES decryption key. + /// This builder instance. public ColumnDecryptionPropertiesBuilder Key(byte[] key) { var aesKey = new AesKey(key); @@ -37,6 +51,10 @@ public ColumnDecryptionPropertiesBuilder Key(byte[] key) return this; } + /// + /// Build the object. + /// + /// The configured object. public ColumnDecryptionProperties Build() => new ColumnDecryptionProperties(ExceptionInfo.Return(_handle, ColumnDecryptionPropertiesBuilder_Build)); private static IntPtr Make(string columnName) diff --git a/csharp/ColumnEncryptionPropertiesBuilder.cs b/csharp/ColumnEncryptionPropertiesBuilder.cs index 65b8ed39..d43bb803 100644 --- a/csharp/ColumnEncryptionPropertiesBuilder.cs +++ b/csharp/ColumnEncryptionPropertiesBuilder.cs @@ -5,15 +5,24 @@ namespace ParquetSharp { /// - /// Builder pattern for ColumnEncryptionProperties. + /// Builder pattern for creating and configuring objects. + /// Provides a fluent API for setting the encryption properties for a column in a Parquet file. /// public sealed class ColumnEncryptionPropertiesBuilder : IDisposable { + /// + /// Initializes a new instance of the class for a column specified by name. + /// + /// The name of the column to encrypt. public ColumnEncryptionPropertiesBuilder(string columnName) : this(Make(columnName)) { } + /// + /// Initializes a new instance of the class for a column specified by path. + /// + /// The object representing the column to encrypt. public ColumnEncryptionPropertiesBuilder(ColumnPath columnPath) : this(Make(columnPath)) { @@ -29,6 +38,11 @@ public void Dispose() _handle.Dispose(); } + /// + /// Set the encryption key for the column. + /// + /// A byte array containing the AES encryption key. + /// This builder instance. public ColumnEncryptionPropertiesBuilder Key(byte[] key) { var aesKey = new AesKey(key); @@ -37,6 +51,11 @@ public ColumnEncryptionPropertiesBuilder Key(byte[] key) return this; } + /// + /// Set the metadata associated with the encryption key for the column. + /// + /// A string containing the metadata associated with the encryption key. + /// This builder instance. public ColumnEncryptionPropertiesBuilder KeyMetadata(string keyMetadata) { ExceptionInfo.Check(ColumnEncryptionPropertiesBuilder_Key_Metadata(_handle.IntPtr, keyMetadata)); @@ -44,6 +63,11 @@ public ColumnEncryptionPropertiesBuilder KeyMetadata(string keyMetadata) return this; } + /// + /// Set the key ID associated with the column's encryption key. + /// + /// An identifier for the encryption key. + /// This builder instance. public ColumnEncryptionPropertiesBuilder KeyId(string keyId) { ExceptionInfo.Check(ColumnEncryptionPropertiesBuilder_Key_Id(_handle.IntPtr, keyId)); @@ -51,6 +75,10 @@ public ColumnEncryptionPropertiesBuilder KeyId(string keyId) return this; } + /// + /// Builds the object. + /// + /// The configured object. public ColumnEncryptionProperties Build() => new ColumnEncryptionProperties(ExceptionInfo.Return(_handle, ColumnEncryptionPropertiesBuilder_Build)); private static IntPtr Make(string columnName) diff --git a/csharp/FileDecryptionPropertiesBuilder.cs b/csharp/FileDecryptionPropertiesBuilder.cs index 3fc86230..290d82e4 100644 --- a/csharp/FileDecryptionPropertiesBuilder.cs +++ b/csharp/FileDecryptionPropertiesBuilder.cs @@ -5,10 +5,14 @@ namespace ParquetSharp { /// - /// Builder pattern for FileDecryptionProperties. + /// Builder pattern for creating and configuring a object. + /// Provides a fluent API for setting the decryption properties (footer key, encryption algorithm, etc.) for a Parquet file. /// public sealed class FileDecryptionPropertiesBuilder : IDisposable { + /// + /// Create a new . + /// public FileDecryptionPropertiesBuilder() { ExceptionInfo.Check(FileDecryptionPropertiesBuilder_Create(out var handle)); @@ -20,6 +24,11 @@ public void Dispose() _handle.Dispose(); } + /// + /// Set the footer key used to decrypt the file. + /// + /// An array of bytes used to decrypt the footer. + /// This builder instance. public FileDecryptionPropertiesBuilder FooterKey(byte[] footerKey) { var footerAesKey = new AesKey(footerKey); @@ -28,6 +37,11 @@ public FileDecryptionPropertiesBuilder FooterKey(byte[] footerKey) return this; } + /// + /// Set the keys used to decrypt the columns. + /// + /// An array of objects. + /// This builder instance. public FileDecryptionPropertiesBuilder ColumnKeys(ColumnDecryptionProperties[] columnDecryptionProperties) { var handles = columnDecryptionProperties.Select(p => p.Handle.IntPtr).ToArray(); @@ -37,6 +51,11 @@ public FileDecryptionPropertiesBuilder ColumnKeys(ColumnDecryptionProperties[] c return this; } + /// + /// Set the prefix verifier used to verify the additional authenticated data (AAD) prefix. + /// + /// An object that provides a callback to verify the AAD prefix. + /// This builder instance. public FileDecryptionPropertiesBuilder AadPrefixVerifier(AadPrefixVerifier aadPrefixVerifier) { var gcHandle = aadPrefixVerifier?.CreateGcHandle() ?? IntPtr.Zero; @@ -62,6 +81,11 @@ public FileDecryptionPropertiesBuilder AadPrefixVerifier(AadPrefixVerifier aadPr return this; } + /// + /// Set the key retriever used to retrieve the decryption keys. + /// + /// A object that provides a callback to retrieve the decryption keys. + /// This builder instance. public FileDecryptionPropertiesBuilder KeyRetriever(DecryptionKeyRetriever keyRetriever) { var gcHandle = keyRetriever?.CreateGcHandle() ?? IntPtr.Zero; @@ -87,6 +111,10 @@ public FileDecryptionPropertiesBuilder KeyRetriever(DecryptionKeyRetriever keyRe return this; } + /// + /// Disable footer signature verification. + /// + /// This builder instance. public FileDecryptionPropertiesBuilder DisableFooterSignatureVerification() { ExceptionInfo.Check(FileDecryptionPropertiesBuilder_Disable_Footer_Signature_Verification(_handle.IntPtr)); @@ -94,6 +122,11 @@ public FileDecryptionPropertiesBuilder DisableFooterSignatureVerification() return this; } + /// + /// Set the additional authenticated data (AAD) prefix. + /// + /// A string representing the AAD prefix. + /// This builder instance. public FileDecryptionPropertiesBuilder AadPrefix(string aadPrefix) { ExceptionInfo.Check(FileDecryptionPropertiesBuilder_Aad_Prefix(_handle.IntPtr, aadPrefix)); @@ -101,6 +134,10 @@ public FileDecryptionPropertiesBuilder AadPrefix(string aadPrefix) return this; } + /// + /// Allow plaintext (unencrypted) files. + /// + /// This builder instance. public FileDecryptionPropertiesBuilder PlaintextFilesAllowed() { ExceptionInfo.Check(FileDecryptionPropertiesBuilder_Plaintext_Files_Allowed(_handle.IntPtr)); @@ -108,6 +145,10 @@ public FileDecryptionPropertiesBuilder PlaintextFilesAllowed() return this; } + /// + /// Build the object. + /// + /// A new object with the configured decryption properties. public FileDecryptionProperties Build() => new FileDecryptionProperties(ExceptionInfo.Return(_handle, FileDecryptionPropertiesBuilder_Build)); [DllImport(ParquetDll.Name)] diff --git a/csharp/FileEncryptionProperties.cs b/csharp/FileEncryptionProperties.cs index dcbd289d..b15fcc84 100644 --- a/csharp/FileEncryptionProperties.cs +++ b/csharp/FileEncryptionProperties.cs @@ -18,12 +18,32 @@ public void Dispose() Handle.Dispose(); } + /// + /// Get a boolean indicating whether the footer is encrypted. + /// public bool EncryptedFooter => ExceptionInfo.Return(Handle, FileEncryptionProperties_Encrypted_Footer); + //public EncryptionAlgorithm Algorithm => TODO + + /// + /// Get the footer key used to encrypt the footer. + /// + /// A byte array representing the footer key. public byte[] FooterKey => ExceptionInfo.Return(Handle, FileEncryptionProperties_Footer_Key).ToBytes(); + /// + /// Get the metadata associated with the footer key. + /// public string FooterKeyMetadata => ExceptionInfo.ReturnString(Handle, FileEncryptionProperties_Footer_Key_Metadata, FileEncryptionProperties_Footer_Key_Metadata_Free); + /// + /// Get the additional authenticated data (AAD) used to encrypt the file. + /// public string FileAad => ExceptionInfo.ReturnString(Handle, FileEncryptionProperties_File_Aad, FileEncryptionProperties_File_Aad_Free); + /// + /// Get the column encryption properties for a specific column. + /// + /// The path that specifies the column. + /// The column encryption properties for the specified column, or if the column is not encrypted. public ColumnEncryptionProperties? ColumnEncryptionProperties(string columnPath) { var columnHandle = ExceptionInfo.Return( @@ -31,6 +51,9 @@ public void Dispose() return columnHandle == IntPtr.Zero ? null : new ColumnEncryptionProperties(columnHandle); } + /// + /// Create a deep clone of the file encryption properties object. + /// public FileEncryptionProperties DeepClone() => new FileEncryptionProperties(ExceptionInfo.Return(Handle, FileEncryptionProperties_Deep_Clone)); [DllImport(ParquetDll.Name)] diff --git a/csharp/FileEncryptionPropertiesBuilder.cs b/csharp/FileEncryptionPropertiesBuilder.cs index 77960f93..3faf8781 100644 --- a/csharp/FileEncryptionPropertiesBuilder.cs +++ b/csharp/FileEncryptionPropertiesBuilder.cs @@ -5,10 +5,15 @@ namespace ParquetSharp { /// - /// Builder pattern for FileEncryptionProperties. + /// Builder pattern for creating and configuring a object. + /// Provides a fluent API for setting the encryption properties (footer key, encryption algorithm, etc.) for a Parquet file. /// public sealed class FileEncryptionPropertiesBuilder : IDisposable { + /// + /// Create a new with a footer key. + /// + /// An array of bytes used to encrypt the footer. public FileEncryptionPropertiesBuilder(byte[] footerKey) { var footerAesKey = new AesKey(footerKey); @@ -21,6 +26,10 @@ public void Dispose() _handle.Dispose(); } + /// + /// Set the footer to be in plaintext, i.e., not encrypted. + /// + /// This builder instance. public FileEncryptionPropertiesBuilder SetPlaintextFooter() { ExceptionInfo.Check(FileEncryptionPropertiesBuilder_Set_Plaintext_Footer(_handle.IntPtr)); @@ -28,6 +37,11 @@ public FileEncryptionPropertiesBuilder SetPlaintextFooter() return this; } + /// + /// Set the encryption algorithm. + /// + /// A value representing the encryption algorithm. + /// This builder instance. public FileEncryptionPropertiesBuilder Algorithm(ParquetCipher parquetCipher) { ExceptionInfo.Check(FileEncryptionPropertiesBuilder_Algorithm(_handle.IntPtr, parquetCipher)); @@ -35,6 +49,15 @@ public FileEncryptionPropertiesBuilder Algorithm(ParquetCipher parquetCipher) return this; } + /// + /// Set the key ID associated to the footer key. + /// + /// A unique identifier for the footer key. + /// This builder instance. + /// + /// Key IDs help identify and manage encryption keys, helpful when multiple keys are in use. + /// This value is typically stored in key management systems. + /// public FileEncryptionPropertiesBuilder FooterKeyId(string footerKeyId) { ExceptionInfo.Check(FileEncryptionPropertiesBuilder_Footer_Key_Id(_handle.IntPtr, footerKeyId)); @@ -42,6 +65,11 @@ public FileEncryptionPropertiesBuilder FooterKeyId(string footerKeyId) return this; } + /// + /// Set the metadata for the footer key. + /// + /// A string containing metadata for the footer key. + /// This builder instance. public FileEncryptionPropertiesBuilder FooterKeyMetadata(string footerKeyMetadata) { ExceptionInfo.Check(FileEncryptionPropertiesBuilder_Footer_Key_Metadata(_handle.IntPtr, footerKeyMetadata)); @@ -49,6 +77,11 @@ public FileEncryptionPropertiesBuilder FooterKeyMetadata(string footerKeyMetadat return this; } + /// + /// Set the additional authenticated data (AAD) prefix. + /// + /// A string representing the AAD prefix. + /// This builder instance. public FileEncryptionPropertiesBuilder AadPrefix(string aadPrefix) { ExceptionInfo.Check(FileEncryptionPropertiesBuilder_Aad_Prefix(_handle.IntPtr, aadPrefix)); @@ -56,6 +89,13 @@ public FileEncryptionPropertiesBuilder AadPrefix(string aadPrefix) return this; } + /// + /// Disable AAD prefix storage in the file. + /// + /// This builder instance. + /// + /// Disabling AAD prefix storage will prevent the AAD prefix from being stored in the file. + /// public FileEncryptionPropertiesBuilder DisableAadPrefixStorage() { ExceptionInfo.Check(FileEncryptionPropertiesBuilder_Disable_Aad_Prefix_Storage(_handle.IntPtr)); @@ -63,6 +103,11 @@ public FileEncryptionPropertiesBuilder DisableAadPrefixStorage() return this; } + /// + /// Set which columns in the Parquet file to encrypt. + /// + /// An array of objects representing the columns to be encrypted. + /// This builder instance. public FileEncryptionPropertiesBuilder EncryptedColumns(ColumnEncryptionProperties[] columnEncryptionProperties) { var handles = columnEncryptionProperties.Select(p => p.Handle.IntPtr).ToArray(); @@ -72,6 +117,10 @@ public FileEncryptionPropertiesBuilder EncryptedColumns(ColumnEncryptionProperti return this; } + /// + /// Build the object. + /// + /// The configured object. public FileEncryptionProperties Build() => new FileEncryptionProperties(ExceptionInfo.Return(_handle, FileEncryptionPropertiesBuilder_Build)); [DllImport(ParquetDll.Name)] diff --git a/csharp/IO/BufferOutputStream.cs b/csharp/IO/BufferOutputStream.cs index 2f5854cd..05134544 100644 --- a/csharp/IO/BufferOutputStream.cs +++ b/csharp/IO/BufferOutputStream.cs @@ -8,16 +8,27 @@ namespace ParquetSharp.IO /// public sealed class BufferOutputStream : OutputStream { + /// + /// Create a new buffer output stream. + /// public BufferOutputStream() : base(ExceptionInfo.Return(BufferOutputStream_Create)) { } + /// + /// Create a new buffer output stream from a resizable buffer. + /// + /// The resizable buffer to write to. public BufferOutputStream(ResizableBuffer resizableBuffer) : base(ExceptionInfo.Return(resizableBuffer.Handle, BufferOutputStream_Create_From_ResizableBuffer)) { } + /// + /// Finish writing to the buffer and return the buffer. + /// + /// The buffer containing the written data. public Buffer Finish() { return new Buffer(ExceptionInfo.Return(Handle!, BufferOutputStream_Finish)); diff --git a/csharp/IO/BufferReader.cs b/csharp/IO/BufferReader.cs index 1f0c74b5..97c295eb 100644 --- a/csharp/IO/BufferReader.cs +++ b/csharp/IO/BufferReader.cs @@ -8,6 +8,10 @@ namespace ParquetSharp.IO /// public sealed class BufferReader : RandomAccessFile { + /// + /// Create a new buffer reader from a buffer. + /// + /// A to read from. public BufferReader(Buffer buffer) : base(ExceptionInfo.Return(buffer.Handle, BufferReader_Create)) { diff --git a/csharp/IO/ResizableBuffer.cs b/csharp/IO/ResizableBuffer.cs index fb00b04c..1d355a4d 100644 --- a/csharp/IO/ResizableBuffer.cs +++ b/csharp/IO/ResizableBuffer.cs @@ -8,11 +8,19 @@ namespace ParquetSharp.IO /// public sealed class ResizableBuffer : Buffer { + /// + /// Create a new resizable buffer with the given initial size. + /// + /// The initial size of the buffer in bytes. public ResizableBuffer(long initialSize = 128L) : base(ExceptionInfo.Return(initialSize, ResizableBuffer_Create)) { } + /// + /// Create a new resizable buffer from a non-owned pointer. + /// + /// The pointer to the buffer. internal static ResizableBuffer FromNonOwnedPtr(IntPtr handle) { return new ResizableBuffer(new ParquetHandle(handle, _ => { })); @@ -22,6 +30,10 @@ private ResizableBuffer(ParquetHandle handle) : base(handle) { } + /// + /// Resize the buffer to the given size. + /// + /// The new size of the buffer in bytes. internal void Resize(long newSize) { ExceptionInfo.Check(ResizableBuffer_Resize(Handle.IntPtr, newSize)); diff --git a/csharp/RowGroupMetaData.cs b/csharp/RowGroupMetaData.cs index 48c1936e..e4225149 100644 --- a/csharp/RowGroupMetaData.cs +++ b/csharp/RowGroupMetaData.cs @@ -3,6 +3,13 @@ namespace ParquetSharp { + /// + /// Represents the metadata for a row group in a Parquet file. + /// + /// + /// A row group is a logical horizontal partition of a Parquet file that contains a set of column chunks. + /// This class provides information about the columns and rows in the row group. + /// public sealed class RowGroupMetaData { internal RowGroupMetaData(IntPtr handle) @@ -10,11 +17,32 @@ internal RowGroupMetaData(IntPtr handle) _handle = handle; } + /// + /// Get the number of columns in the row group. + /// public int NumColumns => ExceptionInfo.Return(_handle, RowGroupMetaData_Num_Columns); + /// + /// Get the number of rows in the row group. + /// public long NumRows => ExceptionInfo.Return(_handle, RowGroupMetaData_Num_Rows); + /// + /// Get the schema descriptor for the row group. + /// + /// A object that describes the schema of the row group. public SchemaDescriptor Schema => _schema ??= new SchemaDescriptor(ExceptionInfo.Return(_handle, RowGroupMetaData_Schema)); + /// + /// Get the total size of the row group in bytes. + /// public long TotalByteSize => ExceptionInfo.Return(_handle, RowGroupMetaData_Total_Byte_Size); + /// + /// Get the metadata for the column chunk at the specified index. + /// + /// The index of the column chunk. + /// The metadata for the column chunk. + /// + /// Column chunks are stored in the same order as the columns in the schema. + /// public ColumnChunkMetaData GetColumnChunkMetaData(int i) { return new ColumnChunkMetaData(ExceptionInfo.Return(_handle, i, RowGroupMetaData_Get_Column_Chunk_Meta_Data));