Package com.esotericsoftware.kryo.serializers

Examples of com.esotericsoftware.kryo.serializers.MapSerializer


    stuff.put("key", "value");
    stuff.put("something", 456);
    stuff.put("self", stuff);

    Kryo kryo = new Kryo();
    kryo.addDefaultSerializer(Stuff.class, new MapSerializer() {
      public void write (Kryo kryo, Output output, Map object) {
        kryo.writeObjectOrNull(output, ((Stuff)object).ordering, Ordering.class);
        super.write(kryo, output, object);
      }
View Full Code Here


    map.put("789", "abc");
    roundTrip(18, 21, map);
    roundTrip(2, 5, new LinkedHashMap());
    roundTrip(18, 21, new LinkedHashMap(map));

    MapSerializer serializer = new MapSerializer();
    kryo.register(HashMap.class, serializer);
    kryo.register(LinkedHashMap.class, serializer);
    serializer.setKeyClass(String.class, kryo.getSerializer(String.class));
    serializer.setKeysCanBeNull(false);
    serializer.setValueClass(String.class, kryo.getSerializer(String.class));
    roundTrip(14, 17, map);
    serializer.setValuesCanBeNull(false);
    roundTrip(14, 17, map);
  }
View Full Code Here

    Random random = new Random();
    for (int i = 0; i < inserts; i++)
      map.put(random.nextLong(), random.nextBoolean());

    Kryo kryo = new Kryo();
    kryo.register(HashMap.class, new MapSerializer());
    kryo.register(ConcurrentHashMap.class, new MapSerializer());

    Output output = new Output(2048, -1);
    kryo.writeClassAndObject(output, map);
    output.close();
View Full Code Here

    map.put("789", "abc");
    roundTrip(18, 21, map);
    roundTrip(2, 5, new LinkedHashMap());
    roundTrip(18, 21, new LinkedHashMap(map));

    MapSerializer serializer = new MapSerializer();
    kryo.register(HashMap.class, serializer);
    kryo.register(LinkedHashMap.class, serializer);
    serializer.setKeyClass(String.class, kryo.getSerializer(String.class));
    serializer.setKeysCanBeNull(false);
    serializer.setValueClass(String.class, kryo.getSerializer(String.class));
    roundTrip(14, 17, map);
    serializer.setValuesCanBeNull(false);
    roundTrip(14, 17, map);
  }
View Full Code Here

    Random random = new Random();
    for (int i = 0; i < inserts; i++)
      map.put(random.nextLong(), random.nextBoolean());

    Kryo kryo = new Kryo();
    kryo.register(HashMap.class, new MapSerializer());
    kryo.register(ConcurrentHashMap.class, new MapSerializer());

    Output output = new Output(2048, -1);
    kryo.writeClassAndObject(output, map);
    output.close();
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.serializers.MapSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.