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


Java HGLiveHandle.getPersistent方法代碼示例

本文整理匯總了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;
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:59,代碼來源:HyperGraph.java


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