本文整理汇总了C#中BerkeleyDB.BTreeDatabaseConfig类的典型用法代码示例。如果您正苦于以下问题:C# BTreeDatabaseConfig类的具体用法?C# BTreeDatabaseConfig怎么用?C# BTreeDatabaseConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BTreeDatabaseConfig类属于BerkeleyDB命名空间,在下文中一共展示了BTreeDatabaseConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigCase1
public void ConfigCase1(BTreeDatabaseConfig dbConfig)
{
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Duplicates = DuplicatesPolicy.UNSORTED;
dbConfig.PageSize = 4096;
dbConfig.MinKeysPerPage = 10;
}
示例2: Config
private void Config(BTreeDatabaseConfig cfg) {
base.Config(cfg);
/*
* Database.Config calls set_flags, but that does not get the BTree
* specific flags. No harm in calling it again.
*/
db.set_flags(cfg.flags);
if (cfg.BlobDir != null && cfg.Env == null)
db.set_blob_dir(cfg.BlobDir);
if (cfg.blobThresholdIsSet)
db.set_blob_threshold(cfg.BlobThreshold, 0);
if (cfg.BTreeCompare != null)
Compare = cfg.BTreeCompare;
if (cfg.BTreePrefixCompare != null)
PrefixCompare = cfg.BTreePrefixCompare;
// The duplicate comparison function cannot change.
if (cfg.DuplicateCompare != null)
DupCompare = cfg.DuplicateCompare;
if (cfg.minkeysIsSet)
db.set_bt_minkey(cfg.MinKeysPerPage);
if (cfg.compressionIsSet) {
Compress = cfg.Compress;
Decompress = cfg.Decompress;
if (Compress == null)
doCompressRef = null;
else
doCompressRef = new BDB_CompressDelegate(doCompress);
if (Decompress == null)
doDecompressRef = null;
else
doDecompressRef = new BDB_DecompressDelegate(doDecompress);
db.set_bt_compress(doCompressRef, doDecompressRef);
}
if (cfg.partitionIsSet) {
nparts = cfg.NParts;
Partition = cfg.Partition;
if (Partition == null)
doPartitionRef = null;
else
doPartitionRef = new BDB_PartitionDelegate(doPartition);
partitionKeys = cfg.PartitionKeys;
IntPtr[] ptrs = null;
if (partitionKeys != null) {
int size = (int)nparts - 1;
ptrs = new IntPtr[size];
for (int i = 0; i < size; i++)
ptrs[i] = DBT.getCPtr(
DatabaseEntry.getDBT(partitionKeys[i])).Handle;
}
db.set_partition(nparts, ptrs, doPartitionRef);
}
}
示例3: OpenBase
private void OpenBase()
{
var pathStr = Environment.GetEnvironmentVariable("PATH");
var pwd = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
pwd = Path.Combine(pwd, IntPtr.Size == 4 ? "x86" : "x64");
if (pathStr != null && !pathStr.Contains(pwd))
{
pwd += ";" + Environment.GetEnvironmentVariable("PATH");
Environment.SetEnvironmentVariable("PATH", pwd);
}
_btreeConfig = new BTreeDatabaseConfig
{
Duplicates = DuplicatesPolicy.NONE,
ErrorPrefix = "QH_" + Path.GetFileName(_dbPAth),
Creation = CreatePolicy.IF_NEEDED,
FreeThreaded = true
};
if (_env != null)
{
_btreeConfig.Env = _env;
}
_btreeDb = BTreeDatabase.Open(_dbPAth, _name, _btreeConfig);
}
示例4: Config
private void Config(BTreeDatabaseConfig cfg) {
base.Config(cfg);
/*
* Database.Config calls set_flags, but that doesn't get the BTree
* specific flags. No harm in calling it again.
*/
db.set_flags(cfg.flags);
if (cfg.BTreeCompare != null)
Compare = cfg.BTreeCompare;
if (cfg.BTreePrefixCompare != null)
PrefixCompare = cfg.BTreePrefixCompare;
// The duplicate comparison function cannot change.
if (cfg.DuplicateCompare != null)
DupCompare = cfg.DuplicateCompare;
if (cfg.minkeysIsSet)
db.set_bt_minkey(cfg.MinKeysPerPage);
if (cfg.compressionIsSet) {
Compress = cfg.Compress;
Decompress = cfg.Decompress;
if (Compress == null)
doCompressRef = null;
else
doCompressRef = new BDB_CompressDelegate(doCompress);
if (Decompress == null)
doDecompressRef = null;
else
doDecompressRef = new BDB_DecompressDelegate(doDecompress);
db.set_bt_compress(doCompressRef, doDecompressRef);
}
}
示例5: GetCursorInBtreeDBUsingRecno
public void GetCursorInBtreeDBUsingRecno(string home,
string name, out BTreeDatabase db,
out BTreeCursor cursor)
{
string dbFileName = home + "/" + name + ".db";
BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
dbConfig.UseRecordNumbers = true;
dbConfig.Creation = CreatePolicy.IF_NEEDED;
db = BTreeDatabase.Open(dbFileName, dbConfig);
cursor = db.Cursor();
}
示例6: Init
public override void Init(int flowCount, long flowRecordCount)
{
BTreeDatabaseConfig config = new BTreeDatabaseConfig();
config.Creation = CreatePolicy.IF_NEEDED;
config.CacheSize = new CacheInfo(5, 0, 2);
config.PageSize = 8 * 1024;
config.BTreeCompare = new EntryComparisonDelegate(CompareFunctionKeyByteArray);
config.Duplicates = DuplicatesPolicy.NONE;
string fileName = Path.Combine(DataDirectory, string.Format("{0}.oracle", CollectionName));
database = BTreeDatabase.Open(fileName, config);
}
示例7: GetSecondaryCursurWithTxn
public void GetSecondaryCursurWithTxn(string home,
string name, bool ifCfg)
{
string dbFileName = name + ".db";
SecondaryCursor cursor;
// Open env.
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseTxns = true;
envConfig.UseMPool = true;
DatabaseEnvironment env = DatabaseEnvironment.Open(home,
envConfig);
// Open primary/secondary database.
Transaction txn = env.BeginTransaction();
BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
BTreeDatabase db = BTreeDatabase.Open(dbFileName,
dbConfig, txn);
SecondaryBTreeDatabaseConfig secDBConfig = new
SecondaryBTreeDatabaseConfig(db,
new SecondaryKeyGenDelegate(SecondaryKeyGen));
secDBConfig.Env = env;
SecondaryBTreeDatabase secDB =
SecondaryBTreeDatabase.Open(dbFileName,
secDBConfig, txn);
for (int i = 0; i < 10; i++)
db.Put(new DatabaseEntry(BitConverter.GetBytes(i)),
new DatabaseEntry(BitConverter.GetBytes((int)i)), txn);
// Create secondary cursor.
if (ifCfg == false)
secDB.SecondaryCursor(txn);
else if (ifCfg == true)
{
CursorConfig cursorConfig = new CursorConfig();
cursorConfig.WriteCursor = false;
cursor = secDB.SecondaryCursor(cursorConfig, txn);
cursor.Close();
}
secDB.Close();
db.Close();
txn.Commit();
env.Close();
}
示例8: TestCompare
public void TestCompare()
{
testName = "TestCompare";
SetUpTest(true);
string dbFileName = testHome + "/" + testName + ".db";
// Open a primary btree database.
BTreeDatabaseConfig btreeDBConfig =
new BTreeDatabaseConfig();
btreeDBConfig.Creation = CreatePolicy.ALWAYS;
BTreeDatabase btreeDB = BTreeDatabase.Open(
dbFileName, btreeDBConfig);
// Open a secondary btree database.
SecondaryBTreeDatabaseConfig secBtreeDBConfig =
new SecondaryBTreeDatabaseConfig(null, null);
secBtreeDBConfig.Primary = btreeDB;
secBtreeDBConfig.Compare =
new EntryComparisonDelegate(
SecondaryEntryComparison);
secBtreeDBConfig.KeyGen =
new SecondaryKeyGenDelegate(SecondaryKeyGen);
SecondaryBTreeDatabase secDB =
SecondaryBTreeDatabase.Open(
dbFileName, secBtreeDBConfig);
/*
* Get the compare function set in the configuration
* and run it in a comparison to see if it is alright.
*/
EntryComparisonDelegate cmp =
secDB.Compare;
DatabaseEntry dbt1, dbt2;
dbt1 = new DatabaseEntry(
BitConverter.GetBytes((int)257));
dbt2 = new DatabaseEntry(
BitConverter.GetBytes((int)255));
Assert.Less(0, cmp(dbt1, dbt2));
for (int i = 0; i < 1000; i++)
btreeDB.Put(new DatabaseEntry(
BitConverter.GetBytes(i)), new DatabaseEntry(
BitConverter.GetBytes(i)));
secDB.Close();
btreeDB.Close();
}
示例9: OpenBtreeDBInEnv
public void OpenBtreeDBInEnv(string dbName,
DatabaseEnvironment env, out BTreeDatabase db,
bool create, Transaction txn)
{
BTreeDatabaseConfig btreeDBConfig =
new BTreeDatabaseConfig();
btreeDBConfig.Env = env;
if (create == true)
btreeDBConfig.Creation = CreatePolicy.IF_NEEDED;
else
btreeDBConfig.Creation = CreatePolicy.NEVER;
if (txn == null)
db = BTreeDatabase.Open(dbName,
btreeDBConfig);
else
db = BTreeDatabase.Open(dbName,
btreeDBConfig, txn);
}
示例10: Open
public BTreeDatabase Open(DatabaseEnvironment env, bool isMaster)
{
string dbName = "rep.db";
// Set up the database.
BTreeDatabaseConfig dbCfg = new BTreeDatabaseConfig();
dbCfg.Env = env;
if (isMaster)
dbCfg.Creation = CreatePolicy.IF_NEEDED;
dbCfg.AutoCommit = true;
dbCfg.FreeThreaded = true;
/*
* Open the database. Do not provide a txn handle. This
* Open is autocommitted because BTreeDatabaseConfig.AutoCommit
* is true.
*/
return BTreeDatabase.Open(dbName, dbCfg);
}
示例11: Confirm
public static void Confirm(XmlElement
xmlElement, BTreeDatabaseConfig btreeDBConfig,
bool compulsory)
{
DatabaseConfig dbConfig = btreeDBConfig;
Confirm(xmlElement, dbConfig, compulsory);
// Confirm Btree database specific configuration
Configuration.ConfirmDuplicatesPolicy(xmlElement,
"Duplicates", btreeDBConfig.Duplicates, compulsory);
Configuration.ConfirmBool(xmlElement,
"NoReverseSplitting",
btreeDBConfig.NoReverseSplitting, compulsory);
Configuration.ConfirmBool(xmlElement,
"UseRecordNumbers", btreeDBConfig.UseRecordNumbers,
compulsory);
Configuration.ConfirmCreatePolicy(xmlElement,
"Creation", btreeDBConfig.Creation, compulsory);
Configuration.ConfirmUint(xmlElement, "MinKeysPerPage",
btreeDBConfig.MinKeysPerPage, compulsory);
}
示例12: TestConfig
public virtual void TestConfig()
{
testName = "TestConfig";
SetUpTest(true);
string dbFileName = testHome + "/" + testName;
XmlElement xmlElem = Configuration.TestSetUp(
testFixtureName, testName);
// Open a primary btree database.
BTreeDatabaseConfig btreeDBConfig =
new BTreeDatabaseConfig();
btreeDBConfig.Creation = CreatePolicy.IF_NEEDED;
BTreeDatabase btreeDB = BTreeDatabase.Open(
dbFileName, btreeDBConfig);
SecondaryDatabaseConfig secDBConfig =
new SecondaryDatabaseConfig(btreeDB, null);
Config(xmlElem, ref secDBConfig, true);
Confirm(xmlElem, secDBConfig, true);
btreeDB.Close();
}
示例13: Config
public static void Config(XmlElement xmlElement,
ref BTreeDatabaseConfig btreeDBConfig, bool compulsory)
{
uint minKeysPerPage = new uint();
DatabaseConfig dbConfig = btreeDBConfig;
Config(xmlElement, ref dbConfig, compulsory);
// Configure specific fields/properties of Btree db
Configuration.ConfigDuplicatesPolicy(xmlElement,
"Duplicates", ref btreeDBConfig.Duplicates,
compulsory);
Configuration.ConfigBool(xmlElement,
"NoReverseSplitting",
ref btreeDBConfig.NoReverseSplitting, compulsory);
Configuration.ConfigBool(xmlElement,
"UseRecordNumbers",
ref btreeDBConfig.UseRecordNumbers, compulsory);
Configuration.ConfigCreatePolicy(xmlElement,
"Creation", ref btreeDBConfig.Creation, compulsory);
if (Configuration.ConfigUint(xmlElement,
"MinKeysPerPage", ref minKeysPerPage, compulsory))
btreeDBConfig.MinKeysPerPage = minKeysPerPage;
}
示例14: OpenNewSequence
public void OpenNewSequence(string dbFileName,
out BTreeDatabase db, out Sequence seq)
{
// Open a database.
BTreeDatabaseConfig btreeDBConfig =
new BTreeDatabaseConfig();
btreeDBConfig.Creation = CreatePolicy.IF_NEEDED;
db = BTreeDatabase.Open(dbFileName, btreeDBConfig);
// Configure and initialize sequence.
SequenceConfig seqConfig = new SequenceConfig();
seqConfig.BackingDatabase = db;
seqConfig.CacheSize = 1000;
seqConfig.Creation = CreatePolicy.ALWAYS;
seqConfig.Decrement = false;
seqConfig.FreeThreaded = true;
seqConfig.Increment = true;
seqConfig.InitialValue = 100;
seqConfig.key = new DatabaseEntry(
ASCIIEncoding.ASCII.GetBytes("key"));
seqConfig.SetRange(Int64.MinValue, Int64.MaxValue);
seqConfig.Wrap = true;
seq = new Sequence(seqConfig);
}
示例15: OpenNewSequenceInEnv
public void OpenNewSequenceInEnv(string home, string dbname,
out DatabaseEnvironment env, out BTreeDatabase db,
out Sequence seq)
{
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseTxns = true;
envConfig.UseMPool = true;
envConfig.UseLogging = true;
env = DatabaseEnvironment.Open(home, envConfig);
Transaction openTxn = env.BeginTransaction();
BTreeDatabaseConfig dbConfig =
new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
db = BTreeDatabase.Open(dbname + ".db", dbConfig,
openTxn);
openTxn.Commit();
Transaction seqTxn = env.BeginTransaction();
SequenceConfig seqConfig = new SequenceConfig();
seqConfig.BackingDatabase = db;
seqConfig.Creation = CreatePolicy.ALWAYS;
seqConfig.Decrement = false;
seqConfig.FreeThreaded = true;
seqConfig.Increment = true;
seqConfig.InitialValue = 0;
seqConfig.key = new DatabaseEntry(
ASCIIEncoding.ASCII.GetBytes("key"));
seqConfig.SetRange(Int64.MinValue, Int64.MaxValue);
seqConfig.Wrap = true;
seq = new Sequence(seqConfig);
seqTxn.Commit();
}