本文整理汇总了Java中com.sleepycat.je.DatabaseEntry类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseEntry类的具体用法?Java DatabaseEntry怎么用?Java DatabaseEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseEntry类属于com.sleepycat.je包,在下文中一共展示了DatabaseEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BtreeFile
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
BtreeFile(Database bdb) //, boolean bCanSortMultiThreads)
{
m_bdb = bdb;
m_key = new DatabaseEntry();
m_data = new DatabaseEntry();
// if(bCanSortMultiThreads)
// {
m_nNbthreadsSort = BaseResourceManager.getNbThreadsSort();
if(m_nNbthreadsSort > 0)
{
m_nNbMaxRequestAsyncSortPending = BaseResourceManager.getNbMaxRequestAsyncSortPending();
BtreePooledThreadWriterFactory btreeThreadFactory = new BtreePooledThreadWriterFactory();
m_threadsPoolWriter = new PoolOfThreads(btreeThreadFactory, m_nNbthreadsSort, m_nNbMaxRequestAsyncSortPending);
m_threadsPoolWriter.startAllThreads();
}
m_multiThreadedSortItemCache = new MultiThreadedSortAddItemCache();
//}
}
示例2: asyncAddItemToSortByMultiThreads
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
public void asyncAddItemToSortByMultiThreads(MultiThreadedSortAddItem multiThreadedSortItem, byte tbyData[])
{
// if more than 1 dedicated thread are used for adding an item to sort
DatabaseEntry data = new DatabaseEntry();
data.setData(tbyData, 0, multiThreadedSortItem.m_nTotalLength);
byte tbyKey[] = m_keyDescription.fillNewKeyBuffer(tbyData, multiThreadedSortItem.m_nNbRecordRead, multiThreadedSortItem.m_bVariableLength);
//Dumper.dump("Record read="+multiThreadedSortItem.m_nNbRecordRead);
//Dumper.dump(tbyKey);
DatabaseEntry key = new DatabaseEntry();
key.setData(tbyKey);
try
{
m_bdb.put(null, key, data);
}
catch (DatabaseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
m_multiThreadedSortItemCache.disposeItemForReuse(multiThreadedSortItem);
}
示例3: put
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
/**
* 添加数据
* @param dbName
* @param key
* @param value
* @throws Exception
*/
public boolean put(String dbName, String key, byte value[]) throws Exception{
if (key == null || value == null) {
logger.error("The key and value must be not null!");
throw new Exception("The put data must be not null!");
}
// long time1 = System.currentTimeMillis();
Database db = this.getDb(dbName);
// logger.info("######### {}, key:{}, getDB elapse:{}ms", dbName, key, (System.currentTimeMillis() - time1));
DatabaseEntry deKey = new DatabaseEntry(key.getBytes("utf-8"));
DatabaseEntry deValue = new DatabaseEntry(value);
//没有对应key时直接添加,存在时直接覆盖
// long start = System.currentTimeMillis();
OperationStatus status = db.put(null, deKey, deValue);
// logger.info("######### {}, key:{}, put elapse:{}ms", dbName, key, (System.currentTimeMillis() - start));
if (status.equals(OperationStatus.SUCCESS)) {
return true;
} else {
logger.info("false, dbName:{}, key:{}, status", dbName, key, status.name());
return false;
}
}
示例4: getTotalCount
import com.sleepycat.je.DatabaseEntry; //导入依赖的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;
}
示例5: put
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
/**
* 向数据库中添加一条记录。
*
* 如果数据库不支持一个key对应多个data或当前database中已经存在该key了,
* 则使用此方法将使用新的值覆盖旧的值。
*
* @param i_Key
* @param i_Value
* @return
*/
public boolean put(DatabaseEntry i_Key ,DatabaseEntry i_Value)
{
OperationStatus v_OperationStatus = this.database.put(null ,i_Key ,i_Value);
if ( v_OperationStatus == OperationStatus.SUCCESS )
{
if ( this.autoCommit )
{
this.commit();
}
return true;
}
else
{
return false;
}
}
示例6: putNoOverwrite
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
/**
* 向数据库中添加一条记录。
*
* 如果原先已经有了该key,则不覆盖。
* 不管database是否允许支持多重记录(一个key对应多个value),
* 只要存在该key就不允许添加,并且返回OperationStatus.KEYEXIST信息。
*
* @param i_Key
* @param i_Value
* @return
*/
public boolean putNoOverwrite(DatabaseEntry i_Key ,DatabaseEntry i_Value)
{
OperationStatus v_OperationStatus = this.database.putNoOverwrite(null ,i_Key ,i_Value);
if ( v_OperationStatus == OperationStatus.SUCCESS )
{
if ( this.autoCommit )
{
this.commit();
}
return true;
}
else if ( v_OperationStatus == OperationStatus.KEYEXIST )
{
return true;
}
else
{
return false;
}
}
示例7: putNoDupData
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
/**
* 向数据库中添加一条记录。
*
* 如果原先已经有了该key,则不覆盖。
* 不管database是否允许支持多重记录(一个key对应多个value),
* 只要存在该key就不允许添加,并且返回OperationStatus.KEYEXIST信息。
*
* @param i_Key
* @param i_Value
* @return
*/
public boolean putNoDupData(DatabaseEntry i_Key ,DatabaseEntry i_Value)
{
OperationStatus v_OperationStatus = this.database.putNoDupData(null ,i_Key ,i_Value);
if ( v_OperationStatus == OperationStatus.SUCCESS )
{
if ( this.autoCommit )
{
this.commit();
}
return true;
}
else
{
return false;
}
}
示例8: get
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
/**
* 获取记录的方法,通过key的方式来匹配,如果没有改记录则返回OperationStatus.NOTFOUND
*
* @param i_Key
* @return
*/
public String get(String i_Key)
{
DatabaseEntry v_Value = this.getDBEntry(i_Key);
if ( v_Value != null )
{
try
{
return new String(v_Value.getData() ,this.dataEnCode);
}
catch (Exception exce)
{
exce.printStackTrace();
}
}
return null;
}
示例9: getDBEntry
import com.sleepycat.je.DatabaseEntry; //导入依赖的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;
}
示例10: getObject
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
/**
* 获取记录的方法,通过key的方式来匹配,如果没有改记录则返回OperationStatus.NOTFOUND
*
* @param i_Key
* @return
*/
public Object getObject(String i_Key)
{
String v_ClassName = this.catalogDB.get(i_Key);
if ( v_ClassName != null )
{
ClassInfo v_ClassInfo = this.catalogClasses.get(v_ClassName);
if ( v_ClassInfo != null )
{
DatabaseEntry v_DBEntry = this.dataDB.getDBEntry(i_Key);
if ( v_DBEntry != null )
{
return v_ClassInfo.getCatalogBinding().entryToObject(v_DBEntry);
}
}
}
return null;
}
示例11: get
import com.sleepycat.je.DatabaseEntry; //导入依赖的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;
}
}
示例12: copyLiveObjects
import com.sleepycat.je.DatabaseEntry; //导入依赖的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 });
}
示例13: containsData
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
public boolean containsData(HGPersistentHandle handle)
{
DatabaseEntry key = new DatabaseEntry(handle.toByteArray());
DatabaseEntry value = new DatabaseEntry();
value.setPartial(0, 0, true);
try
{
if (primitive_db.get(txn().getBJETransaction(), key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS)
{
return true;
}
}
catch (DatabaseException ex)
{
throw new HGException("Failed to retrieve link with handle " + handle + ": " + ex.toString(), ex);
}
return false;
}
示例14: getData
import com.sleepycat.je.DatabaseEntry; //导入依赖的package包/类
public byte[] getData(HGPersistentHandle handle)
{
try
{
DatabaseEntry key = new DatabaseEntry(handle.toByteArray());
DatabaseEntry value = new DatabaseEntry();
if (primitive_db.get(txn().getBJETransaction(), key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS)
return value.getData();
else
return null;
}
catch (Exception ex)
{
throw new HGException("Failed to retrieve link with handle " + handle, ex);
}
}
示例15: getData
import com.sleepycat.je.DatabaseEntry; //导入依赖的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;
}