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


Java Kryo.getGraphContext方法代碼示例

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


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

示例1: skipObsoleteObject

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
/** Reads an object using the registered serializer, but does not return it. If the object type is a {@link Disposable},
 * uses native memory, or is time consuming to instantiate, it should use an implementation of {@link SkippableSerializer}
 * to avoid memory leaks or wasted instantiation time. */
public static <T> void skipObsoleteObject (Kryo kryo, Input input, Class<T> type){
    com.esotericsoftware.kryo.util.ObjectMap graphContext = kryo.getGraphContext();
    final int branchDepth = graphContext.containsKey(OBSOLETE_BRANCH_KEY) ? (Integer)graphContext.get(OBSOLETE_BRANCH_KEY) : 0;
    graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth + 1);

    kryo.readObject(input, type);

    graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth);
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:13,代碼來源:GdxToKryo.java

示例2: skipObsoleteObjectOrNull

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
/** Reads an object or null using the registered serializer, but does not return it. If the object type is a {@link Disposable},
 * uses native memory, or is time consuming to instantiate, it should use an implementation of {@link SkippableSerializer}
 * to avoid memory leaks or wasted instantiation time. */
public static <T> void skipObsoleteObjectOrNull (Kryo kryo, Input input, Class<T> type){
    com.esotericsoftware.kryo.util.ObjectMap graphContext = kryo.getGraphContext();
    final int branchDepth = graphContext.containsKey(OBSOLETE_BRANCH_KEY) ? (Integer)graphContext.get(OBSOLETE_BRANCH_KEY) : 0;
    graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth + 1);

    kryo.readObjectOrNull(input, type);

    graphContext.put(OBSOLETE_BRANCH_KEY, branchDepth);
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:13,代碼來源:GdxToKryo.java

示例3: isInObsoleteBranch

import com.esotericsoftware.kryo.Kryo; //導入方法依賴的package包/類
/**
 * @return Whether the data being read is currently in an obsolete branch of the object graph, as marked by
 * {@link #skipObsoleteObject(Kryo, Input, Class)} or similar.
 */
public static boolean isInObsoleteBranch (Kryo kryo){
    com.esotericsoftware.kryo.util.ObjectMap graphContext = kryo.getGraphContext();
    if (graphContext.containsKey(OBSOLETE_BRANCH_KEY))
        return (Integer)graphContext.get(OBSOLETE_BRANCH_KEY) > 0;
    return false;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:11,代碼來源:GdxToKryo.java


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