Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Accumulo >> mail # user >> Can Sort Order Be Reversed?

Copy link to this message
Re: Can Sort Order Be Reversed?
Nope, we currently only support one sort order. The closest you can come is
by using an encoding the flips the sort order. In this case, you would take
every byte and subtract it from 255 to get your new row, so:

void convert(byte[] row)
  for(int i = 0; i < row.length; i++)
    row[i] = (byte)(255 - row[i]);

void foo()
  byte[] row = "abcd".getBytes();
  // convert to backwards sort
  Mutation m = new Mutation(row);
  BatchWriter bw = ...

  Scanner s = ...
  for(Entry<Key,Value> e:s)
    byte [] row = e.getKey().getRow();
    // convert back
    System.out.println(new String(row));

On Thu, May 31, 2012 at 10:25 AM, David Medinets

> I don't know why it has taken me so long to ask this basic question.
> Rows are stored in Accumulo in sorted order - high to low. Is there a
> configuration option to flip the sort? My specific use case has dates
> as the record key and I want to see the oldest records first.