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

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

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

Cursor.close介绍

[英]Discards the cursor.

The cursor handle may not be used again after this method has been called, regardless of the method's success or failure, with one exception: the close method itself may be called any number of times.

WARNING: To guard against memory leaks, the application should discard all references to the closed handle. While BDB makes an effort to discard references from closed objects to the allocated memory for an environment, this behavior is not guaranteed. The safe course of action for an application is to discard all references to closed BDB objects.
[中]放弃光标。
调用此方法后,无论该方法成功或失败,都不能再次使用游标句柄,但有一个例外:close方法本身可以被调用任意次数。
警告:为了防止内存泄漏,应用程序应该放弃对关闭句柄的所有引用。虽然BDB努力放弃从封闭对象到环境分配内存的引用,但这种行为并不能保证。应用程序的安全操作过程是放弃对关闭的BDB对象的所有引用。

代码示例

代码示例来源:origin: thinkaurelius/titan

private void closeOpenIterators() throws BackendException {
  for (Cursor cursor : openCursors) {
    cursor.close();
  }
}

代码示例来源:origin: voldemort/voldemort

public final void close() {
  try {
    if(isOpen) {
      cursor.close();
      isOpen = false;
    }
  } catch(DatabaseException e) {
    bdbEngine.getLogger().error(e);
  }
}

代码示例来源:origin: internetarchive/heritrix3

/**
 * @return the key to the first item in the database
 * @throws DatabaseException
 */
protected DatabaseEntry getFirstKey() throws DatabaseException {
  DatabaseEntry key = new DatabaseEntry();
  DatabaseEntry value = new DatabaseEntry();
  Cursor cursor = pendingUrisDB.openCursor(null,null);
  OperationStatus status = cursor.getNext(key,value,null);
  cursor.close();
  if(status == OperationStatus.SUCCESS) {
    return key;
  }
  return null;
}

代码示例来源:origin: voldemort/voldemort

public void close() {
  if(cursor != null)
    cursor.close();
  srcDB.close();
  srcEnv.close();
  dstDB.sync();
  dstDB.close();
  dstEnv.close();
}

代码示例来源:origin: internetarchive/heritrix3

protected OperationStatus getNextNearestItem(DatabaseEntry headKey,
    DatabaseEntry result) throws DatabaseException {
  Cursor cursor = null;
  OperationStatus status;
  try {
    cursor = this.pendingUrisDB.openCursor(null, null);
    
    // get cap; headKey at this point should always point to 
    // a queue-beginning cap entry (zero-length value)
    status = cursor.getSearchKey(headKey, result, null);
    if (status != OperationStatus.SUCCESS) {
      LOGGER.severe("bdb queue cap missing: " 
          + status.toString() + " "  + new String(headKey.getData()));
      return status;
    }
    if (result.getData().length > 0) {
      LOGGER.severe("bdb queue has nonzero size: " 
          + result.getData().length);
      return OperationStatus.KEYEXIST;
    }
    // get next item (real first item of queue)
    status = cursor.getNext(headKey,result,null);
  } finally { 
    if(cursor!=null) {
      cursor.close();
    }
  }
  return status;
}

代码示例来源:origin: ltsopensource/light-task-scheduler

