Exemple #1
0
        public static int Compare(Table A, Table B)
        {
            if (A.Columns.Count != B.Columns.Count)
            {
                return(A.Columns.Count - B.Columns.Count);
            }
            else if (A.RecordCount != B.RecordCount)
            {
                return((int)((A.RecordCount - B.RecordCount) & (long)int.MaxValue));
            }

            RecordReader rr_a = A.OpenReader();
            RecordReader rr_b = B.OpenReader();

            int c = 0;

            while (rr_a.CanAdvance && rr_b.CanAdvance)
            {
                c = Record.Compare(rr_a.ReadNext(), rr_b.ReadNext());
                if (c != 0)
                {
                    break;
                }
            }

            return(c);
        }
Exemple #2
0
 /// <summary>
 /// Finds the location of a given record on the page
 /// </summary>
 /// <param name="Key"></param>
 /// <returns></returns>
 public virtual int Search(Record Element)
 {
     for (int i = 0; i < this._Elements.Count; i++)
     {
         if (Record.Compare(Element, this._Elements[i]) == 0)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemple #3
0
        public static RecordKey CheckSort(Table Element, Key Columns)
        {
            Record Last    = null;
            Record Current = null;

            RecordReader rr = Element.OpenReader();

            Current = rr.ReadNext();

            while (rr.CanAdvance)
            {
                if (Last != null && Record.Compare(Last, Current, Columns) > 0)
                {
                    return(rr.PositionKey);
                }
                Last    = Current;
                Current = rr.ReadNext();
            }

            return(RecordKey.RecordNotFound);
        }
Exemple #4
0
        /// <summary>
        /// Gets a record, invluding the key and value
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        public Record GetKeyValue2(Record Composite)
        {
            // Check the last key first //
            if (this._LastKey != null)
            {
                if (Record.Compare(Record.Split(Composite, this._KeyFields), this._LastKey) == 0)
                {
                    return(this._Cluster.Storage.GetPage(this._LastRef.PAGE_ID).Select(this._LastRef.ROW_ID));
                }
            }

            // Get the record key //
            RecordKey x = this._Cluster.FindFirst(Composite, true);

            // This should really only trigger if the table is empty; actually, this should never trigger //
            if (x.IsNotFound)
            {
                return(null);
            }

            // Select the record, and if it's null, return //
            Record y = this._Cluster.Storage.TrySelect(x);

            if (y == null)
            {
                return(null);
            }

            // Need to check if we didn't find the actual record //
            if (Record.Compare(y, Composite, this._KeyFields) == 0)
            {
                this._LastRef = x;
                this._LastKey = Record.Split(Composite, this._KeyFields);
                return(y);
            }

            // Not found //
            return(null);
        }
Exemple #5
0
 public int CompareTo(Record Value)
 {
     this._cTicks++;
     return(Record.Compare(this._Value, Value));
 }
Exemple #6
0
 public int Compare(Record A, Record B)
 {
     this._cTicks++;
     return(Record.Compare(A, this._LeftKey, B, this._RightKey));
 }