Return-Path: Delivered-To: apmail-hbase-user-archive@www.apache.org Received: (qmail 34130 invoked from network); 30 May 2010 21:50:07 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 May 2010 21:50:07 -0000 Received: (qmail 55114 invoked by uid 500); 30 May 2010 21:50:06 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 55084 invoked by uid 500); 30 May 2010 21:50:06 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 55076 invoked by uid 99); 30 May 2010 21:50:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 May 2010 21:50:06 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of iranitov@gmail.com designates 209.85.212.169 as permitted sender) Received: from [209.85.212.169] (HELO mail-px0-f169.google.com) (209.85.212.169) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 May 2010 21:49:59 +0000 Received: by pxi12 with SMTP id 12so1443126pxi.14 for ; Sun, 30 May 2010 14:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=lrFkqcXA41S/Etcvi4IFmUzFYRjhx+/FW7nxT/6AaU4=; b=QO828tTnltEClaejLmvtKp6uDZPKnVHWtf+oYOTkMklt2Uc3D3oKOtiX4dMcz7Xwnb We0vL8+aurMPCpBfawVzubAu51jEO62tHD7XJnjrrjZ86sizHoSfCMhaXxLoTiUAtx/N vutLAMpM5dFXFyIRcf6TNq8IXd2K+EHI3CTxY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=WC3PjKwB4Uj41eaq6VvhOMQg7pOB2OzpYLwJc+pwwj4XS6LV3QD02Mzv/WM4wPuhIG lNdgjJnFp2rwzYSy4kw0/k+ZLa4Y466YWk1npxYKX2MW+TyuL6abEA5Ubqse9agXLxh+ 7y3Xkp9OjGkpBvGk1oWRCSmZtakzhYwQvd1Wk= Received: by 10.115.134.40 with SMTP id l40mr2768434wan.163.1275256178657; Sun, 30 May 2010 14:49:38 -0700 (PDT) Received: from [192.168.1.101] (c-98-234-86-167.hsd1.ca.comcast.net [98.234.86.167]) by mx.google.com with ESMTPS id c1sm43314496wam.7.2010.05.30.14.49.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 30 May 2010 14:49:37 -0700 (PDT) Message-ID: <4C02DD69.5010903@gmail.com> Date: Sun, 30 May 2010 14:49:29 -0700 From: Igor Ranitovic User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: user@hbase.apache.org Subject: Re: how to get the row before this one? References: <3EF5E168-09A0-4FC9-ADBC-FC98D8172104@zerofootprint.net> In-Reply-To: <3EF5E168-09A0-4FC9-ADBC-FC98D8172104@zerofootprint.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 >