當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.close方法代碼示例

本文整理匯總了Java中com.sleepycat.je.Cursor.close方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.close方法的具體用法?Java Cursor.close怎麽用?Java Cursor.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sleepycat.je.Cursor的用法示例。


在下文中一共展示了Cursor.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTotalCount

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * 獲取總數
 * @param dbName
 * @return
 * @throws Exception
 */
public int getTotalCount(String dbName) throws Exception {
    int count = 0;
    Cursor cursor = null;
    try {
        Database db = this.getDb(dbName);
        cursor = db.openCursor(null, null);
        DatabaseEntry foundKey = new DatabaseEntry();
        DatabaseEntry foundData = new DatabaseEntry();
        if (cursor.getLast(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
            count = cursor.count();
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return count;
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:25,代碼來源:BerkeleyDb.java

示例2: copyLiveObjects

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void copyLiveObjects(final long deadTime, final Generation next, final List<Long> deletes) {
  s_logger.debug("Copying objects from {} to {}", this, next);
  final DatabaseEntry identifier = new DatabaseEntry();
  final DatabaseEntry target = new DatabaseEntry();
  final DatabaseEntry accessed = new DatabaseEntry();
  final Cursor cursor = _id2LastAccessed.openCursor(null, null);
  int count = 0;
  while (cursor.getNext(identifier, accessed, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
    final long lastAccess = LongBinding.entryToLong(accessed);
    if (lastAccess - deadTime > 0) {
      if (_id2Target.get(null, identifier, target, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
        next._id2Target.put(null, identifier, target);
        next._target2Id.put(null, target, identifier);
        next._id2LastAccessed.put(null, identifier, accessed);
        count++;
      } else {
        deletes.add(LongBinding.entryToLong(identifier));
      }
    } else {
      deletes.add(LongBinding.entryToLong(identifier));
    }
  }
  cursor.close();
  s_logger.info("Copied {} objects from {} to {}", new Object[] {count, this, next });
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:26,代碼來源:BerkeleyDBTempTargetRepository.java

示例3: readData

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void readData(int limit)
{
    Cursor cursor = scaffoldDatabase.openCursor(null, null);
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    int i = 0;
    while(cursor.getNext(key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS)
    {
        if(i >= limit)
            break;
        String keyString = new String(key.getData());
        System.out.println("hash: " + keyString);
        i++;
    }
    cursor.close();
}
 
開發者ID:ashish-gehani,項目名稱:SPADE,代碼行數:17,代碼來源:Scaffold.java

示例4: getGroundhogStatistics

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public GroundhogStatistics getGroundhogStatistics() {
  GroundhogStatistics wholeGroundhogStatistics = new GroundhogStatistics();

  try {
    Cursor myCursor = conceptToConceptVectorIndexStore.openCursor(null, null);
    DatabaseEntry foundKey = new DatabaseEntry();
    DatabaseEntry foundData = new DatabaseEntry();
    while (myCursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
      ConceptToConceptVectorRecordIndexEntry entry = (ConceptToConceptVectorRecordIndexEntry) myDataBinding.entryToObject(foundData);
      Integer key = (Integer) myIntegerBinding.entryToObject(foundKey);
      ConceptStatistic conceptStatistic = new ConceptStatistic();
      conceptStatistic.docFrequency = entry.conceptVectorRecordIDs.size();
      conceptStatistic.termFrequency = Math.round(entry.sumOfValuesInRecords);
      // RvS: fix compile error by rounding off float to int

      wholeGroundhogStatistics.conceptStatistics.put(key, conceptStatistic);
      wholeGroundhogStatistics.allConceptOccurrences += entry.sumOfValuesInRecords;
    }
    myCursor.close();
  } catch (DatabaseException e) {
    e.printStackTrace();
  }

  return wholeGroundhogStatistics;
}
 
開發者ID:BiosemanticsDotOrg,項目名稱:GeneDiseasePaper,代碼行數:26,代碼來源:ConceptToRecordIndex.java

示例5: getGroundhogStatistics

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public GroundhogStatistics getGroundhogStatistics() {
  GroundhogStatistics wholeGroundhogStatistics = new GroundhogStatistics();

  try {
    Cursor myCursor = conceptToConceptVectorIndexStore.openCursor(null, null);
    DatabaseEntry foundKey = new DatabaseEntry();
    DatabaseEntry foundData = new DatabaseEntry();
    while (myCursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
      ConceptToConceptVectorRecordIndexEntry entry = (ConceptToConceptVectorRecordIndexEntry) myDataBinding.entryToObject(foundData);
      Integer key = (Integer) myIntegerBinding.entryToObject(foundKey);
      ConceptStatistic conceptStatistic = new ConceptStatistic();
      conceptStatistic.docFrequency = entry.conceptVectorRecordIDs.size();
      conceptStatistic.termFrequency = entry.sumOfValuesInRecords.intValue();

      wholeGroundhogStatistics.conceptStatistics.put(key, conceptStatistic);
      wholeGroundhogStatistics.allConceptOccurrences += entry.sumOfValuesInRecords;
    }
    myCursor.close();
  } catch (DatabaseException e) {
    e.printStackTrace();
  }

  return wholeGroundhogStatistics;
}
 
開發者ID:BiosemanticsDotOrg,項目名稱:GeneDiseasePaper,代碼行數:25,代碼來源:ConceptToRecordIndex.java

示例6: privateLoadAllKeys

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private Set privateLoadAllKeys() {
    Set keys = new java.util.HashSet((int) _db.count());
    Cursor cursor = null;
    try {
        cursor = _db.openCursor(null, null);
        DatabaseEntry foundKey = new DatabaseEntry();
        DatabaseEntry foundData = new DatabaseEntry();

        while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
            keys.add((K) entryToObject(foundKey));
        }
    } catch (Exception e) {
        _logger.log(Level.SEVERE, e.getMessage(), e);
    } finally {
        cursor.close();
    }

    _logger.log(Level.INFO, this.getClass().getCanonicalName() + ":" + _mapName + ":loadAllKeys:" + keys.size());

    return keys;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:22,代碼來源:BerkeleyDBStore.java

示例7: testCursorDupAndCloseDb

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void testCursorDupAndCloseDb()
throws DatabaseException {

       initEnv(false);
       DatabaseConfig dbConfig = new DatabaseConfig();
       dbConfig.setAllowCreate(true);
       Database myDb = exampleEnv.openDatabase(null, "fooDb", dbConfig);

myDb.put(null, new StringDbt("blah"), new StringDbt("blort"));
Cursor cursor = myDb.openCursor(null, null);
OperationStatus status = cursor.getNext(new DatabaseEntry(),
                                               new DatabaseEntry(),
                                               LockMode.DEFAULT);
Cursor cursorDup = cursor.dup(true);
cursor.close();
cursorDup.close();
myDb.close();
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:19,代碼來源:DbCursorDupTest.java

示例8: showAllInventory

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void showAllInventory() 
    throws DatabaseException {
    // Get a cursor
    Cursor cursor = myDbEnv.getInventoryDB().openCursor(null, null);

    // DatabaseEntry objects used for reading records
    DatabaseEntry foundKey = new DatabaseEntry();
    DatabaseEntry foundData = new DatabaseEntry();

    try { // always want to make sure the cursor gets closed
        while (cursor.getNext(foundKey, foundData, 
                    LockMode.DEFAULT) == OperationStatus.SUCCESS) {
            Inventory theInventory = 
                (Inventory)inventoryBinding.entryToObject(foundData);
            displayInventoryRecord(foundKey, theInventory);
        }
    } catch (Exception e) {
        System.err.println("Error on inventory cursor:");
        System.err.println(e.toString());
        e.printStackTrace();
    } finally {
        cursor.close();
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:25,代碼來源:ExampleInventoryRead.java

示例9: treeSplittingWithDeletedIdKeyWorker

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void treeSplittingWithDeletedIdKeyWorker()
throws Throwable {

initEnv(false);
StringDbt data = new StringDbt("data");

Cursor cursor = exampleDb.openCursor(null, null);
cursor.put(new StringDbt("AGPFX"), data);
cursor.put(new StringDbt("AHHHH"), data);
cursor.put(new StringDbt("AIIII"), data);
cursor.put(new StringDbt("AAAAA"), data);
cursor.put(new StringDbt("AABBB"), data);
cursor.put(new StringDbt("AACCC"), data);
cursor.close();
exampleDb.delete(null, new StringDbt("AGPFX"));
exampleEnv.compress();
cursor = exampleDb.openCursor(null, null);
cursor.put(new StringDbt("AAAAB"), data);
cursor.put(new StringDbt("AAAAC"), data);
cursor.close();
validateDatabase();
   }
 
開發者ID:nologic,項目名稱:nabs,代碼行數:23,代碼來源:DbCursorTest.java

示例10: get

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
* 通過遊標查詢數據
* 當key為null或者""時,返回數據庫的所有記錄
* @param dbName
* @param key
* @return
* @throws Exception
*/
  public List<BerkeleyBean> get(String dbName, String key) throws Exception {
      List<BerkeleyBean> resultList = null;
      Cursor cursor = null;
      try {
          // 每次取50條
          int itemLimit = 50;
          Database db = this.getDb(dbName);
          cursor = db.openCursor(null, null);
          resultList = new ArrayList<BerkeleyBean>(itemLimit);
          byte keyData[] = null;
          if (key != null && !"".equals(key.trim())) {
              keyData = key.getBytes("utf-8");
          }
          DatabaseEntry foundKey = new DatabaseEntry(keyData);
          DatabaseEntry foundData = new DatabaseEntry();
          // 循環取得數據
          BerkeleyBean bean = null;
          String getKey = null;
          byte data[] = null;
          while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
              getKey = new String(foundKey.getData(), "utf-8");
              data = foundData.getData();
              bean = new BerkeleyBean();
              bean.setKey(getKey);
              bean.setValue(data);
              resultList.add(bean);
              if (itemLimit-- <= 0)
                  break;
          }
      } finally {
          if (cursor != null) {
              cursor.close();
          }
      }
      return resultList;
  }
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:45,代碼來源:BerkeleyDb.java

示例11: closeCursor

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * 關閉遊標
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-06-20
 * @version     v1.0
 *
 * @param i_Cursor
 */
public static void closeCursor(Cursor i_Cursor)
{
    if ( i_Cursor != null )
    {
        try
        {
            i_Cursor.close();
        }
        catch (Exception exce)
        {
            exce.printStackTrace();
        }
    }
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:24,代碼來源:Berkeley.java

示例12: mergeDuplicateEntries

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void mergeDuplicateEntries() {
  try {
    System.out.println("Starting to merge duplicate entries in the Database " + StringUtilities.now());
    Cursor myCursor = conceptToConceptVectorIndexStore.openCursor(null, null);
    DatabaseEntry searchKey = new DatabaseEntry();
    DatabaseEntry foundData = new DatabaseEntry();
    for (Integer key: indexedConceptsWithDuplicates) {
      myIntegerBinding.objectToEntry(key, searchKey);
      if (myCursor.getSearchKey(searchKey, foundData, null) == OperationStatus.SUCCESS) {
        if (myCursor.count() > 1) {
          ConceptToConceptVectorRecordIndexEntry entry = (ConceptToConceptVectorRecordIndexEntry) myDataBinding.entryToObject(foundData);
          //OperationStatus status = myCursor.delete();
          while (myCursor.getNextDup(searchKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
            ConceptToConceptVectorRecordIndexEntry addition = (ConceptToConceptVectorRecordIndexEntry) myDataBinding.entryToObject(foundData);
            entry.conceptVectorRecordIDs.addAll(addition.conceptVectorRecordIDs);
            entry.sumOfValuesInRecords += addition.sumOfValuesInRecords;
            myCursor.delete();
          }
          setEntryInStore(key, entry);
        }
      }
    }
    System.out.println("Done merging duplicate entries in the Database " + StringUtilities.now());
    myCursor.close();
  } catch (DatabaseException e) {
    e.printStackTrace();
  }
}
 
開發者ID:BiosemanticsDotOrg,項目名稱:GeneDiseasePaper,代碼行數:29,代碼來源:ConceptToRecordIndex.java

示例13: removeEntry

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public void removeEntry(KeyType key, ValueType value)
{
	checkOpen();
	DatabaseEntry keyEntry = new DatabaseEntry(keyConverter.toByteArray(key));
	DatabaseEntry valueEntry = new DatabaseEntry(valueConverter.toByteArray(value));
	Cursor cursor = null;

	try
	{
		cursor = db.openCursor(txn().getBJETransaction(), cursorConfig);
		if (cursor.getSearchBoth(keyEntry, valueEntry, LockMode.DEFAULT) == OperationStatus.SUCCESS)
			cursor.delete();
	}
	catch (Exception ex)
	{
		throw new HGException("Failed to lookup index '" + name + "': " + ex.toString(), ex);
	}
	finally
	{
		if (cursor != null)
		{
			try
			{
				cursor.close();
			}
			catch (Throwable t)
			{
			}
		}
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:32,代碼來源:DefaultIndexImpl.java

示例14: findFirst

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public ValueType findFirst(KeyType key)
{
	checkOpen();
	DatabaseEntry keyEntry = new DatabaseEntry(keyConverter.toByteArray(key));
	DatabaseEntry value = new DatabaseEntry();
	ValueType result = null;
	Cursor cursor = null;

	try
	{
		cursor = db.openCursor(txn().getBJETransaction(), cursorConfig);
		OperationStatus status = cursor.getSearchKey(keyEntry, value, LockMode.DEFAULT);
		if (status == OperationStatus.SUCCESS)
			result = valueConverter.fromByteArray(value.getData(), value.getOffset(), value.getSize());
	}
	catch (Exception ex)
	{
		throw new HGException("Failed to lookup index '" + name + "': " + ex.toString(), ex);
	}
	finally
	{
		if (cursor != null)
		{
			try
			{
				cursor.close();
			}
			catch (Throwable t)
			{
			}
		}
	}
	return result;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:35,代碼來源:DefaultIndexImpl.java

示例15: findLast

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * <p>
 * Find the last entry, assuming ordered duplicates, corresponding to the
 * given key.
 * </p>
 * 
 * @param key
 *            The key whose last entry is sought.
 * @return The last (i.e. greatest, i.e. maximum) data value for that key or
 *         null if the set of entries for the key is empty.
 */
public ValueType findLast(KeyType key)
{
	checkOpen();
	DatabaseEntry keyEntry = new DatabaseEntry(keyConverter.toByteArray(key));
	DatabaseEntry value = new DatabaseEntry();
	ValueType result = null;
	Cursor cursor = null;
	try
	{
		cursor = db.openCursor(txn().getBJETransaction(), cursorConfig);
		OperationStatus status = cursor.getLast(keyEntry, value, LockMode.DEFAULT);
		if (status == OperationStatus.SUCCESS)
			result = valueConverter.fromByteArray(value.getData(), value.getOffset(), value.getSize());
	}
	catch (Exception ex)
	{
		throw new HGException("Failed to lookup index '" + name + "': " + ex.toString(), ex);
	}
	finally
	{
		if (cursor != null)
		{
			try
			{
				cursor.close();
			}
			catch (Throwable t)
			{
			}
		}
	}
	return result;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:45,代碼來源:DefaultIndexImpl.java


注:本文中的com.sleepycat.je.Cursor.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。