com.sleepycat.je.Cursor.putNoOverwrite()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中com.sleepycat.je.Cursor.putNoOverwrite()方法的一些代码示例,展示了Cursor.putNoOverwrite()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cursor.putNoOverwrite()方法的具体详情如下:
包路径:com.sleepycat.je.Cursor
类名称:Cursor
方法名:putNoOverwrite

Cursor.putNoOverwrite介绍

[英]Stores a key/data pair into the database.

Calling this method is equivalent to calling #put(DatabaseEntry,DatabaseEntry,Put,WriteOptions) with Put#NO_OVERWRITE.

If the putNoOverwrite method succeeds, the cursor is positioned to refer to the newly inserted item.

If the key already appears in the database, putNoOverwrite will return com.sleepycat.je.OperationStatus#KEYEXIST.
[中]将密钥/数据对存储到数据库中。
调用此方法相当于使用put#NO#覆盖调用#put(DatabaseEntry、DatabaseEntry、put、WriteOptions)。
如果putNoOverwrite方法成功,光标将定位为引用新插入的项。
如果密钥已经出现在数据库中,PutnooOverwrite将返回com。睡猫。日本脑炎。操作状态存在。

代码示例

代码示例来源:origin: com.sleepycat/je

public OperationStatus putNoOverwrite(DatabaseEntry key,
                   DatabaseEntry data)
  throws DatabaseException {
  return cursor.putNoOverwrite(key, data);
}

代码示例来源:origin: org.jboss.cache/jbosscache-core

/**
* Creates parent nodes of the given Fqn, moving upward until an existing
* node is found.
*/
private void createParentNodes(Cursor cursor, Fqn name)
   throws Exception
{
 DatabaseEntry dataEntry = makeDataEntry(null);
 for (int nParts = name.size() - 1; nParts >= 1; nParts -= 1)
 {
   DatabaseEntry keyEntry = makeKeyEntry(name, nParts);
   OperationStatus status = cursor.putNoOverwrite(keyEntry, dataEntry);
   if (status != OperationStatus.SUCCESS)
   {
    break;
   }
 }
}

代码示例来源:origin: dworkin/reddwarf

/** {@inheritDoc} */
public boolean putNoOverwrite(byte[] key, byte[] value) {
try {
  DatabaseEntry putKeyEntry = new DatabaseEntry(key);
  DatabaseEntry putValueEntry = new DatabaseEntry(value);
  OperationStatus status = cursor.putNoOverwrite(
  putKeyEntry, putValueEntry);
  if (status == SUCCESS) {
  isCurrent = true;
  keyEntry = putKeyEntry;
  valueEntry = putValueEntry;
  return true;
  } else if (status == KEYEXIST) {
  return false;
  } else {
  throw new DbDatabaseException("Operation failed: " + status);
  }
} catch (DatabaseException e) {
  throw JeEnvironment.convertException(e, true);
}
}

代码示例来源:origin: com.projectdarkstar.server/sgs-server

/** {@inheritDoc} */
public boolean putNoOverwrite(byte[] key, byte[] value) {
try {
  DatabaseEntry putKeyEntry = new DatabaseEntry(key);
  DatabaseEntry putValueEntry = new DatabaseEntry(value);
  OperationStatus status = cursor.putNoOverwrite(
  putKeyEntry, putValueEntry);
  if (status == SUCCESS) {
  isCurrent = true;
  keyEntry = putKeyEntry;
  valueEntry = putValueEntry;
  return true;
  } else if (status == KEYEXIST) {
  return false;
  } else {
  throw new DbDatabaseException("Operation failed: " + status);
  }
} catch (DatabaseException e) {
  throw JeEnvironment.convertException(e, true);
}
}

代码示例来源:origin: org.reddwarfserver.server/sgs-server

/** {@inheritDoc} */
public boolean putNoOverwrite(byte[] key, byte[] value) {
try {
  DatabaseEntry putKeyEntry = new DatabaseEntry(key);
  DatabaseEntry putValueEntry = new DatabaseEntry(value);
  OperationStatus status = cursor.putNoOverwrite(
  putKeyEntry, putValueEntry);
  if (status == SUCCESS) {
  isCurrent = true;
  keyEntry = putKeyEntry;
  valueEntry = putValueEntry;
  return true;
  } else if (status == KEYEXIST) {
  return false;
  } else {
  throw new DbDatabaseException("Operation failed: " + status);
  }
} catch (DatabaseException e) {
  throw JeEnvironment.convertException(e, true);
}
}

代码示例来源:origin: org.jboss.cache/jbosscache-core

try
  OperationStatus status = cursor.putNoOverwrite(keyEntry, dataEntry);
  if (status == OperationStatus.SUCCESS)

代码示例来源:origin: com.sleepycat/je

} else {
  entityBinding.objectToData(entity, dataEntry);
  status = cursor.putNoOverwrite(keyEntry, dataEntry);
  if (status != OperationStatus.KEYEXIST) {
    failed = false;

代码示例来源:origin: com.sleepycat/je

status = cursor.putNoOverwrite(key, makeData());

相关文章