本文整理汇总了Java中com.sleepycat.je.SecondaryConfig.setMultiKeyCreator方法的典型用法代码示例。如果您正苦于以下问题:Java SecondaryConfig.setMultiKeyCreator方法的具体用法?Java SecondaryConfig.setMultiKeyCreator怎么用?Java SecondaryConfig.setMultiKeyCreator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.je.SecondaryConfig
的用法示例。
在下文中一共展示了SecondaryConfig.setMultiKeyCreator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openSecondary
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的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);
}
}
示例2: openSecondary
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的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);
}
}
示例3: openSecondary
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的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;
}
示例4: openSecondary
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb, String dbName,
Database foreignDb,
ForeignKeyDeleteAction onDelete)
throws DatabaseException {
SecondaryConfig dbConfig = new SecondaryConfig();
dbConfig.setTransactional(isTransactional);
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
MyKeyCreator keyCreator = new MyKeyCreator();
if (useMultiKey) {
dbConfig.setMultiKeyCreator(new SimpleMultiKeyCreator(keyCreator));
} else {
dbConfig.setKeyCreator(keyCreator);
}
if (foreignDb != null) {
if (useMultiKey) {
dbConfig.setForeignMultiKeyNullifier(keyCreator);
} else {
dbConfig.setForeignKeyNullifier(keyCreator);
}
dbConfig.setForeignKeyDatabase(foreignDb);
dbConfig.setForeignKeyDeleteAction(onDelete);
}
Transaction txn = txnBegin();
try {
return env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
} finally {
txnCommit(txn);
}
}
示例5: init
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
@Override
public void init() throws DatabaseException {
SecondaryConfig config = new SecondaryConfig();
config.setAllowCreate(true);
config.setAllowPopulate(true);
config.setTransactional(true);
config.setImmutableSecondaryKey(immutableSecondaryKey);
config.setSortedDuplicates(sortedDuplicates);
config.setMultiKeyCreator(keyCreator);
db = primary.envWrap.env.openSecondaryDatabase(null, name, primary.db, config);
}
示例6: openSecondary
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb,
boolean allowDuplicates,
String dbName,
boolean allowPopulate,
boolean readOnly)
throws DatabaseException {
List secListBefore = priDb.getSecondaryDatabases();
SecondaryConfig dbConfig = new SecondaryConfig();
dbConfig.setTransactional(isTransactional);
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(allowDuplicates);
dbConfig.setReadOnly(readOnly);
dbConfig.setAllowPopulate(allowPopulate);
if (!readOnly) {
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);
}
assertNotNull(secDb);
/* Check configuration. */
assertSame(priDb, secDb.getPrimaryDatabase());
SecondaryConfig config2 = secDb.getSecondaryConfig();
assertEquals(allowPopulate, config2.getAllowPopulate());
assertEquals(dbConfig.getKeyCreator(), config2.getKeyCreator());
/* Make sure the new secondary is added to the primary's list. */
List secListAfter = priDb.getSecondaryDatabases();
assertTrue(secListAfter.remove(secDb));
assertEquals(secListBefore, secListAfter);
return secDb;
}
示例7: openSecondary
import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb,
boolean allowDuplicates,
String dbName,
boolean allowPopulate,
boolean readOnly)
throws DatabaseException {
List secListBefore = priDb.getSecondaryDatabases();
SecondaryConfig dbConfig = new SecondaryConfig();
dbConfig.setTransactional(isTransactional);
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(allowDuplicates);
dbConfig.setReadOnly(readOnly);
dbConfig.setAllowPopulate(allowPopulate);
if (!readOnly) {
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);
}
assertNotNull(secDb);
/* Check configuration. */
assertSame(priDb, secDb.getPrimaryDatabase());
SecondaryConfig config2 = secDb.getSecondaryConfig();
assertEquals(allowPopulate, config2.getAllowPopulate());
assertEquals(dbConfig.getKeyCreator(), config2.getKeyCreator());
/* Make sure the new secondary is added to the primary's list. */
List secListAfter = priDb.getSecondaryDatabases();
assertTrue(secListAfter.remove(secDb));
assertEquals(secListBefore, secListAfter);
return secDb;
}