本文整理汇总了C#中Btree.compareByteArrays方法的典型用法代码示例。如果您正苦于以下问题:C# Btree.compareByteArrays方法的具体用法?C# Btree.compareByteArrays怎么用?C# Btree.compareByteArrays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Btree
的用法示例。
在下文中一共展示了Btree.compareByteArrays方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: remove
internal static BtreeResult remove(StorageImpl db, int pageId, Btree tree, BtreeKey rem, int height)
{
Page pg = db.getPage(pageId);
try
{
int i, n = getnItems(pg), l = 0, r = n;
if (tree.FieldType == ClassDescriptor.FieldType.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 BtreeResult.Underflow:
db.pool.unfix(pg);
pg = null;
pg = db.putPage(pageId);
return handlePageUnderflow(db, pg, r, tree.FieldType, rem, height);
case BtreeResult.Done:
return BtreeResult.Done;
case BtreeResult.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.FieldType == ClassDescriptor.FieldType.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 BtreeResult.Underflow:
db.pool.unfix(pg);
pg = null;
pg = db.putPage(pageId);
return handlePageUnderflow(db, pg, r, tree.FieldType, rem, height);
case BtreeResult.Done:
return BtreeResult.Done;
case BtreeResult.Overflow:
//.........这里部分代码省略.........
示例2: insert
internal static BtreeResult insert(StorageImpl db, int pageId, Btree tree, BtreeKey ins, int height, bool unique, bool overwrite)
{
Page pg = db.getPage(pageId);
BtreeResult result;
int l = 0, n = getnItems(pg), r = n;
int ahead = unique ? 1 : 0;
try
{
if (tree.FieldType == ClassDescriptor.FieldType.tpString)
{
while (l < r)
{
int i = (l + r) >> 1;
if (compareStr(ins.key, pg, i) >= ahead)
{
l = i + 1;
}
else
{
r = i;
}
}
Debug.Assert(l == r);
if (--height != 0)
{
result = insert(db, getKeyStrOid(pg, r), tree, ins, height, unique, overwrite);
Debug.Assert(result != BtreeResult.NotFound);
if (result != BtreeResult.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);
setKeyStrOid(pg, r, ins.oid);
return BtreeResult.Overwrite;
}
else if (unique)
{
return BtreeResult.Duplicate;
}
}
db.pool.unfix(pg);
pg = null;
pg = db.putPage(pageId);
return insertStrKey(db, pg, r, ins, height);
}
else if (tree.FieldType == ClassDescriptor.FieldType.tpArrayOfByte)
{
while (l < r)
{
int i = (l + r) >> 1;
if (tree.compareByteArrays(ins.key, pg, i) >= ahead)
{
l = i + 1;
}
else
{
r = i;
}
}
Debug.Assert(l == r);
if (--height != 0)
{
result = insert(db, getKeyStrOid(pg, r), tree, ins, height, unique, overwrite);
Debug.Assert(result != BtreeResult.NotFound);
if (result != BtreeResult.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);
setKeyStrOid(pg, r, ins.oid);
return BtreeResult.Overwrite;
}
else if (unique)
{
return BtreeResult.Duplicate;
}
}
db.pool.unfix(pg);
pg = null;
pg = db.putPage(pageId);
return insertByteArrayKey(db, pg, r, ins, height);
}
else
{
while (l < r)
{
//.........这里部分代码省略.........
示例3: 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 = getnItems(pg), r = n;
int oid;
height -= 1;
try
{
if (tree.FieldType == ClassDescriptor.FieldType.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;
}
}
Debug.Assert(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.FieldType == ClassDescriptor.FieldType.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;
}
}
Debug.Assert(r == l);
}
//.........这里部分代码省略.........