本文整理了Java中com.sleepycat.je.Cursor.delete()
方法的一些代码示例,展示了Cursor.delete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cursor.delete()
方法的具体详情如下:
包路径:com.sleepycat.je.Cursor
类名称:Cursor
方法名:delete
[英]Deletes the record to which the cursor refers. When the database has associated secondary databases, this method also deletes the associated index records.
The cursor position is unchanged after a delete, and subsequent calls to cursor functions expecting the cursor to refer to an existing record will fail.
Calling this method is equivalent to calling #delete(WriteOptions).
[中]删除光标引用的记录。当数据库具有关联的辅助数据库时,此方法还会删除关联的索引记录。
删除后游标位置不变,后续调用游标函数期望游标引用现有记录的操作将失败。
调用此方法相当于调用#delete(WriteOptions)。
代码示例来源:origin: internetarchive/heritrix3
cursor.delete();
deletedCount++;
代码示例来源:origin: yasserg/crawler4j
public void delete(int count) {
synchronized (mutex) {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
Transaction txn = beginTransaction();
try (Cursor cursor = openCursor(txn)) {
OperationStatus result = cursor.getFirst(key, value, null);
int matches = 0;
while ((matches < count) && (result == OperationStatus.SUCCESS)) {
cursor.delete();
matches++;
result = cursor.getNext(key, value, null);
}
}
commit(txn);
}
}
代码示例来源:origin: yasserg/crawler4j
public boolean removeURL(WebURL webUrl) {
synchronized (mutex) {
DatabaseEntry key = getDatabaseEntryKey(webUrl);
DatabaseEntry value = new DatabaseEntry();
Transaction txn = beginTransaction();
try (Cursor cursor = openCursor(txn)) {
OperationStatus result = cursor.getSearchKey(key, value, null);
if (result == OperationStatus.SUCCESS) {
result = cursor.delete();
if (result == OperationStatus.SUCCESS) {
return true;
}
}
} finally {
commit(txn);
}
}
return false;
}
}
代码示例来源:origin: internetarchive/heritrix3
&& keyData[1] == schemeAuthorityKeyBytes[1]
&& keyData[2] == schemeAuthorityKeyBytes[2]) {
cursor.delete();
forgottenCount++;
} else {
代码示例来源:origin: opensourceBIM/BIMserver
@Override
public void delete(String indexTableName, byte[] featureBytesOldIndex, byte[] array, DatabaseSession databaseSession) throws BimserverLockConflictException {
try {
TableWrapper tableWrapper = getTableWrapper(indexTableName);
Cursor cursor = tableWrapper.getDatabase().openCursor(getTransaction(databaseSession, tableWrapper), getCursorConfig(tableWrapper));
try {
if (cursor.getSearchBoth(new DatabaseEntry(featureBytesOldIndex), new DatabaseEntry(array), LockMode.DEFAULT) == OperationStatus.SUCCESS) {
cursor.delete();
}
} finally {
cursor.close();
}
} catch (LockConflictException e) {
throw new BimserverLockConflictException(e);
} catch (DatabaseException e) {
LOGGER.error("", e);
} catch (UnsupportedOperationException e) {
LOGGER.error("", e);
} catch (IllegalArgumentException e) {
LOGGER.error("", e);
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
}
}
代码示例来源:origin: com.sleepycat/je
public OperationStatus delete()
throws DatabaseException {
return cursor.delete();
}
代码示例来源:origin: org.apache.qpid/qpid-bdbstore
public boolean deleteCurrent()
{
return _cursor.delete() == OperationStatus.SUCCESS;
}
代码示例来源:origin: addthis/hydra
@Override
public void remove() {
if (cursor.delete() != opSuccess) {
throw new RuntimeException("unable to delete");
}
}
}
代码示例来源:origin: HuygensING/timbuctoo
public void empty() {
synchronized (keyEntry) {
try (Cursor cursor = database.openCursor(null, null)) {
while (cursor.getNext(keyEntry, valueEntry, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
cursor.delete();
}
}
}
}
代码示例来源:origin: com.sleepycat/je
public OperationResult delete(WriteOptions options)
throws DatabaseException {
checkInitialized();
return cursor.getCursor().delete(options);
}
/* <!-- end JE only --> */
代码示例来源:origin: io.permazen/permazen-kv-bdb
@Override
public synchronized void remove() {
if (BerkeleyKVTransaction.this.closed)
throw new StaleTransactionException(BerkeleyKVTransaction.this);
if (this.removeKey == null)
throw new IllegalStateException();
try {
final OperationStatus status = this.canRemoveWithCursor ? this.cursor.delete() :
this.cursor.getDatabase().delete(BerkeleyKVTransaction.this.tx, new DatabaseEntry(this.removeKey));
switch (status) {
case SUCCESS:
case KEYEMPTY:
break;
default:
throw BerkeleyKVTransaction.this.weirdStatus(status, "delete");
}
} catch (DatabaseException e) {
throw BerkeleyKVTransaction.this.wrapException(e);
}
this.removeKey = null;
}
代码示例来源:origin: org.jsimpledb/jsimpledb-kv-bdb
@Override
public synchronized void remove() {
if (BerkeleyKVTransaction.this.closed)
throw new StaleTransactionException(BerkeleyKVTransaction.this);
if (this.removeKey == null)
throw new IllegalStateException();
try {
final OperationStatus status = this.canRemoveWithCursor ? this.cursor.delete() :
this.cursor.getDatabase().delete(BerkeleyKVTransaction.this.tx, new DatabaseEntry(this.removeKey));
switch (status) {
case SUCCESS:
case KEYEMPTY:
break;
default:
throw BerkeleyKVTransaction.this.weirdStatus(status, "delete");
}
} catch (DatabaseException e) {
throw BerkeleyKVTransaction.this.wrapException(e);
}
this.removeKey = null;
}
代码示例来源:origin: org.deephacks/graphene-core
public void deleteAll() {
try (Cursor cursor = db.get().openCursor(tm.getInternalTx(), null)) {
DatabaseEntry firstKey = new DatabaseEntry(RowKey.getMinId().getKey());
if (cursor.getSearchKeyRange(firstKey, new DatabaseEntry(), LockMode.RMW) == OperationStatus.SUCCESS) {
cursor.delete();
}
while (cursor.getNextNoDup(firstKey, new DatabaseEntry(), LockMode.RMW) == OperationStatus.SUCCESS) {
cursor.delete();
}
}
}
}
代码示例来源:origin: HuygensING/timbuctoo
public boolean delete(KeyT key, ValueT value) throws DatabaseWriteException {
boolean wasChange = false;
synchronized (keyEntry) {
try (Cursor cursor = database.openCursor(transaction, CursorConfig.DEFAULT)) {
keyBinder.objectToEntry(key, keyEntry);
valueBinder.objectToEntry(value, valueEntry);
OperationStatus searchResult = cursor.getSearchBoth(keyEntry, valueEntry, LockMode.DEFAULT);
if (searchResult.equals(OperationStatus.SUCCESS)) {
wasChange = cursor.delete() == OperationStatus.SUCCESS;
}
} catch (Exception e) {
throw new DatabaseWriteException(e);
}
}
return wasChange;
}
代码示例来源:origin: edu.uci.ics/crawler4j
public boolean removeURL(WebURL webUrl) {
synchronized (mutex) {
DatabaseEntry key = getDatabaseEntryKey(webUrl);
DatabaseEntry value = new DatabaseEntry();
Transaction txn = beginTransaction();
try (Cursor cursor = openCursor(txn)) {
OperationStatus result = cursor.getSearchKey(key, value, null);
if (result == OperationStatus.SUCCESS) {
result = cursor.delete();
if (result == OperationStatus.SUCCESS) {
return true;
}
}
} finally {
commit(txn);
}
}
return false;
}
}
代码示例来源:origin: edu.uci.ics/crawler4j
public void delete(int count) {
synchronized (mutex) {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
Transaction txn = beginTransaction();
try (Cursor cursor = openCursor(txn)) {
OperationStatus result = cursor.getFirst(key, value, null);
int matches = 0;
while ((matches < count) && (result == OperationStatus.SUCCESS)) {
cursor.delete();
matches++;
result = cursor.getNext(key, value, null);
}
}
commit(txn);
}
}
代码示例来源:origin: addthis/hydra
/**
* internal/raw bdb delete
*/
@Override public byte[] delete(byte[] key) throws DatabaseException {
DatabaseEntry dk = new DatabaseEntry(key);
DatabaseEntry dv = new DatabaseEntry();
dv.setPartial(0, 0, true);
Cursor cursor = bdb.openCursor(null, CursorConfig.READ_UNCOMMITTED);
try {
if (cursor.getSearchKey(dk, dv, lockMode) == opSuccess && cursor.delete() == opSuccess && cursor.getPrev(dk, dv, lockMode) == opSuccess) {
return dk.getData();
}
} finally {
cursor.close();
}
return null;
}
代码示例来源:origin: addthis/hydra
/**
* internal/raw bdb delete
*/
@Override public byte[] delete(byte[] key) throws DatabaseException {
DatabaseEntry dk = new DatabaseEntry(key);
DatabaseEntry dv = new DatabaseEntry();
dv.setPartial(0, 0, true);
Cursor cursor = bdb.openCursor(null, cursorConfig);
try {
if (cursor.getSearchKey(dk, dv, lockMode) == opSuccess &&
cursor.delete() == opSuccess && cursor.getPrev(dk, dv, lockMode) == opSuccess) {
return dk.getData();
}
} finally {
cursor.close();
}
return null;
}
代码示例来源:origin: com.sleepycat/je
/**
* Deletes a reserved file db record after the file has been deleted.
* Also used when reactivating a reserved file.
*/
void deleteReservedFileRecord(final Long file) {
final DatabaseEntry keyEntry = new DatabaseEntry();
ReservedFileInfo.keyToEntry(file, keyEntry);
final ReadOptions readOptions =
new ReadOptions().setLockMode(LockMode.RMW);
final Locker locker =
BasicLocker.createBasicLocker(env, false /*noWait*/);
try {
try (Cursor cursor =
DbInternal.makeCursor(reservedFilesDb, locker, null)) {
if (cursor.get(
keyEntry, null, Get.SEARCH, readOptions) != null) {
cursor.delete(null);
}
}
} finally {
locker.operationEnd();
}
}
代码示例来源:origin: com.sleepycat/je
/** Override phase 2 to delete the node entry if delete is true. */
@Override
void phase2Body() {
if (!delete) {
super.phase2Body();
return;
}
final DatabaseEntry nodeNameKey = new DatabaseEntry();
StringBinding.stringToEntry(removeNode.getName(), nodeNameKey);
final Cursor cursor =
makeCursor(groupDbImpl, txn, CursorConfig.DEFAULT);
try {
final OperationStatus status = cursor.getSearchKey(
nodeNameKey, new DatabaseEntry(), LockMode.RMW);
if (status != OperationStatus.SUCCESS) {
throw EnvironmentFailureException.unexpectedState(
"Node ID: " + removeNode.getNameIdPair() +
" not present in group db");
}
cursor.delete();
} finally {
cursor.close();
}
}
};
内容来源于网络,如有侵权,请联系作者删除!