Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/24/15 17:29:09 (9 years ago)
Author:
swagner
Message:

#2520: Worked on new persistence implementation

Location:
branches/PersistenceOverhaul/HeuristicLab.Persistence
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableClassAttribute.cs

    r13367 r13375  
    5959    /// <see cref="StorableClassType.MarkedOnly"/>.
    6060    /// </summary>
    61     public StorableClassAttribute() { }
     61    private StorableClassAttribute() { }
    6262
    6363    /// <summary>
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/StaticCache.cs

    r13367 r13375  
    8585        RegisterExtension(BoolArrayBox.BoolArray);
    8686        RegisterExtension(IntArrayBox.IntArray);
     87        RegisterExtension(LongArrayBox.LongArray);
     88        RegisterExtension(UnsignedIntArrayBox.UnsignedIntArray);
     89        RegisterExtension(UnsignedLongArrayBox.UnsignedLongArray);
     90        RegisterExtension(FloatArrayBox.FloatArray);
     91        RegisterExtension(DoubleArrayBox.DoubleArray);
     92        RegisterExtension(StringArrayBox.StringArray);
    8793        RegisterExtension(MatrixBox.Matrix);
    8894        RegisterExtension(BoolMatrixBox.BoolMatrix);
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Protos/PersistenceMessages.proto

    r13367 r13375  
    8585  repeated int32 values = 1 [packed = true];
    8686}
     87message LongArrayBox {
     88  extend Box {
     89    required LongArrayBox long_array = 122;
     90  }
     91  repeated int64 values = 1 [packed = true];
     92}
     93message UnsignedIntArrayBox {
     94  extend Box {
     95    required UnsignedIntArrayBox unsigned_int_array = 123;
     96  }
     97  repeated uint32 values = 1 [packed = true];
     98}
     99message UnsignedLongArrayBox {
     100  extend Box {
     101    required UnsignedLongArrayBox unsigned_long_array = 124;
     102  }
     103  repeated uint64 values = 1 [packed = true];
     104}
     105message FloatArrayBox {
     106  extend Box {
     107    required FloatArrayBox float_array = 125;
     108  }
     109  repeated float values = 1 [packed = true];
     110}
     111message DoubleArrayBox {
     112  extend Box {
     113    required DoubleArrayBox double_array = 126;
     114  }
     115  repeated double values = 1 [packed = true];
     116}
     117message StringArrayBox {
     118  extend Box {
     119    required StringArrayBox string_array = 127;
     120  }
     121  repeated string values = 1;
     122}
    87123
    88124// matrix boxes
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Transformers/Transformers.cs

    r13367 r13375  
    182182    protected abstract T ToValueType(IEnumerable<int> value, Type type, Mapper mapper);
    183183  }
     184  public abstract class LongArrayBoxTransformer<T> : BoxTransformer<T> {
     185    protected override void Populate(Box.Builder box, T value, Mapper mapper) {
     186      var b = LongArrayBox.CreateBuilder();
     187      b.AddRangeValues(ToBoxType(value, mapper));
     188      box.SetExtension<LongArrayBox>(LongArrayBox.LongArray, b.Build());
     189    }
     190    protected override T Extract(Box box, Type type, Mapper mapper) {
     191      return ToValueType(box.GetExtension(LongArrayBox.LongArray).ValuesList, type, mapper);
     192    }
     193    protected abstract IEnumerable<long> ToBoxType(T value, Mapper mapper);
     194    protected abstract T ToValueType(IEnumerable<long> value, Type type, Mapper mapper);
     195  }
     196  public abstract class UnsignedIntArrayBoxTransformer<T> : BoxTransformer<T> {
     197    protected override void Populate(Box.Builder box, T value, Mapper mapper) {
     198      var b = UnsignedIntArrayBox.CreateBuilder();
     199      b.AddRangeValues(ToBoxType(value, mapper));
     200      box.SetExtension<UnsignedIntArrayBox>(UnsignedIntArrayBox.UnsignedIntArray, b.Build());
     201    }
     202    protected override T Extract(Box box, Type type, Mapper mapper) {
     203      return ToValueType(box.GetExtension(UnsignedIntArrayBox.UnsignedIntArray).ValuesList, type, mapper);
     204    }
     205    protected abstract IEnumerable<uint> ToBoxType(T value, Mapper mapper);
     206    protected abstract T ToValueType(IEnumerable<uint> value, Type type, Mapper mapper);
     207  }
     208  public abstract class UnsignedLongArrayBoxTransformer<T> : BoxTransformer<T> {
     209    protected override void Populate(Box.Builder box, T value, Mapper mapper) {
     210      var b = UnsignedLongArrayBox.CreateBuilder();
     211      b.AddRangeValues(ToBoxType(value, mapper));
     212      box.SetExtension<UnsignedLongArrayBox>(UnsignedLongArrayBox.UnsignedLongArray, b.Build());
     213    }
     214    protected override T Extract(Box box, Type type, Mapper mapper) {
     215      return ToValueType(box.GetExtension(UnsignedLongArrayBox.UnsignedLongArray).ValuesList, type, mapper);
     216    }
     217    protected abstract IEnumerable<ulong> ToBoxType(T value, Mapper mapper);
     218    protected abstract T ToValueType(IEnumerable<ulong> value, Type type, Mapper mapper);
     219  }
     220  public abstract class FloatArrayBoxTransformer<T> : BoxTransformer<T> {
     221    protected override void Populate(Box.Builder box, T value, Mapper mapper) {
     222      var b = FloatArrayBox.CreateBuilder();
     223      b.AddRangeValues(ToBoxType(value, mapper));
     224      box.SetExtension<FloatArrayBox>(FloatArrayBox.FloatArray, b.Build());
     225    }
     226    protected override T Extract(Box box, Type type, Mapper mapper) {
     227      return ToValueType(box.GetExtension(FloatArrayBox.FloatArray).ValuesList, type, mapper);
     228    }
     229    protected abstract IEnumerable<float> ToBoxType(T value, Mapper mapper);
     230    protected abstract T ToValueType(IEnumerable<float> value, Type type, Mapper mapper);
     231  }
     232  public abstract class DoubleArrayBoxTransformer<T> : BoxTransformer<T> {
     233    protected override void Populate(Box.Builder box, T value, Mapper mapper) {
     234      var b = DoubleArrayBox.CreateBuilder();
     235      b.AddRangeValues(ToBoxType(value, mapper));
     236      box.SetExtension<DoubleArrayBox>(DoubleArrayBox.DoubleArray, b.Build());
     237    }
     238    protected override T Extract(Box box, Type type, Mapper mapper) {
     239      return ToValueType(box.GetExtension(DoubleArrayBox.DoubleArray).ValuesList, type, mapper);
     240    }
     241    protected abstract IEnumerable<double> ToBoxType(T value, Mapper mapper);
     242    protected abstract T ToValueType(IEnumerable<double> value, Type type, Mapper mapper);
     243  }
     244  public abstract class StringArrayBoxTransformer<T> : BoxTransformer<T> {
     245    protected override void Populate(Box.Builder box, T value, Mapper mapper) {
     246      var b = StringArrayBox.CreateBuilder();
     247      b.AddRangeValues(ToBoxType(value, mapper));
     248      box.SetExtension<StringArrayBox>(StringArrayBox.StringArray, b.Build());
     249    }
     250    protected override T Extract(Box box, Type type, Mapper mapper) {
     251      return ToValueType(box.GetExtension(StringArrayBox.StringArray).ValuesList, type, mapper);
     252    }
     253    protected abstract IEnumerable<string> ToBoxType(T value, Mapper mapper);
     254    protected abstract T ToValueType(IEnumerable<string> value, Type type, Mapper mapper);
     255  }
    184256  #endregion
    185257
     
    315387    protected override bool[] ToValueType(IEnumerable<bool> value, Type type, Mapper mapper) { return value.ToArray(); }
    316388  }
     389
     390  [Transformer("FF89F6D1-CDE3-498E-9166-F70AC6EB01F1", 301)]
     391  internal sealed class ByteArrayTransformer : UnsignedIntArrayBoxTransformer<byte[]> {
     392    protected override IEnumerable<uint> ToBoxType(byte[] value, Mapper mapper) { return value.Cast<uint>(); }
     393    protected override byte[] ToValueType(IEnumerable<uint> value, Type type, Mapper mapper) { return value.Cast<byte>().ToArray(); }
     394  }
     395
     396  [Transformer("B49B3F2D-2E97-4BAB-8705-8D29DA707C6A", 302)]
     397  internal sealed class SByteArrayTransformer : IntArrayBoxTransformer<sbyte[]> {
     398    protected override IEnumerable<int> ToBoxType(sbyte[] value, Mapper mapper) { return value.Cast<int>(); }
     399    protected override sbyte[] ToValueType(IEnumerable<int> value, Type type, Mapper mapper) { return value.Cast<sbyte>().ToArray(); }
     400  }
     401
     402  [Transformer("2811FDD4-6800-4CBA-86D7-9071ED5775ED", 303)]
     403  internal sealed class ShortArrayTransformer : IntArrayBoxTransformer<short[]> {
     404    protected override IEnumerable<int> ToBoxType(short[] value, Mapper mapper) { return value.Cast<int>(); }
     405    protected override short[] ToValueType(IEnumerable<int> value, Type type, Mapper mapper) { return value.Cast<short>().ToArray(); }
     406  }
     407
     408  [Transformer("1AAC2625-356C-40BC-8CB4-15CB3D047EB8", 304)]
     409  internal sealed class UShortArrayTransformer : UnsignedIntArrayBoxTransformer<ushort[]> {
     410    protected override IEnumerable<uint> ToBoxType(ushort[] value, Mapper mapper) { return value.Cast<uint>(); }
     411    protected override ushort[] ToValueType(IEnumerable<uint> value, Type type, Mapper mapper) { return value.Cast<ushort>().ToArray(); }
     412  }
     413
     414  [Transformer("12F19098-5D49-4C23-8897-69087F1C146D", 305)]
     415  internal sealed class CharArrayTransformer : UnsignedIntArrayBoxTransformer<char[]> {
     416    protected override IEnumerable<uint> ToBoxType(char[] value, Mapper mapper) { return value.Cast<uint>(); }
     417    protected override char[] ToValueType(IEnumerable<uint> value, Type type, Mapper mapper) { return value.Cast<char>().ToArray(); }
     418  }
     419
    317420  [Transformer("5F6DC3BC-4433-4AE9-A636-4BD126F7DACD", 306)]
    318421  internal sealed class IntArrayTransformer : IntArrayBoxTransformer<int[]> {
     
    320423    protected override int[] ToValueType(IEnumerable<int> value, Type type, Mapper mapper) { return value.ToArray(); }
    321424  }
     425
     426  [Transformer("3F10274F-D350-4C82-89EA-A5EB36D4EFCC", 307)]
     427  internal sealed class UIntArrayTransformer : UnsignedIntArrayBoxTransformer<uint[]> {
     428    protected override IEnumerable<uint> ToBoxType(uint[] value, Mapper mapper) { return value; }
     429    protected override uint[] ToValueType(IEnumerable<uint> value, Type type, Mapper mapper) { return value.ToArray(); }
     430  }
     431
     432  [Transformer("E9D550E2-57F7-47F3-803D-37A619DA1A5C", 308)]
     433  internal sealed class LongArrayTransformer : LongArrayBoxTransformer<long[]> {
     434    protected override IEnumerable<long> ToBoxType(long[] value, Mapper mapper) { return value; }
     435    protected override long[] ToValueType(IEnumerable<long> value, Type type, Mapper mapper) { return value.ToArray(); }
     436  }
     437
     438  [Transformer("C02A205B-2176-4282-AC2B-ADEF96DDBE24", 309)]
     439  internal sealed class ULongArrayTransformer : UnsignedLongArrayBoxTransformer<ulong[]> {
     440    protected override IEnumerable<ulong> ToBoxType(ulong[] value, Mapper mapper) { return value; }
     441    protected override ulong[] ToValueType(IEnumerable<ulong> value, Type type, Mapper mapper) { return value.ToArray(); }
     442  }
     443
     444  [Transformer("3C4590D9-C76E-4AFB-98FD-E50D3D051648", 310)]
     445  internal sealed class FloatArrayTransformer : FloatArrayBoxTransformer<float[]> {
     446    protected override IEnumerable<float> ToBoxType(float[] value, Mapper mapper) { return value; }
     447    protected override float[] ToValueType(IEnumerable<float> value, Type type, Mapper mapper) { return value.ToArray(); }
     448  }
     449
     450  [Transformer("FB98C399-9323-4470-9A85-9186C2B2D5D4", 311)]
     451  internal sealed class DoubleArrayTransformer : DoubleArrayBoxTransformer<double[]> {
     452    protected override IEnumerable<double> ToBoxType(double[] value, Mapper mapper) { return value; }
     453    protected override double[] ToValueType(IEnumerable<double> value, Type type, Mapper mapper) { return value.ToArray(); }
     454  }
     455
     456  [Transformer("68332513-9CF1-47FA-A093-6DDB663186EC", 312)]
     457  internal sealed class StringArrayTransformer : StringArrayBoxTransformer<string[]> {
     458    protected override IEnumerable<string> ToBoxType(string[] value, Mapper mapper) { return value; }
     459    protected override string[] ToValueType(IEnumerable<string> value, Type type, Mapper mapper) { return value.ToArray(); }
     460  }
    322461  #endregion
    323462}
Note: See TracChangeset for help on using the changeset viewer.