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


Java LockMode類代碼示例

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


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

示例1: syncGetFirst

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public byte [] syncGetFirst()
{	
	try
	{
		m_cursor = m_bdb.openCursor(null, null);
		OperationStatus status = m_cursor.getFirst(m_key, m_data, LockMode.DEFAULT);
		if(status == OperationStatus.SUCCESS)
		{
			m_nNbRecordExported = 1;
			byte tDataWithHeader[] = getDataRead();
			return tDataWithHeader;
		}
	}
	catch (DatabaseException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:21,代碼來源:BtreeFile.java

示例2: syncGetNext

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public byte [] syncGetNext()
{
	try
	{
		if(m_cursor != null)
		{
			OperationStatus status = m_cursor.getNext(m_key, m_data, LockMode.DEFAULT);
			if(status == OperationStatus.SUCCESS)
			{
				m_nNbRecordExported++;
				byte tDataWithHeader[] = getDataRead();
				return tDataWithHeader;
			}
		}				
	}
	catch (DatabaseException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:23,代碼來源:BtreeFile.java

示例3: getTotalCount

import com.sleepycat.je.LockMode; //導入依賴的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

示例4: getDBEntry

import com.sleepycat.je.LockMode; //導入依賴的package包/類
/**
 * 獲取記錄的方法,通過key的方式來匹配,如果沒有改記錄則返回OperationStatus.NOTFOUND
 * 
 * @param i_Key
 * @return
 */
public DatabaseEntry getDBEntry(String i_Key)
{
    DatabaseEntry   v_Value           = new DatabaseEntry();
    OperationStatus v_OperationStatus = null;
    
    try
    {
        v_OperationStatus = this.database.get(null ,this.toDBEntry(i_Key) ,v_Value ,LockMode.DEFAULT);
        
        if ( v_OperationStatus != null && v_OperationStatus == OperationStatus.SUCCESS )
        {
            return v_Value;
        }
    }
    catch (Exception exce)
    {
        exce.printStackTrace();
    }
    
    return null;
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.berkeley,代碼行數:28,代碼來源:Berkeley.java

示例5: next

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public ConceptVectorRecord next() {
  ConceptVectorRecord result = null;
  if (myCursor != null) {
    if (toggle) {
      result = next;
    }
    else {
      try {
        if (myCursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
          Integer key = (Integer) integerBinding.entryToObject(foundKey);
          result = new ConceptVectorRecord(key);
          result.setConceptVector((ConceptVector) recordDatabaseBinding.entryToObject(foundData));

        }

      } catch (DatabaseException e) {
        e.printStackTrace();
      }
    }
  }
  toggle = false;
  return result;
}
 
開發者ID:BiosemanticsDotOrg,項目名稱:GeneDiseasePaper,代碼行數:24,代碼來源:Groundhog.java

示例6: get

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public TempTarget get(final long uid) {
  final DatabaseEntry key = new DatabaseEntry();
  LongBinding.longToEntry(uid, key);
  final DatabaseEntry value = new DatabaseEntry();
  if (_id2Target.get(null, key, value, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
    final TempTarget target = fromByteArray(value.getData());
    LongBinding.longToEntry(System.nanoTime(), value);
    _id2LastAccessed.put(null, key, value);
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("Found record {} for {} in {}", new Object[] {target, uid, _id2Target.getDatabaseName() });
    }
    return target;
  } else {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("No record found for {} in {}", uid, _id2Target.getDatabaseName());
    }
    return null;
  }
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:20,代碼來源:BerkeleyDBTempTargetRepository.java

示例7: getIdentifier

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public long getIdentifier(final ValueSpecification spec) {
  try (Timer.Context context = _getIdentifierTimer.time()) {
    final byte[] specAsBytes = ValueSpecificationStringEncoder.encodeAsString(spec).getBytes(Charset.forName("UTF-8"));
    _valueSpecKey.setData(specAsBytes);
    OperationStatus status = _valueSpecificationToIdentifier.getDatabase().get(getTransaction(), _valueSpecKey, _identifier, LockMode.READ_COMMITTED);
    switch (status) {
      case NOTFOUND:
        return allocateNewIdentifier(spec);
      case SUCCESS:
        return LongBinding.entryToLong(_identifier);
      default:
        s_logger.warn("Unexpected operation status on load {}, assuming we have to insert a new record", status);
        return allocateNewIdentifier(spec);
    }
  }
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:17,代碼來源:BerkeleyDBIdentifierMap.java

示例8: readData

import com.sleepycat.je.LockMode; //導入依賴的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

示例9: getChildren

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public Set<String> getChildren(String parentHash)
{
    try
    {
        // Instantiate class catalog
        StoredClassCatalog neighborCatalog = new StoredClassCatalog(neighborDatabase);
        // Create the binding
        EntryBinding<Neighbors> neighborBinding = new SerialBinding<>(neighborCatalog, Neighbors.class);
        // Create DatabaseEntry for the key
        DatabaseEntry key = new DatabaseEntry(parentHash.getBytes("UTF-8"));
        // Create the DatabaseEntry for the data.
        DatabaseEntry data = new DatabaseEntry();
        // query database to get the key-value
        OperationStatus operationStatus = scaffoldDatabase.get(null, key, data, LockMode.DEFAULT);
        if(operationStatus != OperationStatus.NOTFOUND)
        {
            Neighbors neighbors = neighborBinding.entryToObject(data);
            return neighbors.children;
        }
    }
    catch (UnsupportedEncodingException ex)
    {
        Logger.getLogger(Scaffold.class.getName()).log(Level.SEVERE, "Scaffold entry insertion error!", ex);
    }
    return null;
}
 
開發者ID:ashish-gehani,項目名稱:SPADE,代碼行數:27,代碼來源:Scaffold.java

示例10: getParents

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public Set<String> getParents(String childHash)
{
    try
    {
        // Instantiate class catalog
        StoredClassCatalog neighborCatalog = new StoredClassCatalog(neighborDatabase);
        // Create the binding
        EntryBinding<Neighbors> neighborBinding = new SerialBinding<>(neighborCatalog, Neighbors.class);
        // Create DatabaseEntry for the key
        DatabaseEntry key = new DatabaseEntry(childHash.getBytes("UTF-8"));
        // Create the DatabaseEntry for the data.
        DatabaseEntry data = new DatabaseEntry();
        // query database to get the key-value
        OperationStatus operationStatus = scaffoldDatabase.get(null, key, data, LockMode.DEFAULT);
        if(operationStatus != OperationStatus.NOTFOUND)
        {
            Neighbors neighbors = neighborBinding.entryToObject(data);
            return neighbors.parents;
        }
    }
    catch (UnsupportedEncodingException ex)
    {
        Logger.getLogger(Scaffold.class.getName()).log(Level.SEVERE, "Scaffold entry insertion error!", ex);
    }
    return null;
}
 
開發者ID:ashish-gehani,項目名稱:SPADE,代碼行數:27,代碼來源:Scaffold.java

示例11: getData

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

	try
	{
		OperationStatus status = db.get(txn().getBJETransaction(), 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);
	}
	return result;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:20,代碼來源:DefaultIndexImpl.java

示例12: goTo

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public GotoResult goTo(T value, boolean exactMatch) {
	byte[] B = converter.toByteArray(value);
	assignData(pkey, B);
	try {
		if (exactMatch) {
			if (((SecondaryCursor)cursor.cursor()).getSearchBoth(key, pkey, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
				positionToCurrent(pkey.getData(), pkey.getOffset(), pkey.getSize());
				return GotoResult.found;
			}
			else
				return GotoResult.nothing;
		}
		else {
			if (((SecondaryCursor)cursor.cursor()).getSearchBothRange(key, pkey, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
				positionToCurrent(pkey.getData(), pkey.getOffset(), pkey.getSize());
				return HGUtils.eq(B, pkey.getData()) ? GotoResult.found : GotoResult.close;
			}
			else
				return GotoResult.nothing;
		}
	}
	catch (Throwable t) {
		closeNoException();
		throw new HGException(t);
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:27,代碼來源:SingleValueResultSet.java

示例13: SingleValueResultSet

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public SingleValueResultSet(BJETxCursor cursor, DatabaseEntry keyIn, ByteArrayConverter<T> converter) {
	//
	// The following is bit hacky because we want to avoid some of the default behavior
	// of the super constructor, which is incorrect when the "values" we are interested in 
	// are the DB's primary keys. So we duplicate its bebavior and override instantiation
	// of the current value.
	this.converter = converter;
	this.cursor = cursor;
	this.key = new DatabaseEntry();
	if (keyIn != null) {
		assignData(key, keyIn.getData());
	}
	
	try {
		((SecondaryCursor)cursor.cursor()).getCurrent(key, pkey, data, LockMode.DEFAULT);
		next = converter.fromByteArray(pkey.getData(), pkey.getOffset(), pkey.getSize());
		lookahead = 1;
	}
	catch (Throwable t) {
		throw new HGException(t);
	}

}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:24,代碼來源:SingleValueResultSet.java

示例14: next

import com.sleepycat.je.LockMode; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public Map.Entry<K, V> next() {
  Map.Entry<K, V> result = null;
  if (myCursor != null) {
    if (toggle) {
      result = next;
    }
    else {
      try {
        if (myCursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
          K key = (K) keyBinding.entryToObject(foundKey);
          V value = (V) valueBinding.entryToObject(foundData);
          result = new Entry(key, value);
        }
      } catch (DatabaseException e) {
        e.printStackTrace();
      }
    }
  }
  toggle = false;
  return result;
}
 
開發者ID:BiosemanticsDotOrg,項目名稱:GeneDiseasePaper,代碼行數:23,代碼來源:SleepyCatStoreCache.java

示例15: goBeforeFirst

import com.sleepycat.je.LockMode; //導入依賴的package包/類
public void goBeforeFirst() {
	try {
		if (cursor.cursor().getFirst(key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
			current = UNKNOWN;
			prev = null;
			next = converter.fromByteArray(data.getData(), data.getOffset(), data.getSize());
			lookahead = 1;
		}
		else {
			prev = next = null;
			current = UNKNOWN;
			lookahead = 0;
		}
	}
	catch (Throwable t) {
		closeNoException();
		throw new HGException(t);
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:20,代碼來源:IndexResultSet.java


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