コード例 #1
0
 /** Register custom classes to serializes with gryo using default serialization. */
 public Builder addCustom(final Class... custom) {
   if (custom != null && custom.length > 0)
     serializationList.addAll(
         Arrays.asList(custom)
             .stream()
             .map(
                 c ->
                     Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                         c, null, currentSerializationId.getAndIncrement()))
             .collect(Collectors.<Triplet<Class, Function<Kryo, Serializer>, Integer>>toList()));
   return this;
 }
コード例 #2
0
 @Override
 public Serializer getSerializer(Class aliasedClass, byte aliasCode, byte multiplexCode)
     throws MissingException {
   rwLock.readLock().lock();
   try {
     Class multiplexClass = bcodeToClass.get(Triplet.with(aliasedClass, aliasCode, multiplexCode));
     if (multiplexClass == null) {
       throw new MissingException();
     }
     Serializer serializer = serializers.get(multiplexClass);
     if (serializer == null) {
       throw new MissingException();
     }
     return serializer;
   } finally {
     rwLock.readLock().unlock();
   }
 }
コード例 #3
0
 /**
  * Register a custom class to serialize with a custom serializer as returned from a {@link
  * Function}.
  */
 public Builder addCustom(final Class clazz, final Function<Kryo, Serializer> serializer) {
   serializationList.add(
       Triplet.with(clazz, serializer, currentSerializationId.getAndIncrement()));
   return this;
 }
コード例 #4
0
          {
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(byte[].class, null, 25));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(char[].class, null, 26));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(short[].class, null, 27));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(int[].class, null, 28));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(long[].class, null, 29));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(float[].class, null, 30));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(double[].class, null, 31));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(String[].class, null, 32));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Object[].class, null, 33));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    ArrayList.class, null, 10));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    BigInteger.class, null, 34));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    BigDecimal.class, null, 35));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Calendar.class, null, 39));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Class.class, null, 41));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Collection.class, null, 37));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Collections.EMPTY_LIST.getClass(), null, 51));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Collections.EMPTY_MAP.getClass(), null, 52));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Collections.EMPTY_SET.getClass(), null, 53));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Collections.singleton(null).getClass(), null, 54));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Collections.singletonList(null).getClass(), null, 24));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Collections.singletonMap(null, null).getClass(), null, 23));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Contains.class, null, 49));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Currency.class, null, 40));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Date.class, null, 38));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Direction.class, null, 12));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    DetachedEdge.class, null, 21));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    DetachedVertexProperty.class, null, 20));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    DetachedProperty.class, null, 18));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    DetachedVertex.class, null, 19));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    DetachedPath.class, null, 60));
            // skip 14
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(EnumSet.class, null, 46));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(HashMap.class, null, 11));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    HashMap.Entry.class, null, 16));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    KryoSerializable.class, null, 36));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    LinkedHashMap.class, null, 47));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    LinkedHashSet.class, null, 71));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    LINKED_HASH_MAP_ENTRY_CLASS, null, 15));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Locale.class, null, 22));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    StringBuffer.class, null, 43));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    StringBuilder.class, null, 44));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(T.class, null, 48));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(TimeZone.class, null, 42));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(TreeMap.class, null, 45));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(TreeSet.class, null, 50));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    UUID.class, kryo -> new UUIDSerializer(), 17));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    URI.class, kryo -> new URISerializer(), 72));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    VertexTerminator.class, null, 13));

            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    ReferenceEdge.class, null, 81));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    ReferenceVertexProperty.class, null, 82));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    ReferenceProperty.class, null, 83));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    ReferenceVertex.class, null, 84));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    ReferencePath.class, null, 85));

            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    StarGraph.class, kryo -> StarGraphGryoSerializer.with(Direction.BOTH), 86));

            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Edge.class, kryo -> new GryoSerializers.EdgeSerializer(), 65));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Vertex.class, kryo -> new GryoSerializers.VertexSerializer(), 66));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Property.class, kryo -> new GryoSerializers.PropertySerializer(), 67));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    VertexProperty.class,
                    kryo -> new GryoSerializers.VertexPropertySerializer(),
                    68));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Path.class, kryo -> new GryoSerializers.PathSerializer(), 59));
            // skip 55
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    B_O_Traverser.class, null, 75));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    O_Traverser.class, null, 76));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    B_LP_O_P_S_SE_SL_Traverser.class, null, 77));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    B_O_S_SE_SL_Traverser.class, null, 78));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    B_LP_O_S_SE_SL_Traverser.class, null, 87));

            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    TraverserSet.class, null, 58));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Tree.class, null, 61));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(HashSet.class, null, 62));
            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(BulkSet.class, null, 64));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    MutableMetrics.class, null, 69));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    StandardTraversalMetrics.class, null, 70));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    MapMemory.class, null, 73));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    MapReduce.NullObject.class, null, 74));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    AtomicLong.class, null, 79));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    DependantMutableMetrics.class, null, 80));
            add(
                Triplet.<Class, Function<Kryo, Serializer>, Integer>with(
                    Pair.class, kryo -> new PairSerializer(), 88)); // ***LAST ID**
          }