遇到使用PowerShell内部的Microsoft.Hadoop.Avro库反序列化avro的问题

时间:2015-12-30 23:37:27

标签: json powershell serialization deserialization avro

我正在尝试使用可在此处找到的Microsoft.Hadoop.Avro库反序列化二进制avro文件。

https://azure.microsoft.com/en-us/documentation/articles/hdinsight-dotnet-avro-serialization/

我没有在C#应用程序中使用库,而是使用Powershell来尝试反序列化。最初我导入Hadoop库以及依赖的Newtonsoft.json库。我通过使用Add-Type cmdlet执行此操作。完全没问题。尝试在源avro文件流上调用AvroSerializer类的Deserialize方法后,问题就出现了。以下是调用链的脚本,并在尝试反序列化avro文件流时返回异常。

**********************
Windows PowerShell transcript start
Start time: 20151230104411
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 5520
PSVersion: 5.0.10586.0
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0.10586.0
BuildVersion: 10.0.10586.0
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\Users\mbird\Documents\PowerShell_transcript.BIRDSP3.eEl7IzKT.20151230104411.txt
PS C:\Users\mbird> $reader =  [Microsoft.Hadoop.Avro.AvroSerializer]::CreateGeneric($json)
PS C:\Users\mbird> $fileStream =New-Object System.IO.FileStream("C:\Users\mbird\Downloads\created.avro",[System.IO.FileMode]::Open,[System.IO.FileAccess]::Read)
PS C:\Users\mbird> $reader.Deserialize($fileStream)
Exception calling "Deserialize" with "1" argument(s): "Array dimensions exceeded supported range."
At line:1 char:1
+ $reader.Deserialize($fileStream)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : OverflowException
Exception calling "Deserialize" with "1" argument(s): "Array dimensions exceeded supported range."
At line:1 char:1
+ $reader.Deserialize($fileStream)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : OverflowException

PS C:\Users\mbird> Stop-Transcript
**********************
Windows PowerShell transcript end
End time: 20151230104449
**********************

我无法弄清楚我在这里做错了什么。

0 个答案:

没有答案