本文整理汇总了C#中BerkeleyDB.BTreeDatabase.Cursor方法的典型用法代码示例。如果您正苦于以下问题:C# BTreeDatabase.Cursor方法的具体用法?C# BTreeDatabase.Cursor怎么用?C# BTreeDatabase.Cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BerkeleyDB.BTreeDatabase
的用法示例。
在下文中一共展示了BTreeDatabase.Cursor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: GetCursorInBtreeDB
public static void GetCursorInBtreeDB(
string home, string name,
CursorConfig cursorConfig,
out DatabaseEnvironment env, out BTreeDatabase db,
out BTreeCursor cursor)
{
string dbFileName = name + ".db";
Configuration.ClearDir(home);
// Open an environment.
DatabaseEnvironmentConfig envConfig =
new DatabaseEnvironmentConfig();
envConfig.Create = true;
envConfig.UseMPool = true;
envConfig.UseTxns = true;
envConfig.NoMMap = false;
envConfig.UseLocking = true;
env = DatabaseEnvironment.Open(home, envConfig);
/*
* Open an btree database. The underlying database
* should be opened with ReadUncommitted if the
* cursor's isolation degree will be set to be 1.
*/
BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
if (cursorConfig.IsolationDegree == Isolation.DEGREE_ONE)
dbConfig.ReadUncommitted = true;
db = BTreeDatabase.Open(dbFileName, dbConfig, null);
// Get a cursor in the transaction.
cursor = db.Cursor(cursorConfig, null);
}
示例3: GetCursorInBtreeDBWithoutEnv
public static void GetCursorInBtreeDBWithoutEnv(
string home, string name, out BTreeDatabase db,
out BTreeCursor cursor)
{
string dbFileName = home + "/" + name + ".db";
BTreeDatabaseConfig dbConfig =
new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Duplicates = DuplicatesPolicy.UNSORTED;
db = BTreeDatabase.Open(dbFileName, dbConfig);
cursor = db.Cursor();
}
示例4: GetMultipleDB
private void GetMultipleDB(string dbFileName,
BTreeDatabaseConfig dbConfig, Transaction txn,
out BTreeDatabase db, out BTreeCursor cursor)
{
if (txn == null) {
db = BTreeDatabase.Open(dbFileName, dbConfig);
cursor = db.Cursor();
} else {
db = BTreeDatabase.Open(
dbFileName, dbConfig, txn);
CursorConfig cursorConfig = new CursorConfig();
cursor = db.Cursor(cursorConfig, txn);
}
KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
DatabaseEntry key, data;
for (int i = 1; i < 100; i++) {
key = new DatabaseEntry(BitConverter.GetBytes(i));
data = new DatabaseEntry(BitConverter.GetBytes(i));
pair = new KeyValuePair<DatabaseEntry, DatabaseEntry>(key, data);
cursor.Add(pair);
}
if (dbConfig.UseRecordNumbers == true) {
byte[] bytes = new byte[512];
for (int i = 0; i < 512; i++)
bytes[i] = (byte)i;
key = new DatabaseEntry(BitConverter.GetBytes(100));
data = new DatabaseEntry(bytes);
pair = new KeyValuePair<DatabaseEntry, DatabaseEntry>(key, data);
cursor.Add(pair);
} else {
if (dbConfig.Duplicates == DuplicatesPolicy.UNSORTED ||
dbConfig.Duplicates == DuplicatesPolicy.SORTED) {
key = new DatabaseEntry(BitConverter.GetBytes(99));
data = new DatabaseEntry(BitConverter.GetBytes(100));
pair = new KeyValuePair<DatabaseEntry, DatabaseEntry>(key, data);
cursor.Add(pair);
}
key = new DatabaseEntry(BitConverter.GetBytes(101));
data = new DatabaseEntry(BitConverter.GetBytes(101));
pair = new KeyValuePair<DatabaseEntry, DatabaseEntry>(key, data);
cursor.Add(pair);
}
}