当前位置: 首页>>代码示例>>Java>>正文


Java SecondaryDatabase类代码示例

本文整理汇总了Java中com.sleepycat.je.SecondaryDatabase的典型用法代码示例。如果您正苦于以下问题:Java SecondaryDatabase类的具体用法?Java SecondaryDatabase怎么用?Java SecondaryDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SecondaryDatabase类属于com.sleepycat.je包,在下文中一共展示了SecondaryDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSecondaryKey

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
public boolean createSecondaryKey(SecondaryDatabase secondaryDb,
                                  DatabaseEntry keyEntry,
                                  DatabaseEntry dataEntry,
                                  DatabaseEntry resultEntry)
    throws DatabaseException {

    /*
     * Convert the data entry to an Event object, extract the secondary
     * key value from it, and then convert it to the resulting
     * secondary key entry.
     */
    Event e  = (Event) dataBinding.entryToObject(dataEntry);
    int price = e.getPrice();
    IntegerBinding.intToEntry(price, resultEntry);
    return true;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:EventExample.java

示例2: createSecondaryKey

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
public boolean createSecondaryKey(SecondaryDatabase secDb,
         DatabaseEntry keyEntry,    // From the primary
         DatabaseEntry dataEntry,   // From the primary
         DatabaseEntry resultEntry) // set the key data on this.
     throws DatabaseException {

    if (dataEntry != null) {
        // Convert dataEntry to an Inventory object
        Inventory inventoryItem =
              (Inventory)theBinding.entryToObject(dataEntry);
        // Get the item name and use that as the key
        String theItem = inventoryItem.getItemName();
        try {
            resultEntry.setData(theItem.getBytes("UTF-8"));
        } catch (IOException willNeverOccur) {}
    }
    return true;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:ItemNameKeyCreator.java

示例3: printByIndex

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
/**
 * Prints all person records by a given secondary index.
 */
private void printByIndex(SecondaryDatabase secDb)
    throws DatabaseException {

    DatabaseEntry secKey = new DatabaseEntry();
    DatabaseEntry priKey = new DatabaseEntry();
    DatabaseEntry priData = new DatabaseEntry();

    SecondaryCursor cursor = secDb.openSecondaryCursor(null, null);
    try {
        while (cursor.getNext(secKey, priKey, priData, null) ==
               OperationStatus.SUCCESS) {
            Person person = (Person) dataBinding.entryToObject(priData);
            person.name = (String) keyBinding.entryToObject(priKey);
            System.out.println("Index key [" +
                               keyBinding.entryToObject(secKey) +
                               "] maps to primary key [" +
                               person.name + ']');
        }
    } finally {
        cursor.close();
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:ToManyExample.java

示例4: createSecondaryKeyInternal

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
private boolean createSecondaryKeyInternal(SecondaryDatabase secondary,
                                           DatabaseEntry key,
                                           DatabaseEntry data,
                                           DatabaseEntry result)
    throws RefreshException {

    if (toMany) {
        throw DbCompat.unexpectedState();
    }
    KeyLocation loc = moveToKey(key, data);
    if (loc != null) {
        RecordOutput output = new RecordOutput
            (catalog, true /*rawAccess*/);
        loc.format.copySecKey(loc.input, output);
        TupleBase.outputToEntry(output, result);
        return true;
    } else {
        /* Key field is not present or null. */
        return false;
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:22,代码来源:PersistKeyCreator.java

示例5: createSecondaryKey

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
public boolean createSecondaryKey(SecondaryDatabase secondary,
			      DatabaseEntry key,
			      DatabaseEntry data,
			      DatabaseEntry result)
throws DatabaseException {

       if (toMany) {
           throw new IllegalStateException();
       }
       KeyLocation loc = moveToKey(key, data);
       if (loc != null) {
           RecordOutput output = new RecordOutput
               (catalog, true /*rawAccess*/);
           loc.format.copySecKey(loc.input, output);
           TupleBase.outputToEntry(output, result);
           return true;
       } else {
           /* Key field is not present or null. */
           return false;
       }
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:22,代码来源:PersistKeyCreator.java

示例6: openSecondaryDatabase

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
SecondaryDatabase openSecondaryDatabase(String dbName,
				    Database primaryDatabase,
				    SecondaryConfig config)
throws DatabaseException {

if (config.getReadOnly()) {
    synchronized (roSecondaryDatabaseHandleCache) {
	return openSecondaryDatabaseInternal
	    (roSecondaryDatabaseHandleCache, dbName,
	     primaryDatabase, config);
    }
} else {
    synchronized (rwSecondaryDatabaseHandleCache) {
	return openSecondaryDatabaseInternal
	    (rwSecondaryDatabaseHandleCache, dbName,
	     primaryDatabase, config);
    }
}
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:20,代码来源:JEManagedConnection.java

示例7: createSecondaryKey

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
public boolean createSecondaryKey(SecondaryDatabase db,
                                  DatabaseEntry primaryKeyEntry,
                                  DatabaseEntry dataEntry,
                                  DatabaseEntry indexKeyEntry)
    throws DatabaseException {

    TupleOutput output = getTupleOutput(null);
    TupleInput primaryKeyInput = entryToInput(primaryKeyEntry);
    TupleInput dataInput = entryToInput(dataEntry);
    if (createSecondaryKey(primaryKeyInput, dataInput, output)) {
        outputToEntry(output, indexKeyEntry);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:TupleTupleKeyCreator.java

示例8: openSecondaryDatabase

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
SecondaryDatabase openSecondaryDatabase(String dbName,
                                        Database primaryDatabase,
                                        SecondaryConfig config)
    throws DatabaseException {

    if (config.getReadOnly()) {
        synchronized (roSecondaryDatabaseHandleCache) {
            return openSecondaryDatabaseInternal
                (roSecondaryDatabaseHandleCache, dbName,
                 primaryDatabase, config);
        }
    } else {
        synchronized (rwSecondaryDatabaseHandleCache) {
            return openSecondaryDatabaseInternal
                (rwSecondaryDatabaseHandleCache, dbName,
                 primaryDatabase, config);
        }
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:20,代码来源:JEManagedConnection.java

示例9: openSecondary

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb, String dbName,
                                        boolean dups, int keyId)
    throws DatabaseException {

    SecondaryConfig dbConfig = new SecondaryConfig();
    dbConfig.setTransactional(isTransactional);
    dbConfig.setAllowCreate(true);
    dbConfig.setSortedDuplicates(dups);
    if (useMultiKey) {
        dbConfig.setMultiKeyCreator
            (new SimpleMultiKeyCreator(new MyKeyCreator(keyId)));
    } else {
        dbConfig.setKeyCreator(new MyKeyCreator(keyId));
    }

    Transaction txn = txnBegin();
    try {
        return env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
    } finally {
        txnCommit(txn);
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:23,代码来源:JoinTest.java

示例10: createSecondaryKey

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
public boolean createSecondaryKey(SecondaryDatabase db,
                                  DatabaseEntry primaryKeyEntry,
                                  DatabaseEntry dataEntry,
                                  DatabaseEntry indexKeyEntry)
    throws DatabaseException {

    Object primaryKeyInput =
        primaryKeyBinding.entryToObject(primaryKeyEntry);
    Object dataInput = dataBinding.entryToObject(dataEntry);
    Object indexKey = createSecondaryKey(primaryKeyInput, dataInput);
    if (indexKey != null) {
        indexKeyBinding.objectToEntry(indexKey, indexKeyEntry);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:18,代码来源:SerialSerialKeyCreator.java

示例11: openSecondaryDatabase

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
/**
 * Returns null if the database is not found (and AllowCreate is false) or
 * already exists (and ExclusiveCreate is true).
 */
public static SecondaryDatabase
    openSecondaryDatabase(Environment env,
                          Transaction txn,
                          String fileName,
                          String dbName,
                          Database primaryDatabase,
                          SecondaryConfig config) {
    assert fileName == null;
    try {
        return env.openSecondaryDatabase(txn, dbName, primaryDatabase,
                                         config);
    } catch (DatabaseNotFoundException e) {
        return null;
    } catch (DatabaseExistsException e) {
        return null;
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:22,代码来源:DbCompat.java

示例12: openSecondary

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb,
                                        String dbName,
                                        boolean dups)
    throws DatabaseException {

    SecondaryConfig dbConfig = new SecondaryConfig();
    dbConfig.setTransactional(isTransactional);
    dbConfig.setAllowCreate(true);
    dbConfig.setSortedDuplicates(dups);
    dbConfig.setMultiKeyCreator(new MyKeyCreator());

    Transaction txn = txnBegin();
    try {
        return env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
    } finally {
        txnCommit(txn);
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:ToManyTest.java

示例13: openSecondaryDb

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
private SecondaryDatabase openSecondaryDb(TupleSerialFactory factory,
                                          String keyName,
                                          Database primary,
                                          String file,
                                          Database foreignStore)
    throws Exception {

    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(testEnv.isTxnMode());
    secConfig.setAllowCreate(true);
    secConfig.setKeyCreator(factory.getKeyCreator(MarshalledObject.class,
                                                  keyName));
    if (foreignStore != null) {
        secConfig.setForeignKeyDatabase(foreignStore);
        secConfig.setForeignKeyDeleteAction(
                ForeignKeyDeleteAction.CASCADE);
    }

    return DbCompat.openSecondaryDatabase(env, null,
                                          file, null,
                                          primary, secConfig);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:23,代码来源:TupleSerialFactoryTest.java

示例14: openSecondary

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
/**
 * Opens the secondary database.
 */
private SecondaryDatabase openSecondary(Database priDb, String dbName,
                                        boolean allowDuplicates)
    throws DatabaseException {

    SecondaryConfig dbConfig = new SecondaryConfig();
    dbConfig.setTransactional(isTransactional);
    dbConfig.setAllowCreate(true);
    dbConfig.setSortedDuplicates(allowDuplicates);
    if (useMultiKey) {
        dbConfig.setMultiKeyCreator
            (new SimpleMultiKeyCreator(new MyKeyCreator()));
    } else {
        dbConfig.setKeyCreator(new MyKeyCreator());
    }
    Transaction txn = txnBegin();
    SecondaryDatabase secDb;
    try {
        secDb = env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
    } finally {
        txnCommit(txn);
    }
    return secDb;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:27,代码来源:SecondaryDirtyReadTest.java

示例15: openSecondaryDb

import com.sleepycat.je.SecondaryDatabase; //导入依赖的package包/类
private SecondaryDatabase openSecondaryDb(Database primary,
                                          String file,
                                          String keyName)
    throws Exception {

    SecondaryConfig secConfig = new SecondaryConfig();
    DbCompat.setTypeBtree(secConfig);
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    DbCompat.setSortedDuplicates(secConfig, true);
    secConfig.setKeyCreator(factory.getKeyCreator(MarshalledObject.class,
                                                  keyName));

    return DbCompat.openSecondaryDatabase(env, null,
                                          file, null,
                                          primary, secConfig);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:18,代码来源:JoinTest.java


注:本文中的com.sleepycat.je.SecondaryDatabase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。