对于每个thrift API调用(在Erlang中使用HBase Thrift),API返回一个thrift连接:
erlang示例:
% creating the initial connection
{ok, TFactory} = thrift_socket_transport:new_transport_factory( "localhost", 9090, []),
{ok, PFactory} = thrift_binary_protocol:new_protocol_factory(TFactory, []),
{ok, Protocol} = PFactory(),
{ok, ThiftConnection1} = thrift_client:new(Protocol, hbase_thrift),
%calling a row mutation
{ThriftConnection2, Result} = thrift_client:call( ThriftConnection1, mutateRow, ["MYTABLE", Row1Id, MutationList1, dict:new()]),
{ThriftConnection3, Result} = thrift_client:call( ThriftConnection2, mutateRow, ["MYTABLE", Row2Id, MutationList2, dict:new()]),
这引发了以下相关问题:
答案 0 :(得分:1)
我意识到这不是一个连接,而是一个节俭传输参考。我把它们相互比较,它们是相同的。在Erlang中,打印他们的内容(序列化)关于每个结果的事实表明他们是相同的
ThriftConnection2 :
{tclient,hbase_thrift,
{protocol,thrift_binary_protocol,
{binary_protocol,
{transport,thrift_buffered_transport,
{buffered_transport,
{transport,thrift_socket_transport,
{data,#Port<0.25469>,infinity}},
[]}},
true,true}},
0}
ThriftConnection3 :
{tclient,hbase_thrift,
{protocol,thrift_binary_protocol,
{binary_protocol,
{transport,thrift_buffered_transport,
{buffered_transport,
{transport,thrift_socket_transport,
{data,#Port<0.25469>,infinity}},
[]}},
true,true}},
0}