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


Java OperationStatus類代碼示例

本文整理匯總了Java中com.sleepycat.je.OperationStatus的典型用法代碼示例。如果您正苦於以下問題:Java OperationStatus類的具體用法?Java OperationStatus怎麽用?Java OperationStatus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: syncGetFirst

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
public byte [] syncGetFirst()
{	
	try
	{
		m_cursor = m_bdb.openCursor(null, null);
		OperationStatus status = m_cursor.getFirst(m_key, m_data, LockMode.DEFAULT);
		if(status == OperationStatus.SUCCESS)
		{
			m_nNbRecordExported = 1;
			byte tDataWithHeader[] = getDataRead();
			return tDataWithHeader;
		}
	}
	catch (DatabaseException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:21,代碼來源:BtreeFile.java

示例2: syncGetNext

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
public byte [] syncGetNext()
{
	try
	{
		if(m_cursor != null)
		{
			OperationStatus status = m_cursor.getNext(m_key, m_data, LockMode.DEFAULT);
			if(status == OperationStatus.SUCCESS)
			{
				m_nNbRecordExported++;
				byte tDataWithHeader[] = getDataRead();
				return tDataWithHeader;
			}
		}				
	}
	catch (DatabaseException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:23,代碼來源:BtreeFile.java

示例3: put

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
/**
	 * 添加數據
	 * @param dbName
	 * @param key
	 * @param value
	 * @throws Exception
	 */
	public boolean put(String dbName, String key, byte value[]) throws Exception{
        if (key == null || value == null) {
			logger.error("The key and value must be not null!");
			throw new Exception("The put data must be not null!");
		}
//        long time1 = System.currentTimeMillis();
        Database db = this.getDb(dbName);
//        logger.info("######### {}, key:{}, getDB elapse:{}ms", dbName, key, (System.currentTimeMillis() - time1));
		DatabaseEntry deKey = new DatabaseEntry(key.getBytes("utf-8"));

		DatabaseEntry deValue = new DatabaseEntry(value);
		//沒有對應key時直接添加,存在時直接覆蓋
//		long start = System.currentTimeMillis();
		OperationStatus status = db.put(null, deKey, deValue);
//		logger.info("######### {}, key:{}, put elapse:{}ms", dbName, key, (System.currentTimeMillis() - start));
		if (status.equals(OperationStatus.SUCCESS)) {
		    return true;
		} else {
		    logger.info("false, dbName:{}, key:{}, status", dbName, key, status.name());
		    return false;
		}
	}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:30,代碼來源:BerkeleyDb.java

示例4: getTotalCount

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
/**
 * 獲取總數
 * @param dbName
 * @return
 * @throws Exception
 */
public int getTotalCount(String dbName) throws Exception {
    int count = 0;
    Cursor cursor = null;
    try {
        Database db = this.getDb(dbName);
        cursor = db.openCursor(null, null);
        DatabaseEntry foundKey = new DatabaseEntry();
        DatabaseEntry foundData = new DatabaseEntry();
        if (cursor.getLast(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
            count = cursor.count();
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return count;
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:25,代碼來源:BerkeleyDb.java

示例5: put

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
/**
 * 向數據庫中添加一條記錄。
 * 
 * 如果數據庫不支持一個key對應多個data或當前database中已經存在該key了,
 * 則使用此方法將使用新的值覆蓋舊的值。
 *
 * @param i_Key
 * @param i_Value
 * @return
 */
public boolean put(DatabaseEntry i_Key ,DatabaseEntry i_Value)
{
    OperationStatus v_OperationStatus = this.database.put(null ,i_Key ,i_Value);
    
    if ( v_OperationStatus == OperationStatus.SUCCESS )
    {
        if ( this.autoCommit )
        {
            this.commit();
        }
        
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:29,代碼來源:Berkeley.java

示例6: putNoOverwrite

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
/**
 * 向數據庫中添加一條記錄。
 * 
 * 如果原先已經有了該key,則不覆蓋。
 * 不管database是否允許支持多重記錄(一個key對應多個value),
 * 隻要存在該key就不允許添加,並且返回OperationStatus.KEYEXIST信息。
 *
 * @param i_Key
 * @param i_Value
 * @return
 */
public boolean putNoOverwrite(DatabaseEntry i_Key ,DatabaseEntry i_Value)
{
    OperationStatus v_OperationStatus = this.database.putNoOverwrite(null ,i_Key ,i_Value);
    
    if ( v_OperationStatus == OperationStatus.SUCCESS )
    {
        if ( this.autoCommit )
        {
            this.commit();
        }
        
        return true;
    }
    else if ( v_OperationStatus == OperationStatus.KEYEXIST )
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:34,代碼來源:Berkeley.java

示例7: putNoDupData

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
/**
 * 向數據庫中添加一條記錄。
 * 
 * 如果原先已經有了該key,則不覆蓋。
 * 不管database是否允許支持多重記錄(一個key對應多個value),
 * 隻要存在該key就不允許添加,並且返回OperationStatus.KEYEXIST信息。  
 *
 * @param i_Key
 * @param i_Value
 * @return
 */
public boolean putNoDupData(DatabaseEntry i_Key ,DatabaseEntry i_Value)
{
    OperationStatus v_OperationStatus = this.database.putNoDupData(null ,i_Key ,i_Value);
    
    if ( v_OperationStatus == OperationStatus.SUCCESS )
    {
        if ( this.autoCommit )
        {
            this.commit();
        }
        
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:30,代碼來源:Berkeley.java

示例8: getDBEntry

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
/**
 * 獲取記錄的方法,通過key的方式來匹配,如果沒有改記錄則返回OperationStatus.NOTFOUND
 * 
 * @param i_Key
 * @return
 */
public DatabaseEntry getDBEntry(String i_Key)
{
    DatabaseEntry   v_Value           = new DatabaseEntry();
    OperationStatus v_OperationStatus = null;
    
    try
    {
        v_OperationStatus = this.database.get(null ,this.toDBEntry(i_Key) ,v_Value ,LockMode.DEFAULT);
        
        if ( v_OperationStatus != null && v_OperationStatus == OperationStatus.SUCCESS )
        {
            return v_Value;
        }
    }
    catch (Exception exce)
    {
        exce.printStackTrace();
    }
    
    return null;
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:28,代碼來源:Berkeley.java

示例9: containsData

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
public boolean containsData(HGPersistentHandle handle)
{
	DatabaseEntry key = new DatabaseEntry(handle.toByteArray());
	DatabaseEntry value = new DatabaseEntry();
	value.setPartial(0, 0, true);
	try
	{
		if (primitive_db.get(txn().getBJETransaction(), key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS)
		{
			return true;
		}
	}
	catch (DatabaseException ex)
	{
		throw new HGException("Failed to retrieve link with handle " + handle + ": " + ex.toString(), ex);
	}
	return false;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:19,代碼來源:BJEStorageImplementation.java

示例10: goTo

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
public GotoResult goTo(T value, boolean exactMatch) {
	byte[] B = converter.toByteArray(value);
	assignData(pkey, B);
	try {
		if (exactMatch) {
			if (((SecondaryCursor)cursor.cursor()).getSearchBoth(key, pkey, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
				positionToCurrent(pkey.getData(), pkey.getOffset(), pkey.getSize());
				return GotoResult.found;
			}
			else
				return GotoResult.nothing;
		}
		else {
			if (((SecondaryCursor)cursor.cursor()).getSearchBothRange(key, pkey, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
				positionToCurrent(pkey.getData(), pkey.getOffset(), pkey.getSize());
				return HGUtils.eq(B, pkey.getData()) ? GotoResult.found : GotoResult.close;
			}
			else
				return GotoResult.nothing;
		}
	}
	catch (Throwable t) {
		closeNoException();
		throw new HGException(t);
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:27,代碼來源:SingleValueResultSet.java

示例11: getChildren

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
public Set<String> getChildren(String parentHash)
{
    try
    {
        // Instantiate class catalog
        StoredClassCatalog neighborCatalog = new StoredClassCatalog(neighborDatabase);
        // Create the binding
        EntryBinding<Neighbors> neighborBinding = new SerialBinding<>(neighborCatalog, Neighbors.class);
        // Create DatabaseEntry for the key
        DatabaseEntry key = new DatabaseEntry(parentHash.getBytes("UTF-8"));
        // Create the DatabaseEntry for the data.
        DatabaseEntry data = new DatabaseEntry();
        // query database to get the key-value
        OperationStatus operationStatus = scaffoldDatabase.get(null, key, data, LockMode.DEFAULT);
        if(operationStatus != OperationStatus.NOTFOUND)
        {
            Neighbors neighbors = neighborBinding.entryToObject(data);
            return neighbors.children;
        }
    }
    catch (UnsupportedEncodingException ex)
    {
        Logger.getLogger(Scaffold.class.getName()).log(Level.SEVERE, "Scaffold entry insertion error!", ex);
    }
    return null;
}
 
開發者ID:ashish-gehani,項目名稱:SPADE,代碼行數:27,代碼來源:Scaffold.java

示例12: getParents

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
public Set<String> getParents(String childHash)
{
    try
    {
        // Instantiate class catalog
        StoredClassCatalog neighborCatalog = new StoredClassCatalog(neighborDatabase);
        // Create the binding
        EntryBinding<Neighbors> neighborBinding = new SerialBinding<>(neighborCatalog, Neighbors.class);
        // Create DatabaseEntry for the key
        DatabaseEntry key = new DatabaseEntry(childHash.getBytes("UTF-8"));
        // Create the DatabaseEntry for the data.
        DatabaseEntry data = new DatabaseEntry();
        // query database to get the key-value
        OperationStatus operationStatus = scaffoldDatabase.get(null, key, data, LockMode.DEFAULT);
        if(operationStatus != OperationStatus.NOTFOUND)
        {
            Neighbors neighbors = neighborBinding.entryToObject(data);
            return neighbors.parents;
        }
    }
    catch (UnsupportedEncodingException ex)
    {
        Logger.getLogger(Scaffold.class.getName()).log(Level.SEVERE, "Scaffold entry insertion error!", ex);
    }
    return null;
}
 
開發者ID:ashish-gehani,項目名稱:SPADE,代碼行數:27,代碼來源:Scaffold.java

示例13: containsLink

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
public boolean containsLink(HGPersistentHandle handle)
{
	DatabaseEntry key = new DatabaseEntry(handle.toByteArray());
	DatabaseEntry value = new DatabaseEntry();
	value.setPartial(0, 0, true);
	try
	{
		if (data_db.get(txn().getBJETransaction(), key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS)
		{
			// System.out.println(value.toString());
			return true;
		}
	}
	catch (DatabaseException ex)
	{
		throw new HGException("Failed to retrieve link with handle " + handle + ": " + ex.toString(), ex);
	}

	return false;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:21,代碼來源:BJEStorageImplementation.java

示例14: skipTo

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
@Override
public boolean skipTo(KVPair kv) throws TddlException {
    /*
     * for (ColumnMeta c : meta.getKeyColumns()) { Object v =
     * kv.getKey().get(c.getName()); if (v == null) { if(kv.getValue() !=
     * null) v = kv.getValue().get(c.getName()); }
     * key_record.put(c.getName(), v); } return skipTo(key_record);
     */
    key.setData(key_codec.encode(kv.getKey()));
    if (value != null) {
        value.setData(value_codec.encode(kv.getValue()));
    }
    if (OperationStatus.SUCCESS == je_cursor.getSearchBothRange(key, value, lockMode)) {
        setKV();
        // //System.out.println("skip true:"+skip_key+",,,current="+current);
        return true;
    }
    // //System.out.println("skip false:"+skip_key);
    return false;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:21,代碼來源:JE_Cursor.java

示例15: load

import com.sleepycat.je.OperationStatus; //導入依賴的package包/類
@Override
public V load(K key) {
    try {
        DatabaseEntry keyEntry = objectToEntry(key);
        DatabaseEntry valueEntry = new DatabaseEntry();
        OperationStatus status = _db.get(null, keyEntry, valueEntry, LockMode.DEFAULT);
        if (status == OperationStatus.SUCCESS) {
            return (V) entryToObject(valueEntry);
        } else {
            return null;
        }
    } catch (Exception e) {
        _logger.log(Level.SEVERE, e.getMessage(), e);
        return null;
    }
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:17,代碼來源:BerkeleyDBStore.java


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