Skip to content

[BUG]: Cannot serialize/deserialize byte arrays #761

Description

@anthiras

Library Version

6.0.3

.NET Runtime

.NET 10

OS and Architecture

macOS (Apple Silicon)

How to reproduce?

Run the snippet below which performs serialization and deserialization using the high level API with two sample classes. One class has a byte[] property and fails on serialization, the other has a ReadOnlyMemory<byte> property and fails on deserialization.

Failing test

Program.cs


using Parquet.Serialization;

ByteArrayEvent[] byteArrayEvents = [new() { ByteArray = [1, 2, 3] }];
ByteMemoryEvent[] byteMemoryEvents = [new() { ByteMemory = (ReadOnlyMemory<byte>) new byte[]{1, 2, 3} }];

Console.WriteLine("### Testing byte[] ###");
await TrySerializeDeserialize(byteArrayEvents);
Console.WriteLine("### Testing ReadOnlyMemory<byte> ###");
await TrySerializeDeserialize(byteMemoryEvents);

async Task TrySerializeDeserialize<T>(T[] data) where T : class, new()
{
    try
    {
        await ParquetSerializer.SerializeAsync(data, "data.parquet");
        await ParquetSerializer.DeserializeAsync<T>("data.parquet");
        Console.WriteLine("Success!");
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
    }
}

public class ByteArrayEvent
{
    public byte[] ByteArray { get; set; } // can deserialize, cannot serialize
}

public class ByteMemoryEvent
{
    public ReadOnlyMemory<byte> ByteMemory { get; set; } // can serialize, cannot deserialize
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions