Exemplo n.º 1
0
        /// <summary>
        /// Moves to the first row (as defined by the cursor) where the index entries
        /// are &gt;= the given values.
        /// </summary>
        /// <remarks>
        /// Moves to the first row (as defined by the cursor) where the index entries
        /// are &gt;= the given values.  If a an exception is thrown, the cursor is
        /// restored to its previous state.
        /// </remarks>
        /// <param name="entryValues">the column values for the index's columns.</param>
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void FindClosestRowByEntry(params object[] entryValues)
        {
            Cursor.Position curPos  = _curPos;
            Cursor.Position prevPos = _prevPos;
            bool            found   = false;

            try
            {
                FindRowByEntryImpl(ToRowValues(entryValues), false);
                found = true;
            }
            finally
            {
                if (!found)
                {
                    try
                    {
                        RestorePosition(curPos, prevPos);
                    }
                    catch (IOException e)
                    {
                        System.Console.Error.WriteLine("Failed restoring position");
                        Sharpen.Runtime.PrintStackTrace(e, System.Console.Error);
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <exception cref="System.IO.IOException"></exception>
 protected internal override Cursor.Position FindAnotherPosition(Table.RowState rowState
                                                                 , Cursor.Position curPos, bool moveForward)
 {
     IndexCursor.IndexDirHandler handler = ((IndexCursor.IndexDirHandler)GetDirHandler
                                                (moveForward));
     IndexCursor.IndexPosition endPos = (IndexCursor.IndexPosition)handler.GetEndPosition
                                            ();
     IndexData.Entry entry = handler.GetAnotherEntry();
     return((!entry.Equals(endPos.GetEntry())) ? new IndexCursor.IndexPosition(entry)
          : endPos);
 }
Exemplo n.º 3
0
 /// <exception cref="System.IO.IOException"></exception>
 protected internal override void RestorePositionImpl(Cursor.Position curPos, Cursor.Position
                                                      prevPos)
 {
     if (!(curPos is IndexCursor.IndexPosition) || !(prevPos is IndexCursor.IndexPosition
                                                     ))
     {
         throw new ArgumentException("Restored positions must be index positions");
     }
     _entryCursor.RestorePosition(((IndexCursor.IndexPosition)curPos).GetEntry(), ((IndexCursor.IndexPosition
                                                                                    )prevPos).GetEntry());
     base.RestorePositionImpl(curPos, prevPos);
 }