- Timestamp:
- 07/05/19 14:56:37 (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj
r16658 r17087 107 107 </PropertyGroup> 108 108 <ItemGroup> 109 <Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> 110 <SpecificVersion>False</SpecificVersion> 111 <HintPath>..\..\bin\Google.Protobuf.dll</HintPath> 112 <Private>False</Private> 113 </Reference> 109 114 <Reference Include="System" /> 110 115 <Reference Include="System.Configuration" /> -
trunk/HeuristicLab.Clients.Hive/3.3/Plugin.cs.frame
r16658 r17087 41 41 [PluginDependency("HeuristicLab.Optimization", "3.3")] 42 42 [PluginDependency("HeuristicLab.Persistence", "3.3")] 43 [PluginDependency("HeuristicLab.Protobuf", "3.6.1")] 43 44 public class HeuristicLabClientsHivePlugin : PluginBase { 44 45 } -
trunk/HeuristicLab.Clients.Hive/3.3/Util/PersistenceUtil.cs
r16565 r17087 23 23 using System.Collections.Generic; 24 24 using System.IO; 25 using System.IO.Compression; 26 using Google.Protobuf; 25 27 using HEAL.Attic; 26 28 using HeuristicLab.Persistence.Default.Xml; … … 44 46 try { 45 47 return (T)ser.Deserialize(sjob); 46 } catch (Exception) { 47 // retry with old persistence 48 using (MemoryStream memStream = new MemoryStream(sjob)) { 49 return XmlParser.Deserialize<T>(memStream); 48 } catch (PersistenceException e) { 49 // Exceptions may arise because data in Hive was uploaded with former XML-based 50 // persistence or with Attic prior to 1.2. 51 if (e.InnerException is InvalidDataException) { 52 // We assume the data was serialized with HEAL.Attic < 1.2 which did not use 53 // DeflateStream, but as of 1.2 uses DeflateStream by default 54 var compressedData = Compress(sjob); 55 try { 56 // retry with the job's data compressed 57 return (T)ser.Deserialize(compressedData); 58 } catch (PersistenceException e2) { 59 if (e2.InnerException is InvalidProtocolBufferException 60 || e2.InnerException is InvalidDataException) { 61 // retry deserialize original bytes with old persistence 62 return DeserializeWithXmlParser<T>(sjob); 63 } else throw; 64 } 50 65 } 66 if (e.InnerException is InvalidProtocolBufferException) { 67 // We assume the data was not serialized with HEAL.Attic, but with the former 68 // XML-based persistence 69 return DeserializeWithXmlParser<T>(sjob); 70 } else throw; 71 } 72 } 73 74 private static byte[] Compress(byte[] sjob) { 75 using (var memStream = new MemoryStream(sjob.Length)) { 76 using (var deflateStream = new DeflateStream(memStream, CompressionMode.Compress)) { 77 deflateStream.Write(sjob, 0, sjob.Length); 78 } 79 return memStream.ToArray(); 80 } 81 } 82 83 private static T DeserializeWithXmlParser<T>(byte[] sjob) { 84 using (MemoryStream memStream = new MemoryStream(sjob)) { 85 return XmlParser.Deserialize<T>(memStream); 51 86 } 52 87 } -
trunk/HeuristicLab.Optimizer/3.3/StartPage.cs
r17022 r17087 23 23 using System.Collections.Generic; 24 24 using System.IO; 25 using System.IO.Compression;26 25 using System.Linq; 27 26 using System.Reflection; … … 120 119 using (var stream = assembly.GetManifestResourceStream(name)) { 121 120 var serializer = new ProtoBufSerializer(); 122 // TODO remove deflateStream with next release of HEAL.Attic 123 using (var deflateStream = new DeflateStream(stream, CompressionMode.Decompress, true)) { 124 var item = (NamedItem)serializer.Deserialize(deflateStream, false); 125 OnSampleLoaded(item, group, 1.0 / count); 126 } 121 var item = (NamedItem)serializer.Deserialize(stream, false); 122 OnSampleLoaded(item, group, 1.0 / count); 127 123 } 128 124 }
Note: See TracChangeset
for help on using the changeset viewer.