Return-Path: Delivered-To: apmail-hadoop-hbase-user-archive@locus.apache.org Received: (qmail 28963 invoked from network); 29 Nov 2008 05:13:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Nov 2008 05:13:22 -0000 Received: (qmail 58598 invoked by uid 500); 29 Nov 2008 05:13:32 -0000 Delivered-To: apmail-hadoop-hbase-user-archive@hadoop.apache.org Received: (qmail 58581 invoked by uid 500); 29 Nov 2008 05:13:32 -0000 Mailing-List: contact hbase-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-user@hadoop.apache.org Delivered-To: mailing list hbase-user@hadoop.apache.org Received: (qmail 58570 invoked by uid 99); 29 Nov 2008 05:13:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Nov 2008 21:13:32 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of saint.ack@gmail.com designates 209.85.132.246 as permitted sender) Received: from [209.85.132.246] (HELO an-out-0708.google.com) (209.85.132.246) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Nov 2008 05:12:05 +0000 Received: by an-out-0708.google.com with SMTP id d40so606980and.29 for ; Fri, 28 Nov 2008 21:12:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type:references :x-google-sender-auth; bh=QZ77rtuckgYgTQNk2AvtqqC5ngv2VpJZJuSYNFa9Pps=; b=ZYOzYjV6cgJWb5OlSTIBONLFX22XIIV/iwl1dQlsPn2ao3JFdFPip2Nh60mkkALmVY TjXiM7WYEO7ACc17E5dEnXF8UJlXMLKFp+FOXZ8OGkGloy3yr+nZxhnWvOREIUpFPIb8 4Jl8dQHvaAzj5DXvrF9kumyvhWBbkbZcmOLx0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:references:x-google-sender-auth; b=Ywfreo49ZE3Icu7X08CXWd1bcRCe+KTPOaC/K3ymXQGFK957kUu5AD2vq0wJnGL0NM 6sTvlrrfY+cQg/f8wmE+OYju6R6jtOsc7VBnfXksTeZjAKDn3TNRN4AfPz7bN2bSTakF wJKv2jRQ6kVo4wawzWJuJ7cfGxASA9af9D1Xc= Received: by 10.100.13.2 with SMTP id 2mr4557088anm.74.1227935561638; Fri, 28 Nov 2008 21:12:41 -0800 (PST) Received: by 10.100.106.20 with HTTP; Fri, 28 Nov 2008 21:12:41 -0800 (PST) Message-ID: <7c962aed0811282112x39223e58u8f8fa40c3a5112dd@mail.gmail.com> Date: Fri, 28 Nov 2008 21:12:41 -0800 From: stack Sender: saint.ack@gmail.com To: hbase-user@hadoop.apache.org Subject: Re: HBase DSL for Groovy In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_27108_5706326.1227935561621" References: X-Google-Sender-Auth: 64bfb0e632fcdb26 X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_27108_5706326.1227935561621 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline It looks great Tom (and thanks for adding to main wiki page). St.Ack On Fri, Nov 28, 2008 at 12:22 PM, Tom Nichols wrote: > I added the code and some documentation to a wiki page here: > http://wiki.apache.org/hadoop/Hbase/Groovy . > > The code itself is pretty well documented so it should be fairly easy > for anyone to pick up and use. I'll keep the page updated as I come > up with enhancements. > > On Tue, Nov 25, 2008 at 1:22 PM, stack wrote: > > This looks great Tom (Code as well as the DSL). I'm not a groovy-head > but > > it looks like builder pattern to me and the example parsing and uploading > an > > URL fetch is nicely succinct. > > > > How do you want to proceed? You think it worth sticking it up in google > > code project somewhere? Do you think it will evolve at all? Or, if you > > want, add the class to an issue -- perhaps call it somethinge else -- and > > then make a wiki page linking to the issue with the below explication and > > examples in it (See main hbase page -- pattern seems to be a link off > here > > to a page per language; e.g. jython, jruby, etc.). > > > > Good stuff, > > St.Ack > > > > > > Tom Nichols wrote: > >> > >> Hi -- > >> > >> I've created a builder-style HBase client DSL for Groovy -- currently > >> it just wraps the client API to make inserts and row scans a little > >> easier. There probably plenty of room for improvement so I wanted to > >> submit it to the community. Any feedback or suggestions are welcome. > >> > >> Here's an example: > >> > >> def hbase = HBase.connect() // may optionally pass host name > >> /* Create: this will create a table if it does not exist, or disable > >> & update column families > >> if the table already does exist. The table will be enabled when > >> the create statement returns */ > >> hbase.create( 'myTable' ) { > >> family( 'familyOne' ) { > >> inMemory = true > >> bloomFilter = false > >> } > >> } > >> > >> /* Insert/ update rows: > >> hbase.update( 'myTable' ) { > >> row( 'rowOne' ) { > >> family( 'familyOne' ) { > >> col 'one', 'someValue' > >> col 'two', 'anotherValue' > >> col 'three', 1234 > >> } > >> // alternate form that doesn't use nested family name: > >> col 'familyOne:four', 12345 > >> } > >> row( 'rowTwo' ) { /* more column values */ } > >> // etc > >> } > >> > >> So a more realistic example -- if you were iterating through some data > >> and inserting it would look like this: > >> > >> hbase.update( 'myTable' ) { > >> new URL( someCSV ).eachLine { line -> > >> def values = line.split(',') > >> row( values[0] ) { > >> col 'fam1:val1', values[1] > >> // etc... > >> } > >> } > >> } > >> > >> There is also wrapper for the scanner API as well: > >> > >> hbase.scan( cols : ['fam:col1', 'fam:col2'], > >> start : '001', end : '200', > >> // any timestamp args may be long, Date or Calendar > >> timestamp : Date.parse( 'yy/mm/dd HH:MM:ss', '08/11/25 > >> 05:00:00' ) > >> ) { row -> > >> > >> // each row is a RowResult instance -- which is a Map! So all > map > >> operations are valid here: > >> row.each { println '${it.key} : ${it.value}' } > >> } > >> > > > > > ------=_Part_27108_5706326.1227935561621--