Examples of SecondaryDatabase


Examples of com.sleepycat.db.SecondaryDatabase

        mySecConfig.setKeyCreator(keyCreator);

        // Now open it
        try {
            itemnameindexdb = databasesHome + "/" + itemnameindexdb;
            itemNameIndexDb = new SecondaryDatabase(itemnameindexdb,
                                                    null,
                                                    inventoryDb,
                                                    mySecConfig);
        } catch(FileNotFoundException fnfe) {
            System.err.println("MyDbs: " + fnfe.toString());
View Full Code Here

Examples of com.sleepycat.db.SecondaryDatabase

         * doNotCreate is true and the database does not exist, we silently
         * ignore the DatabaseNotFoundException and return null.  When
         * getSecondaryIndex is subsequently called, the secondary database
         * will be created and populated from the primary -- a bulk load.
         */
        SecondaryDatabase db;
        boolean saveAllowCreate = config.getAllowCreate();
        try {
            if (doNotCreate) {
                config.setAllowCreate(false);
            }
View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

  boolean retval = false;
  try
 
   //*-- first, get the environment
   if (env == null) { openEnv(DBDIR, false); if (env == null) return retval; }
   SecondaryDatabase  dbe = getSecDB(); //if (dbe == null) return retval;
   if (dbe != null) dbe.close();  
   env.removeDatabase(null, dbname);   
   retval = true;
  }
  catch (DatabaseException dbe) { }

View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

                                      String dbName,
                                      Database primaryDatabase,
                                      SecondaryConfig config)
        throws DatabaseException {

        SecondaryDatabase db;
        if (config.getExclusiveCreate()) {
            db = env.openSecondaryDatabase(null, dbName,
                                           primaryDatabase, config);
            databaseHandleCache.put(dbName, db);
        } else {
            db = (SecondaryDatabase) databaseHandleCache.get(dbName);
            if (db == null) {
                db = env.openSecondaryDatabase(null, dbName,
                                               primaryDatabase, config);
                databaseHandleCache.put(dbName, db);
            } else {
                DbInternal.validate(config, db.getConfig());
            }
        }
        return db;
    }
View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

                 " Transactional, DeferredWrite, ReadOnly");
        }

        PersistKeyBinding keyBinding = getKeyBinding(keyClassName);

        SecondaryDatabase db = openSecondaryDatabase
            (txn, fileAndDbNames, primaryIndex,
             secKeyMeta.getKeyName(), config, doNotCreate);
        if (db == null) {
            assert doNotCreate;
            return null;
View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

            }
            /* First try creating a new database, populate if needed. */
            if (config.getAllowCreate()) {
                config.setExclusiveCreate(true);
                /* AllowPopulate is true; comparators are set. */
                final SecondaryDatabase db = DbCompat.openSecondaryDatabase
                    (env, txn, fileAndDbNames[0], fileAndDbNames[1], priDb,
                     config);
                if (db != null) {
                    /* For unit testing. */
                    boolean doFlush = false;
                    /* Update dup ordering bug info. [#17252] */
                    if (config.getDuplicateComparator() != null &&
                        entityFormat.setSecKeyCorrectlyOrdered(keyName)) {
                        catalog.flush(txn);
                        doFlush = true;
                    }
                   
                    /*
                     * expectFlush is false except when set by
                     * SecondaryDupOrderTest.
                     */
                    assert !expectFlush || doFlush;
                   
                    return db;
                }
            }
            /* Next try opening an existing database. */
            config.setAllowCreate(false);
            config.setAllowPopulate(false);
            config.setExclusiveCreate(false);
           
            /* Account for dup ordering bug. [#17252] */
            if (config.getDuplicateComparator() != null &&
                entityFormat.isSecKeyIncorrectlyOrdered(keyName)) {
                /* <!-- begin JE only --> */
                config.setOverrideDuplicateComparator(false);
                /* <!-- end JE only --> */
                config.setDuplicateComparator((Comparator<byte[]>) null);
            }
            final SecondaryDatabase db = DbCompat.openSecondaryDatabase
                (env, txn, fileAndDbNames[0], fileAndDbNames[1], priDb,
                 config);
            return db;
        } finally {
            config.setAllowPopulate(true);
View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

   */
  public void get(IMetaData[] keys, ICache cache) throws Exception {
    // 检查是否有还未初始化的单项键值索引表
    for (IMetaData o : keys) {
      String name = o.getName();
      SecondaryDatabase db = dbKeys.get(name);
      if (db == null) {
        synchronized (this) {
          db = dbKeys.get(name);
          if (db == null) {
            dbKeys.put(name, env.openSecondaryDatabase(null, name, dbMain,
View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

   *          关键字名称
   * @throws Exception
   *           数据操作异常
   */
  public void clear(String name) throws Exception {
    SecondaryDatabase db = dbKeys.get(name);
    if (db != null) {
      Transaction tran = env.beginTransaction(null, null);
      DatabaseEntry key = new DatabaseEntry();
      DatabaseEntry pKey = new DatabaseEntry();
      DatabaseEntry data = new DatabaseEntry();
      try {
        SecondaryCursor cursor = db.openSecondaryCursor(tran, null);
        try {
          while (cursor.getNext(key, pKey, data, null) == OperationStatus.SUCCESS) {
            cursor.delete();
            dataBinding.entryToObject(data).remove();
          }
View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

      DatabaseEntry data = new DatabaseEntry();
      List<DatabaseEntry> entries = new ArrayList<DatabaseEntry>();
      try {
        for (int i = 0; i < size; i++) {
          IMetaData o = keys[i];
          SecondaryDatabase db = dbKeys.get(o.getName());
          if (db == null) {
            return;
          }
          SecondaryCursor cursor = db.openSecondaryCursor(null, null);
          key.setData(o.getBytes());
          cursor.getSearchKey(key, data, null);
          cursors[i] = cursor;
        }
        JoinCursor joinCursor = dbMain.join(cursors, null);
View Full Code Here

Examples of com.sleepycat.je.SecondaryDatabase

   *          缓存关键字
   * @throws Exception
   *           数据操作异常
   */
  private void clear(IMetaData data) throws Exception {
    SecondaryDatabase db = dbKeys.get(data.getName());
    if (db != null) {
      Transaction tran = env.beginTransaction(null, null);
      DatabaseEntry key = new DatabaseEntry(data.getBytes());
      DatabaseEntry pKey = new DatabaseEntry();
      DatabaseEntry pData = new DatabaseEntry();
      try {
        SecondaryCursor cursor = db.openSecondaryCursor(tran, null);
        try {
          OperationStatus ret = cursor.getSearchKey(key, pKey, pData, null);
          while (ret == OperationStatus.SUCCESS) {
            cursor.delete();
            dataBinding.entryToObject(pData).remove();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.