本文整理汇总了Java中com.sleepycat.je.OperationStatus类的典型用法代码示例。如果您正苦于以下问题:Java OperationStatus类的具体用法?Java OperationStatus怎么用?Java OperationStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OperationStatus类属于com.sleepycat.je包,在下文中一共展示了OperationStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: syncGetFirst
import com.sleepycat.je.OperationStatus; //导入依赖的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;
}
示例2: syncGetNext
import com.sleepycat.je.OperationStatus; //导入依赖的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;
}
示例3: put
import com.sleepycat.je.OperationStatus; //导入依赖的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.OperationStatus; //导入依赖的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.OperationStatus; //导入依赖的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.OperationStatus; //导入依赖的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.OperationStatus; //导入依赖的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: getDBEntry
import com.sleepycat.je.OperationStatus; //导入依赖的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;
}
示例9: containsData
import com.sleepycat.je.OperationStatus; //导入依赖的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;
}
示例10: goTo
import com.sleepycat.je.OperationStatus; //导入依赖的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);
}
}
示例11: getChildren
import com.sleepycat.je.OperationStatus; //导入依赖的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;
}
示例12: getParents
import com.sleepycat.je.OperationStatus; //导入依赖的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;
}
示例13: containsLink
import com.sleepycat.je.OperationStatus; //导入依赖的package包/类
public boolean containsLink(HGPersistentHandle handle)
{
DatabaseEntry key = new DatabaseEntry(handle.toByteArray());
DatabaseEntry value = new DatabaseEntry();
value.setPartial(0, 0, true);
try
{
if (data_db.get(txn().getBJETransaction(), key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS)
{
// System.out.println(value.toString());
return true;
}
}
catch (DatabaseException ex)
{
throw new HGException("Failed to retrieve link with handle " + handle + ": " + ex.toString(), ex);
}
return false;
}
示例14: skipTo
import com.sleepycat.je.OperationStatus; //导入依赖的package包/类
@Override
public boolean skipTo(KVPair kv) throws TddlException {
/*
* for (ColumnMeta c : meta.getKeyColumns()) { Object v =
* kv.getKey().get(c.getName()); if (v == null) { if(kv.getValue() !=
* null) v = kv.getValue().get(c.getName()); }
* key_record.put(c.getName(), v); } return skipTo(key_record);
*/
key.setData(key_codec.encode(kv.getKey()));
if (value != null) {
value.setData(value_codec.encode(kv.getValue()));
}
if (OperationStatus.SUCCESS == je_cursor.getSearchBothRange(key, value, lockMode)) {
setKV();
// //System.out.println("skip true:"+skip_key+",,,current="+current);
return true;
}
// //System.out.println("skip false:"+skip_key);
return false;
}
示例15: load
import com.sleepycat.je.OperationStatus; //导入依赖的package包/类
@Override
public V load(K key) {
try {
DatabaseEntry keyEntry = objectToEntry(key);
DatabaseEntry valueEntry = new DatabaseEntry();
OperationStatus status = _db.get(null, keyEntry, valueEntry, LockMode.DEFAULT);
if (status == OperationStatus.SUCCESS) {
return (V) entryToObject(valueEntry);
} else {
return null;
}
} catch (Exception e) {
_logger.log(Level.SEVERE, e.getMessage(), e);
return null;
}
}