use Thrift;
use Thrift::Socket;
use Thrift::FramedTransport;
use Thrift::BinaryProtocol;
use lib <LOCATION OF GENERATED PERL CODE>;
use ThriftHive;
# init variables ($host, $port, $query)
#
my $socket = Thrift::Socket->new($host, $port);
my $transport = Thrift::BufferedTransport->new($socket);
my $protocol = Thrift::BinaryProtocol->new($transport);
my $client = ThriftHiveClient->new($protocol);
eval {$transport->open()}; #do something with Exceptions
eval {$client->execute($query)};
for (my $i = 0; $i < $count; $i++)
{
my $row;
eval {$row = $client->fetchOne()};
#use $row
}
$transport->close();
I have not tested the code, but looks correct as acceptable solution.
Update: take a look also on the official documentation (Apache Thrift Perl Tutorial) which contains a Client and Server example script.
Hope this helps.
Seeking for Perl wisdom...on the process of learning...not there...yet!
|