Because fluentd is used to collect logs, you need to use ruby to insert data to hbase through the thrift interface. After searching online, you find that many of them insert a single data, no
Because fluentd is used to collect logs, you need to use ruby to insert data to hbase through the thrift interface. After searching online, you find that many of them insert a single data, no
Because fluentd is used to collect logs at work, you need to use ruby to insert data to hbase through the thrift interface. After searching online, you find that many of them insert a single data, there is no way to modify the code by referring to batch inserts written in python.
$:. Unshift File. expand_path ('gen-rb', File. dirname (_ FILE __))
Require 'thrift'
Require File. expand_path ('gen-rb/hbase ', File. dirname (_ FILE __))
Transport = Thrift: BufferedTransport. new (Thrift: Socket. new ("localhost", "9090 "))
Transport. open
Client = Apache: Hadoop: Hbase: Thrift: Hbase: Client. new (Thrift: BinaryProtocol. new (transport ))
# Get Table meta data
Def newpass (len)
Chars = ("a"... "z"). to_a + ("A"... "Z"). to_a + ("0"... "9"). to_a
Newpass = ""
1. upto (len) {| I | newpass <chars [rand (chars. size-1)]}
Return newpass
End
Columnvalue = "v" * 10
Batchmutations = []
Starttime = Time. now
1000. times do | x |
Mutations = []
Rowkey = "RK _" <Time. now. strftime ('% Y % m % d _' <newpass (15 ))
5. times do | I |
Mutations <Apache: Hadoop: Hbase: Thrift: Mutation. new (: column => "f1:" <I. to_s,: value => columnvalue)
End
Batchmutations <Apache: Hadoop: Hbase: Thrift: BatchMutation. new (: row => rowkey,: mutations => mutations)
End
Client. mutateRows ("testdb2", batchmutations)