(thanks igor)

On Sun, May 30, 2010 at 2:49 PM, Igor Ranitovic <[email protected]> wrote:
> One thing that I can think of is to sort measurements from the newest to
> oldest:
>
> DevA,12pm,150W
> DevA,9am,100W
>
> Now instead of scanning from-to date, start with the to date and keep
> scanning until you find a row with a date that is older than the from date.
> To use your example, start the scan from 1pm and stop when you hit 9am.
>
> To sort row from newest to oldest use MAXINT - timestamp, where timestamp is
> seconds since epoch.
>
> Hope this helps.
> i.
>
> Oliver Meyn 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
>>
>
>

Reply via email to