Created
October 23, 2009 03:39
-
-
Save cchandler/216619 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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