本文整理了Java中com.sleepycat.je.Cursor.putCurrent()
方法的一些代码示例,展示了Cursor.putCurrent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cursor.putCurrent()
方法的具体详情如下:
包路径:com.sleepycat.je.Cursor
类名称:Cursor
方法名:putCurrent
[英]Replaces the data in the key/data pair at the current cursor position.
Calling this method is equivalent to calling #put(DatabaseEntry,DatabaseEntry,Put,WriteOptions) with Put#CURRENT.
Overwrite the data of the key/data pair to which the cursor refers with the specified data item. This method will return OperationStatus.NOTFOUND if the cursor currently refers to an already-deleted key/data pair.
For a database that does not support duplicates, the data may be changed by this method. If duplicates are supported, the data may be changed only if a custom partial comparator is configured and the comparator considers the old and new data to be equal (that is, the comparator returns zero). For more information on partial comparators see DatabaseConfig#setDuplicateComparator.
If the old and new data are unequal according to the comparator, a DuplicateDataException is thrown. Changing the data in this case would change the sort order of the record, which would change the cursor position, and this is not allowed. To change the sort order of a record, delete it and then re-insert it.
[中]在当前光标位置替换密钥/数据对中的数据。
调用此方法相当于使用put#CURRENT调用#put(DatabaseEntry、DatabaseEntry、put、WriteOptions)。
用指定的数据项覆盖光标引用的密钥/数据对的数据。此方法将返回OperationStatus。如果光标当前引用已删除的密钥/数据对,则未找到。
对于不支持重复的数据库,可以通过此方法更改数据。如果支持重复,则仅当配置了自定义部分比较器且比较器认为新旧数据相等(即比较器返回零)时,才可以更改数据。有关部分比较器的更多信息,请参阅DatabaseConfig#setDuplicateComparator。
如果根据比较器,新旧数据不相等,则抛出DuplicateDataException。在这种情况下,更改数据将更改记录的排序顺序,从而更改光标位置,这是不允许的。要更改记录的排序顺序,请将其删除,然后重新插入。
代码示例来源:origin: com.sleepycat/je
public OperationStatus putCurrent(DatabaseEntry data)
throws DatabaseException {
return cursor.putCurrent(data);
}
代码示例来源:origin: HuygensING/timbuctoo
public void replace(KeyT key, ValueT initialValue, Function<ValueT, ValueT> replacer) throws DatabaseWriteException {
synchronized (keyEntry) {
try (Cursor cursor = database.openCursor(transaction, CursorConfig.DEFAULT)) {
keyBinder.objectToEntry(key, keyEntry);
OperationStatus searchResult = cursor.getSearchKey(keyEntry, valueEntry, LockMode.DEFAULT);
ValueT newValue = initialValue;
if (searchResult.equals(OperationStatus.SUCCESS)) {
newValue = replacer.apply(valueBinder.entryToObject(valueEntry));
}
valueBinder.objectToEntry(newValue, valueEntry);
cursor.putCurrent(valueEntry);
} catch (Exception e) {
throw new DatabaseWriteException(e);
}
}
}
代码示例来源:origin: org.jboss.cache/jbosscache-core
cursor.putCurrent(makeDataEntry(map));
代码示例来源:origin: org.jboss.cache/jbosscache-core
/**
* Internal version of remove(String,Object) that allows passing a
* transaction.
*/
private Object doRemove(Transaction txn, Fqn name, Object key)
throws Exception
{
Object oldVal = null;
DatabaseEntry keyEntry = makeKeyEntry(name);
DatabaseEntry foundData = new DatabaseEntry();
Cursor cursor = cacheDb.openCursor(txn, null);
try
{
OperationStatus status =
cursor.getSearchKey(keyEntry, foundData, LockMode.RMW);
if (status == OperationStatus.SUCCESS)
{
Map map = makeDataObject(foundData);
oldVal = map.remove(key);
cursor.putCurrent(makeDataEntry(map));
}
}
finally
{
cursor.close();
}
return oldVal;
}
代码示例来源:origin: org.jboss.cache/jbosscache-core
/**
* Internal version of removeData(Fqn) that allows passing a transaction.
*/
private void doRemoveData(Transaction txn, Fqn name)
throws Exception
{
DatabaseEntry dataEntry = new DatabaseEntry();
dataEntry.setPartial(0, 0, true);
DatabaseEntry keyEntry = makeKeyEntry(name);
Cursor cursor = cacheDb.openCursor(txn, null);
try
{
OperationStatus status =
cursor.getSearchKey(keyEntry, dataEntry, LockMode.RMW);
if (status == OperationStatus.SUCCESS)
{
cursor.putCurrent(makeDataEntry(null));
}
}
finally
{
cursor.close();
}
}
代码示例来源:origin: org.apache.qpid/qpid-bdbstore
tupleOutput.writeString(writer.getBuffer().toString());
TupleBinding.outputToEntry(tupleOutput, value);
objectsCursor.putCurrent(value);
代码示例来源:origin: com.sleepycat/je
this, priKey, data, secKey)) {
priCursor.putCurrent(data);
priCursor.putCurrent(data);
代码示例来源:origin: com.sleepycat/je
DatabaseEntry groupEntry = new DatabaseEntry();
groupBinding.objectToEntry(repGroup, groupEntry);
OperationStatus status = mcursor.putCurrent(groupEntry);
if (!OperationStatus.SUCCESS.equals(status)) {
throw new IllegalStateException("Unexpected state:" +
代码示例来源:origin: com.sleepycat/je
bucket.fillDataEntry(data);
OperationStatus status = cursor.putCurrent(data);
代码示例来源:origin: com.sleepycat/je
status = cursor.putCurrent(value);
if (status != OperationStatus.SUCCESS) {
throw EnvironmentFailureException.unexpectedState
代码示例来源:origin: com.sleepycat/je
boolean oneWritten = false;
if (evolveNeeded(key, data, binding)) {
cursor.putCurrent(data);
oneWritten = true;
nWritten += 1;
内容来源于网络,如有侵权,请联系作者删除!