accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Fuchs <adam.p.fu...@ugov.gov>
Subject Re: Can Sort Order Be Reversed?
Date Thu, 31 May 2012 14:40:03 GMT
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
  convert(row);
  Mutation m = new Mutation(row);
  ...
  BatchWriter bw = ...
  bw.add(m);
  ...

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

On Thu, May 31, 2012 at 10:25 AM, David Medinets
<david.medinets@gmail.com>wrote:

> 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.
>

Mime
View raw message