当前位置: 首页>>代码示例>>C#>>正文


C# Btree.compareByteArrays方法代码示例

本文整理汇总了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: 
//.........这里部分代码省略.........
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:101,代码来源:BtreePage.cs

示例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)
             {
//.........这里部分代码省略.........
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:101,代码来源:BtreePage.cs

示例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);
             }
//.........这里部分代码省略.........
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:101,代码来源:BtreePage.cs


注:本文中的Btree.compareByteArrays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。