Uploaded image for project: 'Accumulo'
  1. Accumulo
  2. ACCUMULO-403

Create general row selection iterator

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.4.0
    • client, tserver
    • None

    Description

      The WholeRowIterator support filtering rows that meet a certain criteria. However it reads the entire row into memory. It is possible to efficiently select rows w/o reading them into memory by using two iterators. One iterator for selection, one for reading. When its determined that a row is not needed using the selection iterator, then seek the read iterator over the row.

      This pattern could be made into an easy to use iterator that users extend. The iterator could have an abstract method that user implement to decide if they want to select or filter a row. Could look something like the following.

      class RowSelectionIterator extends WrappingIterator {
      
         public abstract boolean selectRow(SortedKeyValueIterator row);
      
      }
      
      

      Below is a simple example of a row selection iterator that returns rows that have the columns foo and bar.

      class FooBarRowSelector extends  RowSelectionIterator {
         public boolean selectRow(SortedKeyValueIterator row){
            
            Text row = row.getTopKey().getRow();
            //seek instead of scanning, this more efficient for large rows w/ lots of columns... 
            //if the row only has a few columns scanning is probably faster... also seeking the 
            //columns in sorted order is more efficient.
            row.seek(Range.exact(row, 'bar');
            boolean sawBar = row.hasTop();
      
            if(!sawBar)
              return false;
      
            row.seek(Range.exact(row, 'foo'));
            boolean sawFoo = row.hasTop();
      
            return sawFoo;
         }
      }
      
      

      Attachments

        Activity

          People

            kturner Keith Turner
            kturner Keith Turner
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: