Skip to content

Instantly share code, notes, and snippets.

@simonholgate
Created June 21, 2012 13:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonholgate/2965839 to your computer and use it in GitHub Desktop.
Save simonholgate/2965839 to your computer and use it in GitHub Desktop.
Cascalog test with HBase
(ns test.hbase
(:require (cascalog [workflow :as w]
[ops :as c]
[vars :as v]))
(:import (org.apache.hadoop.hbase.util Bytes)
(com.twitter.maple.hbase HBaseTap HBaseScheme)
(cascading.hbase ByteHolder)))
(use '[cascalog api playground])
(bootstrap-emacs)
(defn hbase-tap [table-name key-field column-family & value-fields]
(let [scheme (HBaseScheme. (w/fields key-field) column-family (w/fields value-fi\
elds))]
(HBaseTap. table-name scheme)))
(defn as-string [^ByteHolder bytes]
(.toString bytes))
(let [age-table (hbase-tap "age-table" "?person" "cf" "?age")]
(?<- (stdout) [?p ?a] (age-table ?p ?age) (as-string ?age :> ?a)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment