internal static int Compare(bytearr left, bytearr right)
		{
			int lL = left.val.Length;
			int rL = right.val.Length;
			if (lL < rL)
				return -1;
			if (lL > rL)
				return 1;
			// key len equal
			int len = lL;

			for (int i = 0; i < len; i++)
			{
				int l = left.val[i];
				int r = right.val[i];
				int k = l - r;
				if (k == 0)
					continue;
				if (k < 0)
					return -1;
				else
					return 1;
			}
			return 0;
		}
        private int FindPointerOrLower(Bucket b, bytearr key, out bool found)
        {
            found = false;
            if (b.Pointers.Count == 0)
            {
                return(0);
            }
            // binary search
            int lastlower = -1;
            int first     = 0;
            int last      = b.Pointers.Count - 1;
            int mid       = 0;

            while (first <= last)
            {
                mid = (first + last) >> 1;
                KeyPointer k       = b.Pointers[mid];
                int        compare = Helper.Compare(k.Key, key);
                if (compare < 0)
                {
                    lastlower = mid;
                    first     = mid + 1;
                }
                if (compare == 0)
                {
                    found = true;
                    return(mid);
                }
                if (compare > 0)
                {
                    last = mid - 1;
                }
            }

            return(lastlower);
        }
Esempio n. 3
0
        internal static int Compare(bytearr left, bytearr right)
        {
            int lL = left.val.Length;
            int rL = right.val.Length;

            if (lL < rL)
            {
                return(-1);
            }
            if (lL > rL)
            {
                return(1);
            }
            // key len equal
            int len = lL;

            for (int i = 0; i < len; i++)
            {
                int l = left.val[i];
                int r = right.val[i];
                int k = l - r;
                if (k == 0)
                {
                    continue;
                }
                if (k < 0)
                {
                    return(-1);
                }
                else
                {
                    return(1);
                }
            }
            return(0);
        }
		public KeyPointer(bytearr key, int recno)
		{
			RecordNum = recno;
			Key = key;
			DuplicatesPage = -1;
		}
		public KeyPointer(bytearr key, int recno, int duppage)
		{
			RecordNum = recno;
			Key = key;
			DuplicatesPage = duppage;
		}
Esempio n. 6
0
 public KeyPointer(bytearr key, int recno)
 {
     RecordNum      = recno;
     Key            = key;
     DuplicatesPage = -1;
 }
Esempio n. 7
0
 public KeyPointer(bytearr key, int recno, int duppage)
 {
     RecordNum      = recno;
     Key            = key;
     DuplicatesPage = duppage;
 }
		private int FindPointerOrLower(Bucket b, bytearr key, out bool found)
		{
			found = false;
			if (b.Pointers.Count == 0)
				return 0;
			// binary search
			int lastlower = -1;
			int first = 0;
			int last = b.Pointers.Count - 1;
			int mid = 0;
			while (first <= last)
			{
				mid = (first + last) >> 1;
				KeyPointer k = b.Pointers[mid];
				int compare = Helper.Compare(k.Key, key);
				if (compare < 0)
				{
					lastlower = mid;
					first = mid + 1;
				}
				if (compare == 0)
				{
					found = true;
					return mid;
				}
				if (compare > 0)
				{
					last = mid - 1;
				}
			}

			return lastlower;
		}