In the API there is getRowOrBefore but it doesn't seem to work going against tables other than catalog tables (HBase-2628). (I'm not sure we want getRowOrBefore freely available for use in user tables anyways since it is an expensive, perverse access). Absent this, I have no recommendation other than to start your scan earlier than you need to and if no devA in the preamble, back up further still, etc.
St.Ack P.S. You look like you are working on good stuff. On Fri, May 28, 2010 at 9:01 AM, Oliver Meyn <[email protected]> wrote: > Hi all, > > I have a table "device_power" which has as its row key > "device_id.timestamp", and a single column, "power". A new row is written > whenever the power consumption of a device changes, which could be every > second, or could be as much as days. > > When I do a query like "what was the average power of device X between Date > 1 and Date 2" I can get all keys where device_id matches X (using > PrefixFilter) and timestamp > Date1 and < Date2 (using either RowFilter or > setTimeRange). But I also need the last row before my time range to know > what state the device was in at the start of my query period. Maybe an > example will help make it more obvious (my timestamps are long integers, but > this is easier to read): > > DevA.9am, 100W > DevB.10am, 200W > DevB.11am, 150W > DevA.12pm, 150W > > And now the query "What was the average power of DevA btw 10am and 1pm". Is > there a clever way to "get the first row before 10am that matches > PrefixFilter("DevA") ? > > Thanks, > Oliver >
