當前位置: 首頁>>代碼示例>>Java>>正文


Java Kryo.reference方法代碼示例

本文整理匯總了Java中com.esotericsoftware.kryo.Kryo.reference方法的典型用法代碼示例。如果您正苦於以下問題:Java Kryo.reference方法的具體用法?Java Kryo.reference怎麽用?Java Kryo.reference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.esotericsoftware.kryo.Kryo的用法示例。


在下文中一共展示了Kryo.reference方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public Queue read(Kryo kryo, Input input, Class<Queue> type) {
    int length = input.readVarInt(true);
    Registration registration = kryo.readClass(input);
    Class cls = registration == null ? Object.class : registration.getType();
    Queue queue = new Queue(length, cls);
    kryo.reference(queue);
    Class elementClass = null;
    Serializer serializer = null;
    if (genericType != null) {
        elementClass = genericType;
        serializer = kryo.getSerializer(genericType);
        genericType = null;
    }
    if (serializer != null) {
        for (int i = 0; i < length; i++)
            queue.addLast(kryo.readObjectOrNull(input, elementClass, serializer));
    } else {
        for (int i = 0; i < length; i++)
            queue.addLast(kryo.readClassAndObject(input));
    }
    return queue;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:24,代碼來源:QueueSerializer.java

示例2: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public SortedIntList read(Kryo kryo, Input input, Class<SortedIntList> type) {
    int length = input.readVarInt(true);
    SortedIntList list = new SortedIntList();
    kryo.reference(list);
    Class elementClass = null;
    Serializer serializer = null;
    if (genericType != null) {
        elementClass = genericType;
        serializer = kryo.getSerializer(genericType);
        genericType = null;
    }
    for (int i = 0; i < length; i++) {
        int index = input.readInt();
        Object value = serializer != null ?
                kryo.readObjectOrNull(input, elementClass, serializer) : kryo.readClassAndObject(input);
        list.insert(index, value);
    }
    return list;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:21,代碼來源:SortedIntListSerializer.java

示例3: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public T read(Kryo kryo, Input input, Class<T> type) {
    int length = input.readVarInt(true);
    boolean ordered = input.readBoolean();
    Class cls = kryo.readClass(input).getType();
    T array = create(ordered, length, cls);
    kryo.reference(array);
    Class elementClass = null;
    Serializer serializer = null;
    if (genericType != null) {
        elementClass = genericType;
        serializer = kryo.getSerializer(genericType);
        genericType = null;
    }
    if (serializer != null) {
        for (int i = 0; i < length; i++)
            array.add(kryo.readObjectOrNull(input, elementClass, serializer));
    } else {
        for (int i = 0; i < length; i++)
            array.add(kryo.readClassAndObject(input));
    }
    return array;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:24,代碼來源:ArraySerializer.java

示例4: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public T read(Kryo kryo, Input input, Class<T> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    T objectSet = create(length);

    kryo.reference(objectSet);

    Class elementClass = null;
    Serializer serializer = null;
    if (genericType != null) {
        elementClass = genericType;
        serializer = kryo.getSerializer(genericType);
        genericType = null;
    }
    if (serializer != null) {
        for (int i = 0; i < length; i++)
            objectSet.add(kryo.readObject(input, elementClass, serializer));
    } else {
        for (int i = 0; i < length; i++)
            objectSet.add(kryo.readClassAndObject(input));
    }
    return objectSet;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:25,代碼來源:ObjectSetSerializer.java

示例5: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public T read (Kryo kryo, Input input, Class<T> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    T map = create(length);

    Class keyClass = null;
    Class valueClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }
    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:39,代碼來源:ObjectMapSerializer.java

示例6: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public ObjectFloatMap read (Kryo kryo, Input input, Class<ObjectFloatMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    ObjectFloatMap map = create(length);

    Class keyClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        float value = input.readFloat();
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:28,代碼來源:ObjectFloatMapSerializer.java

示例7: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  try {
    final T object = kryo.newInstance(type);
    kryo.reference(object);
    object.readFields(new DataInputStream(input));
    return object;
  } catch (final IOException e) {
    throw new RuntimeException("unable to deserialize Writable object", e);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:12,代碼來源:WritableSerializer.java

示例8: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public ImmutableMap<Object, Object> read(Kryo kryo, Input input, Class<ImmutableMap<Object, ? extends Object>> type) {
  Map map = kryo.readObject(input, HashMap.class);
  final ImmutableMap<Object, Object> result = ImmutableMap.copyOf(map);
  kryo.reference(result);
  return result;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:8,代碼來源:ImmutableCollectionSerializers.java

示例9: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public IdentityMap read (Kryo kryo, Input input, Class<IdentityMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    IdentityMap map = new IdentityMap(length);

    Class keyClass = null;
    Class valueClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }
    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:39,代碼來源:IdentityMapSerializer.java

示例10: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public LongMap read (Kryo kryo, Input input, Class<LongMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    LongMap map = new LongMap(length);

    Class valueClass = null;

    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        long key = input.readLong();
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:28,代碼來源:LongMapSerializer.java

示例11: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
public ObjectIntMap read (Kryo kryo, Input input, Class<ObjectIntMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    ObjectIntMap map = create(length);

    Class keyClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        int value = input.readInt();
        map.put(key, value);
    }
    return map;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:28,代碼來源:ObjectIntMapSerializer.java

示例12: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  final boolean isNone = kryo.readObject(input, Boolean.class);
  if (isNone) {
    return (T)Convention.NONE;
  }
  final T result = super.read(kryo, input, type);
  final T normalized = (T) result.getTraitDef().canonize(result);
  kryo.reference(normalized);
  return normalized;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:12,代碼來源:RelTraitSerializers.java

示例13: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  final boolean isKnown = kryo.readObject(input, Boolean.class);
  if (isKnown) {
    final Integer ordinal = kryo.readObject(input, Integer.class);
    final SqlOperator operator = OperatorPopulator.BACKWARD.get(ordinal);
    if (operator != null) {
      kryo.reference(operator);
      return (T)operator;
    }
    throw new IllegalStateException(String.format("Unable to locate operator with ordinal [%s]", ordinal));
  }

  return super.read(kryo, input, type);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:16,代碼來源:SqlOperatorSerializer.java

示例14: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  // do not use delegate.read because we do not want it to cache the object. Rather, we will cache the normalized type.
  final T dataType = kryo.newInstance(type);
  final FieldSerializer.CachedField[] fields = delegate.getFields();
  for (int i = 0, n = fields.length; i < n; i++) {
    fields[i].read(input, dataType);
  }

  // be gentle to calcite and normalize the returned data type. normalization here means to use same type instances.
  final T result = (T) typeFactory.copyType(dataType);
  kryo.reference(result);
  return result;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:15,代碼來源:RelDataTypeSerializer.java

示例15: read

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
  final T result = factory.get();
  kryo.reference(result);
  return result;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:7,代碼來源:RelTraitDefSerializers.java


注:本文中的com.esotericsoftware.kryo.Kryo.reference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。