You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Dave Brosius <db...@apache.org> on 2011/06/19 09:57:53 UTC

Is this ok?

Perhaps this ok, but seems odd to me, just double checking...

ScrollInsensitiveResultSet around line 321

If the row hasn't been seen yet, if scans rows till it finds the row 
which is fine,
then once found, if the result is *found*, it looks it up again in the 
hashtable which seems odd


         if (row > 0)
         {
             // position is from the start of the result set
             if (row <= positionInSource)
             {
                 // We've already seen the row before
                 return getRowFromHashTable(row);
             }

             /* We haven't seen the row yet, scan until we find
              * it or we get to the end.
              */
             int diff = row - positionInSource;
             ExecRow result = null;
             while (diff > 0)
             {
                 if ((result = getNextRowFromSource()) != null)
                 {
                     diff--;
                 }
                 else
                 {
                     break;
                 }
             }
*if (result != null) {
                 result = getRowFromHashTable(row);
             }*
             currentRow = result;
             return result;
         }

Re: Is this ok?

Posted by Knut Anders Hatlen <kn...@oracle.com>.
Dave Brosius <db...@apache.org> writes:

> Perhaps this ok, but seems odd to me, just double checking...
>
> ScrollInsensitiveResultSet around line 321
>
> If the row hasn't been seen yet, if scans rows till it finds the row
> which is fine,
> then once found, if the result is found, it looks it up again in the
> hashtable which seems odd

It looks like getRowFromHashTable() doesn't just fetch the row from the
hashtable. It also has some side-effects (setting various fields in the
result set) that getNextRowFromSource() doesn't have. So I guess the
method is called primarily for the side-effects and not for retrieving
the row in this case. But it does look a little puzzling without a
comment.

-- 
Knut Anders

Re: Is this ok?

Posted by Lily Wei <li...@gmail.com>.
Hi Dave:
     It seems odd to me too. Do you have any case to show the cursor did not find the desire row and some other row instead?


Thanks, 
Lily

On Jun 19, 2011, at 12:57 AM, Dave Brosius <db...@apache.org> wrote:

> Perhaps this ok, but seems odd to me, just double checking...
> 
> ScrollInsensitiveResultSet around line 321
> 
> If the row hasn't been seen yet, if scans rows till it finds the row which is fine,
> then once found, if the result is found, it looks it up again in the hashtable which seems odd
> 
> 
>         if (row > 0)
>         {
>             // position is from the start of the result set
>             if (row <= positionInSource)
>             {
>                 // We've already seen the row before
>                 return getRowFromHashTable(row);
>             }
>             
>             /* We haven't seen the row yet, scan until we find
>              * it or we get to the end.
>              */
>             int diff = row - positionInSource;
>             ExecRow result = null;
>             while (diff > 0)
>             {
>                 if ((result = getNextRowFromSource()) != null)
>                 {
>                     diff--;
>                 }
>                 else
>                 {
>                     break;
>                 }
>             }
>             if (result != null) {
>                 result = getRowFromHashTable(row);
>             }
>             currentRow = result;
>             return result;
>         }