NAME
HBase::JSONRest - Simple REST client for HBase
SYNOPSIS
A simple get request:
my $hbase = HBase::JSONRest->new(host => $hostname);
my $records = $hbase->get(
table => 'table_name',
where => {
key_begins_with => "key_prefix"
},
);
A simple put request:
# array of hashes, where each hash is one row
my $rows = [
...
{
row_key => "$row_key",
# cells: array of hashes where eash hash is one cell
row_cells => [
{ column => "$family_name:$colum_name", value => "$value" },
],
},
...
];
my $res = $hbase->put(
table => $table_name,
changes => $rows
);
DESCRIPTION
A simple rest client for HBase.
METHODS
get
Scans a table by key prefix or exact key match depending on options passed:
# scan by key prefix:
my $records = $hbase->get(
table => $table_name,
where => {
key_begins_with => "$key_prefix"
},
);
# exact match:
my $record = $hbase->get(
table => $table_name,
where => {
key_equals => "$key"
},
);
put
Inserts one or multiple rows. If a key allready exists then depending on if HBase versioning is on, the record will be updated (versioning is off) or new version will be inserted (versioning is on)
# multiple rows
my $rows = [
...
{
row_key => "$row_key",
# cells: array of hashes where eash hash is one cell
row_cells => [
{ column => "$family_name:$colum_name", value => "$value" },
],
},
...
];
my $res = $hbase->put(
table => $table_name,
changes => $rows
);
# single row - basically the same as multiple rows, but
# the rows array has just one elements
my $rows = [
{
row_key => "$row_key",
# cells: array of hashes where eash hash is one cell
row_cells => [
{ column => "$family_name:$colum_name", value => "$value" },
],
},
];
my $res = $hbase->put(
table => $table_name,
changes => $rows
);
version
Returns a hashref with server version info
my $version_info = $hbase->version;
print Dumper($version_info);
output example:
---------------
version => $VAR1 = {
'Server' => 'jetty/6.1.26.cloudera.2',
'Jersey' => '1.8',
'REST' => '0.0.2',
'OS' => 'Linux 2.6.32-358.23.2.el6.x86_64 amd64',
'JVM' => 'Oracle Corporation 1.7.0_51-24.51-b03'
};
list
Returns a list of tables available in HBase
print "tables => " . Dumper($hbase->list);
tables => $VAR1 = [
{
'name' => 'very_big_table'
},
...,
{
'name' => 'super_big_table'
}
];
ERROR HANDLING
Information on error is stored in hbase object under key last error:
my $records = $hbase->get(
table => $table_name,
where => {
key_begins_with => "$key_prefix"
},
);
if ($hbase->{last_error}) {
# handle error
}
else {
# process records
}
VERSION
Current version: 0.001
AUTHOR
bdevetak - Bosko Devetak (cpan:BDEVETAK) <bosko.devetak@gmail.com>
CONTRIBUTORS
theMage, <cpan:NEVES>
, <mailto:themage@magick-source.net>
Sawyer X, <xsawyerx at cpan.org>
COPYRIGHT
Copyright (c) 2014 the HBase::JSONRest "AUTHOR" and "CONTRIBUTORS" as listed above.
LICENSE
This library is free software and may be distributed under the same terms as perl itself. See http://dev.perl.org/licenses/.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.