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


Java Cursor.getNext方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例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 = 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

示例5: 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

示例6: preload

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private static void preload(Environment env, String dbName)
    throws DatabaseException {

    System.out.println("Preload starting");
    Database db = env.openDatabase(null, dbName, null);
    Cursor cursor = db.openCursor(null, null);
    try {
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        int count = 0;
        while (cursor.getNext(key, data, LockMode.DEFAULT) ==
               OperationStatus.SUCCESS) {
            count++;
            if ((count % 50000) == 0) {
                System.out.println(count + "...");
            }
        }
        System.out.println("Preloaded " + count + " records");
    } finally {
        cursor.close();
        db.close();
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:24,代碼來源:DbRunAction.java

示例7: 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:prat0318,項目名稱:dbms,代碼行數:25,代碼來源:ExampleInventoryRead.java

示例8: testReadLocks

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/** 
 * Insert and then scan some records. Measure memory usage at different
 * points in this sequence, asserting that the memory usage count is
 * properly decremented.
 */
public void testReadLocks()
    throws DatabaseException {

    loadData();

    /* 
     * Now scan the database. Make sure all locking overhead is
     * released.
     */
    for (int t = 0; t < numTxns; t++) {
        Cursor c = db.openCursor(txns[t], null);
        while (c.getNext(keyEntry, dataEntry, null) == 
               OperationStatus.SUCCESS) {
        }
        c.close();
    }
    afterAction = mb.getCacheMemoryUsage();

    closeTxns(false);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:26,代碼來源:TxnMemoryTest.java

示例9: dump

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void dump() {
    try {
        Cursor cursor = db.openCursor(null, null);
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        while (cursor.getNext(key, data, LockMode.DEFAULT) ==
               OperationStatus.SUCCESS) {
            System.out.println("<rec key=\"" +
                               IntegerBinding.entryToInt(key) +
                               "\" data=\"" +
                               IntegerBinding.entryToInt(data) +
                               "\"/>");
        }
        DbInternal.dbGetDatabaseImpl(db).getTree().dump();
        cursor.close();
    } catch (DatabaseException DBE) {
        throw new RuntimeException(DBE);
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:20,代碼來源:SplitRace_SR11144Test.java

示例10: dump

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
private void dump() {
    try {
        Cursor cursor = db.openCursor(null, null);
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        while (cursor.getNext(key, data, LockMode.DEFAULT) ==
               OperationStatus.SUCCESS) {
            System.out.println("<rec key=\"" + 
                               IntegerBinding.entryToInt(key) +
                               "\" data=\"" +
                               IntegerBinding.entryToInt(data) +
                               "\"/>");
        }
        DbInternal.dbGetDatabaseImpl(db).getTree().dump();
        cursor.close();
    } catch (DatabaseException DBE) {
        throw new RuntimeException(DBE);
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:20,代碼來源:SplitRace_SR11144Test.java

示例11: 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

示例12: gets

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
 * 獲取所有記錄
 * 
 * @author      ZhengWei(HY)
 * @createDate  2016-02-17
 * @version     v1.0
 *
 * @return
 */
public Map<String ,String> gets()
{
    Map<String ,String> v_Ret    = new HashMap<String ,String>();
    Cursor              v_Cursor = null;
    DatabaseEntry       v_Key    = new DatabaseEntry();  
    DatabaseEntry       v_Value  = new DatabaseEntry();
    
    try
    {
        v_Cursor = this.database.openCursor(null ,null);
        
        while ( v_Cursor.getNext(v_Key ,v_Value ,LockMode.DEFAULT) == OperationStatus.SUCCESS )
        {
            v_Ret.put(new String(v_Key.getData() ,this.dataEnCode) ,new String(v_Value.getData() ,this.dataEnCode));
        }
    }
    catch (Exception exce)
    {
        exce.printStackTrace();
    }
    finally
    {
        closeCursor(v_Cursor);
    }
    
    return v_Ret;
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:37,代碼來源:Berkeley.java

示例13: getDBEntrys

import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
public Map<String ,DatabaseEntry> getDBEntrys()
{
    Map<String ,DatabaseEntry> v_Ret    = new HashMap<String ,DatabaseEntry>();
    Cursor                     v_Cursor = null;
    DatabaseEntry              v_Key    = new DatabaseEntry();  
    DatabaseEntry              v_Value  = new DatabaseEntry();
    
    try
    {
        v_Cursor = this.database.openCursor(null ,null);
        
        while ( v_Cursor.getNext(v_Key ,v_Value ,LockMode.DEFAULT) == OperationStatus.SUCCESS )
        {
            v_Ret.put(new String(v_Key.getData() ,this.dataEnCode) ,v_Value);
        }
    }
    catch (Exception exce)
    {
        exce.printStackTrace();
    }
    finally
    {
        closeCursor(v_Cursor);
    }
    
    return v_Ret;
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:28,代碼來源:Berkeley.java

示例14: testRemoveEmptyBIN

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

    /* Non-transactional no-dups, 2 keys. */
    openAndInit(false, false);
    OperationStatus status;

    /* Cursor appears on BIN. */
    Cursor cursor = db.openCursor(null, null);
    status = cursor.getFirst(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Delete without closing the cursor does not compress. */
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    status = cursor.getNext(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    env.compress();
    checkBinEntriesAndCursors(bin, 2, 1);

    /* Closing the cursor without calling compress does not compress. */
    cursor.close();
    checkBinEntriesAndCursors(bin, 2, 0);

    /* Finally compress can compress. */
    env.compress();
    checkBinEntriesAndCursors(bin, 0, 0);

    /* BIN is empty so parent entry should be gone also. */
    assertEquals(1, in.getNEntries());

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:37,代碼來源:INCompressorTest.java

示例15: testRemoveEmptyDBIN

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

    /* Non-transactional dups, 2 keys and 2 dups for 1st key. */
    openAndInit(false, true);
    OperationStatus status;

    /* Cursor appears on DBIN. */
    Cursor cursor = db.openCursor(null, null);
    status = cursor.getFirst(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    checkBinEntriesAndCursors(dbin, 2, 1);

    /* Delete without closing the cursor does not compress. */
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    status = cursor.getNext(keyFound, dataFound, null);
    assertEquals(OperationStatus.SUCCESS, status);
    status = cursor.delete();
    assertEquals(OperationStatus.SUCCESS, status);
    env.compress();
    checkBinEntriesAndCursors(dbin, 2, 1);

    /* Closing the cursor without calling compress does not compress. */
    cursor.close();
    checkBinEntriesAndCursors(dbin, 2, 0);

    /* Finally compress can compress. */
    env.compress();
    checkBinEntriesAndCursors(dbin, 0, 0);

    /* BIN parent should have one less entry. */
    assertEquals(2, in.getNEntries());
    checkBinEntriesAndCursors(bin, 1, 0);

    closeEnv();
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:38,代碼來源:INCompressorTest.java


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