Skip to content

Instantly share code, notes, and snippets.

@cchandler
Created October 23, 2009 03:39
Show Gist options
  • Save cchandler/216619 to your computer and use it in GitHub Desktop.
Save cchandler/216619 to your computer and use it in GitHub Desktop.
require './hbase'
require './hbase_constants'
require './hbase_types'
transport = Thrift::BufferedTransport.new(Thrift::Socket.new("hbase_server", "9090"))
transport.open
client = Apache::Hadoop::Hbase::Thrift::Hbase::Client.new(Thrift::BinaryProtocol.new(transport))
## Get Table meta data
client.getTableNames
client.getColumnDescriptors("t1")
client.getTableRegions("t1")
## Insert data
mutation = Apache::Hadoop::Hbase::Thrift::Mutation.new(:column => "f1", :value => "Some value")
# client.mutateRow("t1","generic_key", [mutation])
## Delete data (Currently is triggering a null pointer exception...)
deletion = Apache::Hadoop::Hbase::Thrift::Mutation.new(:column => "f1", :isDelete => true)
client.mutateRow("t1", "generic_key", [deletion])
## Read all columns for a key
client.getRow("t1","generic_key")
## Read specific columns for a key
client.getRowWithColumns("t1", "generic_key", ["f1"])
## Read a specific timestamped row
client.getRowTs("t1", "generic_key", 1256268530758)
## Read a specific set of columns for a timestamp
client.getRowWithColumnsTs("t1","generic_key", ["f1"], 1256268530758)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment