hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Rawson <ryano...@gmail.com>
Subject Re: Is it safe to delete a row inside a scanner loop?
Date Thu, 25 Mar 2010 07:43:52 GMT
You'll see the rows then.  If this is a serious requirement, you might
have to set scanner caching = 1 or do something else client side in
your own app code.

-ryan

On Thu, Mar 25, 2010 at 12:40 AM, Angus He <angushe@gmail.com> wrote:
> Hi Ryan,
>
> What if the rows to be deleted have been already in the client scanner cache?
>
>
>
> On Thu, Mar 25, 2010 at 2:07 PM, Ryan Rawson <ryanobjc@gmail.com> wrote:
>> Hey,
>>
>> I'm pretty sure that Iterator.remove() will be local only and not
>> actually affect HBase.
>>
>> But yes it is safe.  If you delete a row you just scanned, since the
>> scanner will be past the row in question, thus it is safe to delete
>> it.  And even if you deleted a row you were just about to see, you'd
>> just end up skipping that row.
>>
>> -ryan
>>
>> On Wed, Mar 24, 2010 at 10:12 AM, Jeyendran Balakrishnan
>> <jbalakrishnan@docomolabs-usa.com> wrote:
>>> Hi,
>>>
>>> I am running a scanner on a HBase table.
>>> After getting each row, and using the data, I want to delete the row.
>>> Is it safe to do so from inside the scanner loop?
>>>
>>> And if so, what is the best way to delete the row?:
>>> * Using HTable.deleteAll()
>>> or
>>> * Using Iterator.remove()
>>>
>>> My use case is something like this [I am using HBase 19.3, please don't
>>> kill me :-)]:
>>>
>>> HTable table = ...;
>>> Scanner scanner = table.getScanner(...);
>>>
>>> try
>>> {
>>>        Iterable<RowResult> I = scanner.iterator();
>>>        while (I.hasNext())
>>>        {
>>>                RowResult result = I.next();
>>>
>>>                //      Do something with result:
>>>                // ....
>>>
>>>                //      Now delete the row
>>>
>>>                //      HTable approach
>>>                byte[] rowKeyBytes = result.getRow();
>>>                table.deleteAll(rowKeyBytes);
>>>
>>>                //      OR Iterator.remove() approach:
>>>                //I.remove();
>>>        }
>>> }
>>> finally
>>> {
>>>        if (scanner != null)
>>>                scanner.close();
>>> }
>>>
>>> Thanks a lot,
>>> jp
>>>
>>>
>>
>
>
>
> --
> Regards
> Angus
>

Mime
View raw message