我对 Berkeley DB for .NET 3.5(确切地说是 5.0.21 版)有疑问。
primaryKeyDuplicatesPolicy = DuplicatesPolicy.NONE
这是我的设置在主数据库上使用时效果很好:
var btcfg = new BTreeDatabaseConfig
{
Duplicates = primaryKeyDuplicatesPolicy,
Creation = CreatePolicy.IF_NEEDED,
FreeThreaded = false,
ErrorPrefix = "bdbIndex",
ReadUncommitted = false,
UseMVCC = false,
CacheSize = new CacheInfo(cacheSize, 0, 1),
};
var primaryDb = BTreeDatabase.Open(additionalPath + "primary.db", btcfg);
var secondaryDb = SecondaryBTreeDatabase.Open(additionalPath + "secondary.db",
new SecondaryBTreeDatabaseConfig(PrimaryDb, GetSecondaryDbKey)
{
AutoCommit = btcfg.AutoCommit,
Creation = CreatePolicy.IF_NEEDED,
FreeThreaded = btcfg.FreeThreaded,
ErrorPrefix = btcfg.ErrorPrefix,
ReadUncommitted = btcfg.ReadUncommitted,
UseMVCC = btcfg.UseMVCC,
Env = env,
Duplicates = DuplicatesPolicy.NONE
});
现在,一旦我更改primaryKeyDuplicatesPolicy
为任何其他值,一切都会SecondaryBTreeDatabase.Open()
以 exception中断BerkeleyDB.DatabaseException : Invalid argument
。
那么,是否有可能在主数据库中有重复的辅助数据库?(据我了解,手册说是的,这是可能的)。
其次,我做错了什么,我应该怎么做才能使这件事起作用?
PS:我试过初始化环境,但这没有帮助。此外,目前将逻辑拆分为两个主数据库会很痛苦。