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 <[email protected]> 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
> <[email protected]> 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

Reply via email to