本文整理汇总了C#中Btree.CompareByteArrays方法的典型用法代码示例。如果您正苦于以下问题:C# Btree.CompareByteArrays方法的具体用法?C# Btree.CompareByteArrays怎么用?C# Btree.CompareByteArrays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Btree
的用法示例。
在下文中一共展示了Btree.CompareByteArrays方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Remove
internal static int Remove(StorageImpl db, int pageId, Btree tree, BtreeKey rem, int height)
{
Page pg = db.GetPage(pageId);
try
{
int i, n = GetItemsCount(pg), l = 0, r = n;
if (tree.type == ClassDescriptor.tpString)
{
while (l < r)
{
i = (l + r) >> 1;
if (CompareStr(rem.key, pg, i) > 0)
{
l = i + 1;
}
else
{
r = i;
}
}
if (--height != 0)
{
do
{
switch (Remove(db, GetKeyStrOid(pg, r), tree, rem, height))
{
case Btree.op_underflow:
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
return HandlePageUnderflow(db, pg, r, tree.type, rem, height);
case Btree.op_done:
return Btree.op_done;
case Btree.op_overflow:
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
return InsertStrKey(db, pg, r, rem, height);
}
}
while (++r <= n);
}
else
{
while (r < n)
{
if (CompareStr(rem.key, pg, r) == 0)
{
int oid = GetKeyStrOid(pg, r);
if (oid == rem.oid || rem.oid == 0)
{
rem.oldOid = oid;
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
return RemoveStrKey(pg, r);
}
}
else
{
break;
}
r += 1;
}
}
}
else if (tree.type == ClassDescriptor.tpArrayOfByte)
{
while (l < r)
{
i = (l + r) >> 1;
if (tree.CompareByteArrays(rem.key, pg, i) > 0)
{
l = i + 1;
}
else
{
r = i;
}
}
if (--height != 0)
{
do
{
switch (Remove(db, GetKeyStrOid(pg, r), tree, rem, height))
{
case Btree.op_underflow:
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
return HandlePageUnderflow(db, pg, r, tree.type, rem, height);
case Btree.op_done:
return Btree.op_done;
case Btree.op_overflow:
db.pool.Unfix(pg);
//.........这里部分代码省略.........
示例2: Find
internal static bool Find(StorageImpl db, int pageId, Key firstKey, Key lastKey, Btree tree, int height, ArrayList result)
{
Page pg = db.GetPage(pageId);
int l = 0, n = GetItemsCount(pg), r = n;
int oid;
height -= 1;
try
{
if (tree.type == ClassDescriptor.tpString)
{
if (firstKey != null)
{
while (l < r)
{
int i = (l + r) >> 1;
if (CompareStr(firstKey, pg, i) >= firstKey.inclusion)
{
l = i + 1;
}
else
{
r = i;
}
}
Assert.That(r == l);
}
if (lastKey != null)
{
if (height == 0)
{
while (l < n)
{
if (-CompareStr(lastKey, pg, l) >= lastKey.inclusion)
{
return false;
}
oid = GetKeyStrOid(pg, l);
result.Add(db.LookupObject(oid, null));
l += 1;
}
}
else
{
do
{
if (!Find(db, GetKeyStrOid(pg, l), firstKey, lastKey, tree, height, result))
{
return false;
}
if (l == n)
{
return true;
}
}
while (CompareStr(lastKey, pg, l++) >= 0);
return false;
}
}
else
{
if (height == 0)
{
while (l < n)
{
oid = GetKeyStrOid(pg, l);
result.Add(db.LookupObject(oid, null));
l += 1;
}
}
else
{
do
{
if (!Find(db, GetKeyStrOid(pg, l), firstKey, lastKey, tree, height, result))
{
return false;
}
}
while (++l <= n);
}
}
}
else if (tree.type == ClassDescriptor.tpArrayOfByte)
{
if (firstKey != null)
{
while (l < r)
{
int i = (l + r) >> 1;
if (tree.CompareByteArrays(firstKey, pg, i) >= firstKey.inclusion)
{
l = i + 1;
}
else
{
r = i;
}
}
Assert.That(r == l);
}
//.........这里部分代码省略.........
示例3: Insert
internal static int Insert(StorageImpl db, int pageId, Btree tree, BtreeKey ins, int height, bool unique, bool overwrite)
{
Page pg = db.GetPage(pageId);
int result;
int l = 0, n = GetItemsCount(pg), r = n;
try
{
if (tree.type == ClassDescriptor.tpString)
{
while (l < r)
{
int i = (l + r) >> 1;
if (CompareStr(ins.key, pg, i) > 0)
{
l = i + 1;
}
else
{
r = i;
}
}
Assert.That(l == r);
if (--height != 0)
{
result = Insert(db, GetKeyStrOid(pg, r), tree, ins, height, unique, overwrite);
Assert.That(result != Btree.op_not_found);
if (result != Btree.op_overflow)
{
return result;
}
}
else if (r < n && CompareStr(ins.key, pg, r) == 0)
{
if (overwrite)
{
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
ins.oldOid = GetKeyStrOid(pg, r);
SetKeyStrOid(pg, r, ins.oid);
return Btree.op_overwrite;
}
else if (unique)
{
return Btree.op_duplicate;
}
}
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
return InsertStrKey(db, pg, r, ins, height);
}
else if (tree.type == ClassDescriptor.tpArrayOfByte)
{
while (l < r)
{
int i = (l + r) >> 1;
if (tree.CompareByteArrays(ins.key, pg, i) > 0)
{
l = i + 1;
}
else
{
r = i;
}
}
Assert.That(l == r);
if (--height != 0)
{
result = Insert(db, GetKeyStrOid(pg, r), tree, ins, height, unique, overwrite);
Assert.That(result != Btree.op_not_found);
if (result != Btree.op_overflow)
{
return result;
}
}
else if (r < n && tree.CompareByteArrays(ins.key, pg, r) == 0)
{
if (overwrite)
{
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
ins.oldOid = GetKeyStrOid(pg, r);
SetKeyStrOid(pg, r, ins.oid);
return Btree.op_overwrite;
}
else if (unique)
{
return Btree.op_duplicate;
}
}
db.pool.Unfix(pg);
pg = null;
pg = db.PutPage(pageId);
return InsertByteArrayKey(db, pg, r, ins, height);
}
else
{
while (l < r)
//.........这里部分代码省略.........