|
|
-
Can Sort Order Be Reversed?
David Medinets 2012-05-31, 14:24
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.
-
Re: Can Sort Order Be Reversed?
William Slacum 2012-05-31, 14:33
As of now, nope!
On Thu, May 31, 2012 at 7:24 AM, David Medinets <[EMAIL PROTECTED]> 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.
-
Re: Can Sort Order Be Reversed?
Adam Fuchs 2012-05-31, 14:40
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 <[EMAIL PROTECTED]>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. >
-
Re: Can Sort Order Be Reversed?
Jim Klucar 2012-05-31, 14:41
If its an int or long you can subtract it from the maximum int/long before you write the row id.
if it is a YYYYMMDD string, subtract each character from 9 before writing the rowid.
Sent from my iPhone
On May 31, 2012, at 10:34 AM, William Slacum <[EMAIL PROTECTED]> wrote:
> As of now, nope! > > On Thu, May 31, 2012 at 7:24 AM, David Medinets > <[EMAIL PROTECTED]> 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.
-
Re: Can Sort Order Be Reversed?
Juan Moreno 2012-05-31, 14:52
While we are on the subject, is there a way to scan rows sorted by timestamp, or a particular column?
--------------------------------- *Juan* Moreno On May 31, 2012 10:41 AM, "Jim Klucar" <[EMAIL PROTECTED]> wrote:
> If its an int or long you can subtract it from the maximum int/long > before you write the row id. > > if it is a YYYYMMDD string, subtract each character from 9 before > writing the rowid. > > Sent from my iPhone > > On May 31, 2012, at 10:34 AM, William Slacum <[EMAIL PROTECTED]> wrote: > > > As of now, nope! > > > > On Thu, May 31, 2012 at 7:24 AM, David Medinets > > <[EMAIL PROTECTED]> 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. >
-
Re: Can Sort Order Be Reversed?
Billie J Rinaldi 2012-05-31, 22:16
On Thursday, May 31, 2012 10:52:33 AM, "Juan Moreno" <[EMAIL PROTECTED]> wrote: > While we are on the subject, is there a way to scan rows sorted by > timestamp, or a particular column?
No. The primary sort is on the row. If you would like your data sorted by a particular feature, create a table with that feature stored in the row. (Good key design is much more complex than this, but this concept is the basic starting point.)
Billie > --------------------------------- > Juan Moreno > > On May 31, 2012 10:41 AM, "Jim Klucar" < [EMAIL PROTECTED] > wrote: > > > If its an int or long you can subtract it from the maximum int/long > before you write the row id. > > if it is a YYYYMMDD string, subtract each character from 9 before > writing the rowid. > > Sent from my iPhone > > On May 31, 2012, at 10:34 AM, William Slacum < [EMAIL PROTECTED] > > wrote: > > > As of now, nope! > > > > On Thu, May 31, 2012 at 7:24 AM, David Medinets > > < [EMAIL PROTECTED] > 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.
|
|