Exemplo n.º 1
0
        self.client.mutateRow(tname, row, mutations)

    def getOneRowData(self, tname, rowkey):
        return self.client.getRow(tname, rowkey)

    def getMoreRowData(self, tname, startRow, columns):
        return self.client.scannerOpen(tableName=tname,
                                       startRow=startRow,
                                       columns=columns)


if __name__ == "__main__":
    transport = TSocket.TSocket('118.190.159.190', 9090)
    transport = TTransport.TBufferedTransport(transport)
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
    client = Hbase.Client(protocol)
    transport.open()
    hbase = HBaseHelper(client)

    #get all table's name
    tnames = hbase.getAllTableName()
    print "tnames: ", tnames

    #create table
    content1 = ColumnDescriptor(name='f1:', maxVersions=1)
    content2 = ColumnDescriptor(name='f2:', maxVersions=1)
    content3 = ColumnDescriptor(name='f3:', maxVersions=1)
    content4 = ColumnDescriptor(name='f4:', maxVersions=1)
    hbase.createTable('testTable', [content1, content2, content3, content4])

    # insert data
Exemplo n.º 2
0
 def open(self):
     socket = TSocket.TSocket(self.host, self.port)
     self.transport = TTransport.TBufferedTransport(socket)
     protocol = TBinaryProtocol.TBinaryProtocol(self.transport)
     self.client = Hbase.Client(protocol)
     self.transport.open()