1
2
|
hive --service hiveserver
/usr/lib/hbase/bin/hbase-daemon.sh start thrift
|
Download HBase and Thrift php client package and write your own client:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
//thrift php
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__).'/thrift/src';
require_once( $GLOBALS['THRIFT_ROOT'].'/Thrift.php' );
require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php' );
require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php' );
require_once( $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php' );
//hbase thrift
require_once dirname(__FILE__).'/thrift/Hbase.php';
//hive thrift
require_once dirname(__FILE__).'/thrift/ThriftHive.php';
/*
HBase php thrift client
*/
//open connection
$socket = new TSocket( 'localhost', 9090 );
$transport = new TBufferedTransport( $socket );
$protocol = new TBinaryProtocol( $transport );
$client = new HbaseClient( $protocol );
$transport->open();
//show all tables
$tables = $client->getTableNames();
foreach ( $tables as $name ) {
echo( " found: {$name}\n" );
}
//Create a table
try {
$columns = array(new ColumnDescriptor( array(
'name' =>; 'colFamily:',
'maxVersions' => 10) ));
$client->createTable("tableName", $columns );
} catch ( AlreadyExists $ae ) {
echo( "WARN: {$ae->;message}\n" );
}
//insert data to table
$mutations = array(
new Mutation( array(
'column' => 'colFamily:Col',
'value' => 'value123'
) ),
);
$client->mutateRow( "tableName", "ID_1237846634624", $mutations );
//get table data
$row = $client->getRow("tableName", "ID_1237846634624");
/*
Hive php thrift client
*/
//open connection
$transport = new TSocket("localhost", 10000);
$protocol = new TBinaryProtocol($transport);
$client = new ThriftHiveClient($protocol);
$transport->open();
//show tables
$client->execute('SHOW TABLES');
$tables = $client->fetchAll();
foreach ($tables as $name){
echo( " found: {$name}\n" );
}
//Create Hive table with Hbase table mapping
$mapping = 'CREATE EXTERNAL TABLE tableName(Col String, Col1 String)
STORED BY \'org.apache.hadoop.hive.hbase.HBaseStorageHandler\'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = "colFamily:Col, colFamily:Col")
TBLPROPERTIES("hbase.table.name" = "tableName")';
$client->execute($mapping);
//Query table
$client->execute('SELECT * FROM tableName Limit 10');
var_dump($client->fetchAll());
|
http://mmalithh.blogspot.in/2012/08/apache-thrift-quick-start.html
ReplyDeletehttp://blog.alireza-noori.com/programming/source-code-for-thrift-tutorial/
ReplyDeletehttp://blog.newitfarmer.com/software-develop/open-source/869/install-thrift-on-linux
ReplyDeleteDebian or Ubuntu setup
ReplyDeleteThe following command install all the required tools and libraries to build and install the Apache Thrift compiler on a Debian/Ubuntu Linux based system.
sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
Then install the Java JDK of your choice. Type javac to see a list of available packages, pick the one you prefer and apt-get install it.
Debian Lenny Users need some packages from backports
sudo apt-get -t lenny-backports install automake libboost-test-dev
Optional packages
Some other packages depend on what languages you want Thrift to support.
Ruby
ruby-full ruby-dev librspec-ruby rake rubygems libdaemons-ruby libgemplugin-ruby mongrel
Python
python-dev python-twisted
Perl
libbit-vector-perl
Php, install
php5-dev php5-cli
C_glib
libglib2.0-dev
Erlang
erlang-base erlang-eunit erlang-dev
Csharp
mono-gmcs libmono-dev libmono-system-web2.0-cil
Haskell
ghc6 cabal-install libghc6-binary-dev libghc6-network-dev libghc6-http-dev
Thrift Compiler for Windows
mingw32 mingw32-binutils mingw32-runtime
http://wiki.apache.org/hadoop/Hbase/ThriftApi
ReplyDeletehttp://hbase.apache.org/book/thrift.htm
ReplyDelete