1

protobuf-net を使用した C# での大きなファイル (20GB) の逆シリアル化中に、"Sub-message not read correctly" Exception. 例外は、20 GB のうち 2 GB を読み取った後に発生します。小さいインスタンスでも同じデータ構造が機能します。

20 MB のデータのシリアル化は正常に機能します。

シリアル化のコード例を次に示します。

            if (File.Exists(filename))
                File.Delete(filename);

            using (FileStream stream = new FileStream(filename, FileMode.Create))
            {
                Serializer.Serialize<HubLabelingData>(stream, data);
                stream.Close();
            }

デシリアライゼーションのコード例を次に示します。

            using (FileStream stream = new FileStream(filename, FileMode.Open))
            {
                data = Serializer.Deserialize<HubLabelingData>(stream);
                stream.Close();
            }

データ構造は次のとおりです (小さなインスタンスでは問題なく動作します)。

[ProtoContract]
public class HubLabelingData
{
    [ProtoMember(1)]
    public HL[] hlf;

    [ProtoMember(2)]
    public HL[] hlb;

    [ProtoMember(3)]
    public NG g;

    [ProtoMember(4)]
    public List<PL> plf;

    [ProtoMember(5)]
    public List<PL> plb;

    [ProtoMember(6)]
    public PHL[] pihlf;

    [ProtoMember(7)]
    public PHL[] pihlb;
}

[ProtoContract]
public class HL
{
    [ProtoMember(1)]
    public int[] l;

    [ProtoMember(2)]
    public double[] d;
}

[ProtoContract]
public class PL
{
    [ProtoMember(1)]
    public Dictionary<int, List<GP>> p;
}

[ProtoContract]
public class PHL
{
    [ProtoMember(1)]
    public short[] l;
}

[ProtoContract]
public class NG
{
    [ProtoMember(1)]
    public NA[] e;

    [ProtoMember(2)]
    public NA[] tne { get; set; }

    [ProtoMember(3)]
    public float[] a;

    [ProtoMember(4)]
    public float[] o;

    [ProtoMember(5)]
    public int num = 0;

}

[ProtoContract]
public class NA
{
    [ProtoMember(1)]
    public int one { get; set; }

    [ProtoMember(2)]
    public int two { get; set; }

    [ProtoMember(3)]
    public double tree { get; set; }

    [ProtoMember(4)]
    public int four { get; set; }

}

[ProtoContract]
public class NN
{
    [ProtoMember(1)]
    public List<NA> nas;

}

[ProtoContract]
public class GP
{
    [ProtoMember(1)]
    public float one { get; set; }

    [ProtoMember(2)]
    public float two { get; set; }

}
4

2 に答える 2

1

同じ問題を抱えているすべての人のために:

Protbuf.net は、2.048 GB を超えるファイル (それぞれのオブジェクト) の逆シリアル化をサポートしていません。

データを複数のメッセージに分割しました。より多くの作業が必要でしたが、完璧に動作します。

于 2013-06-02T16:43:11.870 に答える