if (cursor != null) {
  try {
    cursor.close();
  } catch (DatabaseException e) {
    LOGGER.warn("close cursor failed! ", e);

代码示例来源:origin: ltsopensource/light-task-scheduler

if (cursor != null) {
  try {
    cursor.close();
  } catch (DatabaseException e) {
    LOGGER.warn("close cursor failed! ", e);

代码示例来源:origin: internetarchive/heritrix3

cursor.close();

代码示例来源:origin: internetarchive/heritrix3

cursor.close();

代码示例来源:origin: thinkaurelius/titan

} finally {
  try {
    if (cursor != null) cursor.close();
  } catch (Exception e) {
    throw new PermanentBackendException(e);

代码示例来源:origin: internetarchive/heritrix3

/**
   * Utility method to perform action for all pending CrawlURI instances.
   * @param c Closure action to perform
   * @throws DatabaseException
   */
  protected void forAllPendingDo(Closure c) throws DatabaseException {
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry value = new DatabaseEntry();
    Cursor cursor = pendingUrisDB.openCursor(null, null);
    while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS) {
      if (value.getData().length == 0) {
        continue;
      }
      CrawlURI item = (CrawlURI) crawlUriBinding.entryToObject(value);
      c.execute(item);
    }
    cursor.close(); 
  }
}

代码示例来源:origin: internetarchive/heritrix3

cursor.close();
long newCount = count.addAndGet(-forgottenCount);
logger.info("forgot " + forgottenCount + " urls from scheme+authority of url " + url + " (leaving " + newCount + " urls from other scheme+authorities)");

代码示例来源:origin: yasserg/crawler4j

cursor.close();
tnx.commit();

代码示例来源:origin: opensourceBIM/BIMserver

@Override
public void close() {
  try {
    cursor.close();
    berkeleyKeyValueStore.removeOpenCursor(cursorId);
  } catch (DatabaseException e) {
    LOGGER.error("", e);
  }
}

代码示例来源:origin: opensourceBIM/BIMserver

@Override
public void close() {
  try {
    cursor.close();
    berkeleyKeyValueStore.removeOpenCursor(cursorId);
  } catch (DatabaseException e) {
    LOGGER.error("", e);
  }
}

代码示例来源:origin: opensourceBIM/BIMserver

@Override
public SearchingRecordIterator getRecordIterator(String tableName, byte[] mustStartWith, byte[] startSearchingAt, DatabaseSession databaseSession, boolean keysOnly) throws BimserverLockConflictException, BimserverDatabaseException {
  Cursor cursor = null;
  try {
    TableWrapper tableWrapper = getTableWrapper(tableName);
    cursor = tableWrapper.getDatabase().openCursor(getTransaction(databaseSession, tableWrapper), getCursorConfig(tableWrapper));
    BerkeleySearchingRecordIterator berkeleySearchingRecordIterator = new BerkeleySearchingRecordIterator(cursor, this, cursorCounter.incrementAndGet(), mustStartWith, startSearchingAt, keysOnly);
    if (MONITOR_CURSOR_STACK_TRACES) {
      openCursors.put(berkeleySearchingRecordIterator.getCursorId(), new Exception().getStackTrace());
    }
    return berkeleySearchingRecordIterator;
  } catch (BimserverLockConflictException e) {
    if (cursor != null) {
      try {
        cursor.close();
        throw e;
      } catch (DatabaseException e1) {
        LOGGER.error("", e1);
      }
    }
  } catch (DatabaseException e1) {
    LOGGER.error("", e1);
  }
  return null;
}

代码示例来源: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: opensourceBIM/BIMserver

@Override
public List<byte[]> getDuplicates(String tableName, byte[] keyBytes, DatabaseSession databaseSession) throws BimserverDatabaseException {
  DatabaseEntry key = new DatabaseEntry(keyBytes);
  DatabaseEntry value = new DatabaseEntry();
  try {
    TableWrapper tableWrapper = getTableWrapper(tableName);
    Cursor cursor = tableWrapper.getDatabase().openCursor(getTransaction(databaseSession, tableWrapper), getCursorConfig(tableWrapper));
    try {
      OperationStatus operationStatus = cursor.getSearchKey(key, value, LockMode.DEFAULT);
      List<byte[]> result = new ArrayList<byte[]>();
      while (operationStatus == OperationStatus.SUCCESS) {
        result.add(value.getData());
        operationStatus = cursor.getNextDup(key, value, LockMode.DEFAULT);
      }
      return result;
    } finally {
      cursor.close();
    }
  } catch (DatabaseException e) {
    LOGGER.error("", e);
  }
  return null;
}

代码示例来源:origin: com.thinkaurelius.titan/titan-berkeleyje-jre6

private void closeOpenIterators() throws StorageException {
  for (Cursor cursor : openCursors) {
    cursor.close();
  }
}

代码示例来源:origin: addthis/hydra

@Override
public void close() {
  if (cursor != null) {
    cursor.close();
    cursor = null;
    synchronized (openIterators) {
      openIterators.remove(this);
    }
  }
}

相关文章