Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing dispose of RowGroupMetaData in RowGroupReader? #322

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cquery.cacheDirectory": "${workspaceFolder}/.vscode/cquery_cached_index/"
}
5 changes: 5 additions & 0 deletions cpp/RowGroupMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ using namespace parquet;

extern "C"
{
PARQUETSHARP_EXPORT void RowGroupMetaData_Free(const RowGroupMetaData* row_group_meta_data)
{
delete row_group_meta_data;
}

PARQUETSHARP_EXPORT ExceptionInfo* RowGroupMetaData_Get_Column_Chunk_Meta_Data(const RowGroupMetaData* row_group_meta_data, int i, ColumnChunkMetaData** column_chunk_meta_data)
{
TRYCATCH(*column_chunk_meta_data = row_group_meta_data->ColumnChunk(i).release();)
Expand Down
5 changes: 5 additions & 0 deletions cpp/SchemaDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ using namespace parquet;

extern "C"
{
PARQUETSHARP_EXPORT void SchemaDescriptor_Free(const SchemaDescriptor* descriptor)
{
delete descriptor;
}

PARQUETSHARP_EXPORT ExceptionInfo* SchemaDescriptor_Column(const SchemaDescriptor* descriptor, int i, const ColumnDescriptor** column_descriptor)
{
TRYCATCH(*column_descriptor = descriptor->Column(i);)
Expand Down
15 changes: 12 additions & 3 deletions csharp/RowGroupMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@

namespace ParquetSharp
{
public sealed class RowGroupMetaData
public sealed class RowGroupMetaData : IDisposable
{
internal RowGroupMetaData(IntPtr handle)
{
_handle = handle;
_handle = new ParquetHandle(handle, RowGroupMetaData_Free);
}

public void Dispose()
{
_schema?.Dispose();
_handle.Dispose();
}

public int NumColumns => ExceptionInfo.Return<int>(_handle, RowGroupMetaData_Num_Columns);
Expand Down Expand Up @@ -35,7 +41,10 @@ public ColumnChunkMetaData GetColumnChunkMetaData(int i)
[DllImport(ParquetDll.Name)]
private static extern IntPtr RowGroupMetaData_Total_Byte_Size(IntPtr rowGroupMetaData, out long totalByteSize);

private readonly IntPtr _handle;
[DllImport(ParquetDll.Name)]
private static extern void RowGroupMetaData_Free(IntPtr rowGroupMetaData);

private readonly ParquetHandle _handle;
private SchemaDescriptor? _schema;
}
}
1 change: 1 addition & 0 deletions csharp/RowGroupReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal RowGroupReader(IntPtr handle, ParquetFileReader parquetFileReader)

public void Dispose()
{
_metaData?.Dispose();
_handle.Dispose();
}

Expand Down
14 changes: 11 additions & 3 deletions csharp/SchemaDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

namespace ParquetSharp
{
public sealed class SchemaDescriptor
public sealed class SchemaDescriptor : IDisposable
{
internal SchemaDescriptor(IntPtr schemaDescriptorHandle)
{
_handle = schemaDescriptorHandle;
_handle = new ParquetHandle(schemaDescriptorHandle, SchemaDescriptor_Free);
}

public void Dispose()
{
_handle.Dispose();
}

public GroupNode GroupNode => (GroupNode) (Node.Create(ExceptionInfo.Return<IntPtr>(_handle, SchemaDescriptor_Group_Node)) ?? throw new InvalidOperationException());
Expand Down Expand Up @@ -38,6 +43,9 @@ public Node ColumnRoot(int i)
return Node.Create(ExceptionInfo.Return<int, IntPtr>(_handle, i, SchemaDescriptor_Get_Column_Root)) ?? throw new InvalidOperationException();
}

[DllImport(ParquetDll.Name)]
private static extern void SchemaDescriptor_Free(IntPtr descriptor);

[DllImport(ParquetDll.Name)]
private static extern IntPtr SchemaDescriptor_Column(IntPtr descriptor, int i, out IntPtr columnDescriptor);

Expand All @@ -62,6 +70,6 @@ public Node ColumnRoot(int i)
[DllImport(ParquetDll.Name)]
private static extern IntPtr SchemaDescriptor_Schema_Root(IntPtr descriptor, out IntPtr schemaRoot);

private readonly IntPtr _handle;
private readonly ParquetHandle _handle;
}
}