Package com.sleepycat.je

Examples of com.sleepycat.je.DatabaseEntry


  boolean readOnly = true; boolean dupFlag = false;
  dbt.openDB(Constants.EXT_FILES_DB, readOnly, dupFlag);
 
  BooleanQuery query = new BooleanQuery();
  TupleBinding tpb = new IndexableDoc().getBdbBinding();
  DatabaseEntry data = new DatabaseEntry();
  if ( dbt.fetch(key, data) )
   {
     //*-- extract the text of the document
     IndexableDoc idoc = (IndexableDoc) tpb.entryToObject(data);
     String docText = idoc.getContents().toString();
View Full Code Here


   {
    //*-- use the key to fetch the matching database entry
    Document doc = hits.doc(i);
    String key = doc.get("key");
    String ftype = doc.get("type");
    DatabaseEntry data = new DatabaseEntry();

    String dbname = (ftype.equalsIgnoreCase("email")) ? Constants.EXT_MESSAGES_DB: Constants.EXT_FILES_DB;
    dbt.openDB(dbname, true, false); //*-- no create and no dups            
    dbt.fetch(key, data);
    dbt.closeDB();
View Full Code Here

public synchronized String getNextKey() throws DatabaseException
{
  String lastKey = "0"; Cursor cursor = null;
  cursor = getCurrentDB().openCursor(null, null);
  DatabaseEntry key = new DatabaseEntry(); DatabaseEntry data = new DatabaseEntry();
  if (cursor.getLast(key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS)
   lastKey = new String(key.getData())
  cursor.close();

  int i = new Integer(lastKey).intValue() + 1;
View Full Code Here

{

  boolean valid = false;
  try
  { key = key.trim();
  DatabaseEntry dbKey = new DatabaseEntry( key.getBytes("UTF-8") );
  DatabaseEntry  dbData = new DatabaseEntry();
  data.getBdbBinding().objectToEntry(data, dbData);
  OperationStatus ost = (dups) ? getCurrentDB().put(null, dbKey, dbData):
   getCurrentDB().putNoOverwrite(null, dbKey, dbData)

  if (ost != OperationStatus.KEYEXIST) valid = true;
View Full Code Here

public boolean fetch (String key, DatabaseEntry dbData)
{
  boolean retval = false;
  try
  { key = key.trim();
  DatabaseEntry dbKey = new DatabaseEntry( key.getBytes("UTF-8") );

  //*-- use the key to fetch the data from the primary database
  if ( getCurrentDB().get(null, dbKey, dbData, LockMode.DEFAULT== OperationStatus.SUCCESS) retval = true;
  }
  catch (RuntimeException e)
View Full Code Here

  ArrayList<DatabaseEntry> al = new ArrayList<DatabaseEntry>();
  Cursor cursor = null;
  DatabaseEntry[] dbData = null;
  try
  {
   DatabaseEntry dbKey = new DatabaseEntry( key.getBytes("UTF-8") );
   DatabaseEntry dbe = new DatabaseEntry();
   cursor = getCurrentDB().openCursor(null, null);
   OperationStatus ostat = (rangeFlag) ? cursor.getSearchKeyRange(dbKey, dbe, LockMode.DEFAULT):
                            cursor.getSearchKey(dbKey, dbe, LockMode.DEFAULT);

   int numRecords = 0;
   if (cursor.count() >= 1)
   { while ( (ostat == OperationStatus.SUCCESS) && (numRecords < RANGE) )
   { al.add(dbe); dbe = new DatabaseEntry();
   ostat = (rangeFlag) ? cursor.getNext(dbKey, dbe, LockMode.DEFAULT):
    cursor.getNextDup(dbKey, dbe, LockMode.DEFAULT);
   numRecords++;
   }
   }
View Full Code Here

  * @param key String Sec. key to the row
  * @return DatabaseEntry data from the row
  */
public DatabaseEntry fetchSec (String key)
{
  DatabaseEntry dbData = new DatabaseEntry();
  try
  {
   key = key.trim();
   DatabaseEntry dbKey = new DatabaseEntry( key.getBytes("UTF-8") );
   DatabaseEntry py = new DatabaseEntry();

   //*-- use the key to fetch the data from the primary database
   OperationStatus os = getSecDB().get(null, dbKey, py, dbData, LockMode.DEFAULT);
   if (os != OperationStatus.SUCCESS) dbData = null;
  }
View Full Code Here

  ArrayList<DatabaseEntry> al = new ArrayList<DatabaseEntry>();
  SecondaryCursor secCursor = null;
  DatabaseEntry[] dbData = null;
  try
 
   DatabaseEntry dbKey = new DatabaseEntry( key.getBytes("UTF-8") );
   DatabaseEntry dbe = new DatabaseEntry();
   secCursor = getSecDB().openSecondaryCursor(null, null);
   OperationStatus ostat = (rangeFlag) ? secCursor.getSearchKeyRange(dbKey, dbe, LockMode.DEFAULT):
    secCursor.getSearchKey(dbKey, dbe, LockMode.DEFAULT);

   int numRecords = 0;
   if (secCursor.count() >= 1)
   { while ( (ostat == OperationStatus.SUCCESS) && (numRecords < RANGE) )
   { al.add(dbe); dbe = new DatabaseEntry();
   ostat = (rangeFlag) ? secCursor.getNext(dbKey, dbe, LockMode.DEFAULT):
    secCursor.getNextDup(dbKey, dbe, LockMode.DEFAULT);
   numRecords++;
   }
   }
View Full Code Here

  * @return boolean
  */
public synchronized boolean delete (String key)
{
  try
  { DatabaseEntry dbe = new DatabaseEntry( key.getBytes("UTF-8"));
  if ( getCurrentDB().delete(null, dbe) == OperationStatus.NOTFOUND) return false; }
  catch (UnsupportedEncodingException ue) { return false; }
  catch (DatabaseException e) { return false;}
  return true;
}
View Full Code Here

  Cursor cursor = null;
  boolean retval = false;
  try
  { cursor = getCurrentDB().openCursor(null, null);
    DatabaseEntry dkey = new DatabaseEntry(key.getBytes("UTF-8") );
    DatabaseEntry data = new DatabaseEntry();
    if (
    cursor.getSearchKey(dkey, data, LockMode.DEFAULT) ==
      OperationStatus.SUCCESS ) retval = true;
  }
  catch (UnsupportedEncodingException e)
View Full Code Here

TOP

Related Classes of com.sleepycat.je.DatabaseEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.