本文整理匯總了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);
}
示例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);
}
示例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;
}