本文整理汇总了Java中org.hypergraphdb.handle.HGLiveHandle.getPersistent方法的典型用法代码示例。如果您正苦于以下问题:Java HGLiveHandle.getPersistent方法的具体用法?Java HGLiveHandle.getPersistent怎么用?Java HGLiveHandle.getPersistent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hypergraphdb.handle.HGLiveHandle
的用法示例。
在下文中一共展示了HGLiveHandle.getPersistent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshHandle
import org.hypergraphdb.handle.HGLiveHandle; //导入方法依赖的package包/类
/**
* <p>
* Refresh an atom handle with a currently valid and efficient run-time value. HyperGraph
* manages essentially two types of handles: run-time handles that are reminiscent to memory
* pointers and provide very fast access to loaded atoms and persistent handles that refer
* to long term storage. An atom can be accessed with both types of handles at all times
* regardless of whether it is currently in memory or "passified" into permanent storage.
* During long operations on a large graph, it is likely that atoms get moved in and out
* of main memory and their <em>live</em> status constantly fluctuates. This method allows
* you to bring a <code>HGHandle</code> in line with the current <em>live</em> status of
* an atom. It is desirable to bring a <code>HGHandle</code> when the atom will be accessed
* frequently. The following scenarios describe situation where it may be worth refreshing
* a handle:
* </p>
*
* <ul>
* <li>A link has been retrieved and the atoms in its target set will be frequently
* accessed. Generally, the atom handles comprising the target set will be persistent handles,
* unless those atoms are loaded at the time the link is retrieved. Therefore, one may
* want to refresh that target handles after their corresponding atoms have been loaded
* in memory.</li>
* <li>An atom was loaded, but it wasn't used for a long time and was therefore removed
* from the cache. In this case, its live handle would loose its "liveliness" and it would
* be a good idea to refresh it if the atom starts being used again.
* </ul>
*
* <p>
* Given a persistent handle as an argument, this method will return the corresponding live handle
* if and only if the atom currently loaded. Given an invalid live handle, the method will
* either return a new, valid one if the atom was re-loaded, or it will simply return
* its argument if the atom is currently in the cache.
* </p>
*
* @param handle The handle of the atom.
* @return An updated handle according to the behavior described above.
*/
public HGHandle refreshHandle(HGHandle handle)
{
if (handle instanceof HGPersistentHandle)
{
HGHandle result = cache.get((HGPersistentHandle)handle);
return result != null ? result : handle;
}
else
{
HGLiveHandle live = (HGLiveHandle)handle;
if (live.getRef() == null)
{
HGLiveHandle updated = cache.get(live.getPersistent());
if (updated != null)
return updated;
else
return live.getPersistent();
}
else
return handle;
}
}