本文整理匯總了Java中com.sleepycat.je.OperationStatus.KEYEXIST屬性的典型用法代碼示例。如果您正苦於以下問題:Java OperationStatus.KEYEXIST屬性的具體用法?Java OperationStatus.KEYEXIST怎麽用?Java OperationStatus.KEYEXIST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.sleepycat.je.OperationStatus
的用法示例。
在下文中一共展示了OperationStatus.KEYEXIST屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: putNoOverwrite
/**
* 向數據庫中添加一條記錄。
*
* 如果原先已經有了該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;
}
}
示例2: addEntry
public void addEntry(KeyType key, ValueType value)
{
checkOpen();
DatabaseEntry dbkey = new DatabaseEntry(keyConverter.toByteArray(key));
DatabaseEntry dbvalue = new DatabaseEntry(valueConverter.toByteArray(value));
try
{
OperationStatus result = db.putNoDupData(txn().getBJETransaction(), dbkey, dbvalue);
if (result != OperationStatus.SUCCESS && result != OperationStatus.KEYEXIST)
throw new Exception("OperationStatus: " + result);
}
catch (Exception ex)
{
throw new HGException("Failed to add entry to index '" + name + "': " + ex.toString(), ex);
}
}
示例3: store
public long store(final long newId, final byte[] targetWithUid, final byte[] targetNoUid) {
final DatabaseEntry idEntry = new DatabaseEntry();
LongBinding.longToEntry(newId, idEntry);
final DatabaseEntry targetEntry = new DatabaseEntry();
targetEntry.setData(targetWithUid);
// Write the new identifier marker first in case the target2Id write is successful
if (_id2Target.put(null, idEntry, targetEntry) != OperationStatus.SUCCESS) {
throw new OpenGammaRuntimeException("Internal error writing new record marker");
}
targetEntry.setData(targetNoUid);
final OperationStatus status = _target2Id.putNoOverwrite(null, targetEntry, idEntry);
if (status == OperationStatus.SUCCESS) {
LongBinding.longToEntry(System.nanoTime(), targetEntry);
_id2LastAccessed.put(null, idEntry, targetEntry);
return newId;
}
// Write was unsuccessful; won't be using the new identifier so remove the marker
_id2Target.delete(null, idEntry);
if (status != OperationStatus.KEYEXIST) {
s_logger.error("Error removing {} from {}", newId, _id2Target.getDatabaseName());
throw new OpenGammaRuntimeException("Couldn't update to database");
}
if (_target2Id.get(null, targetEntry, idEntry, LockMode.READ_UNCOMMITTED) != OperationStatus.SUCCESS) {
// Shouldn't happen - the identifier must be there since the previous put failed
throw new OpenGammaRuntimeException("Internal error fetching existing record");
}
final long result = LongBinding.entryToLong(idEntry);
return result;
}
示例4: addEntry
public void addEntry(KeyType key, ValueType value) {
checkOpen();
DatabaseEntry dbkey = new DatabaseEntry(keyConverter.toByteArray(key));
DatabaseEntry dbvalue = new DatabaseEntry(valueConverter.toByteArray(value));
try {
OperationStatus result = db.put(txn().getBJETransaction(), dbkey, dbvalue);
if (result != OperationStatus.SUCCESS && result != OperationStatus.KEYEXIST)
throw new Exception("OperationStatus: " + result);
}
catch (Exception ex) {
throw new HGException("Failed to add entry to index '" + name + "': " + ex.toString(), ex);
}
}