Git Product home page Git Product logo

pybase's Introduction

PyBase

Native Python HBase Client (i.e doesn't use Thrift) developed during an internship at Flipboard.

Currently supports the following commands -

  • Get
  • Scan
  • Put
  • Append
  • Increment
  • Delete

Additionally supports every filter here for gets and scans.

Development has slowed down now that I'm back at school. Would love help moving forward - see the contributing section for details.

Supported Versions

Developed on HBase >= 1.0. Theoretically compatible with any version of HBase utilizing Protobuf (0.96+) but wholly untested.

Installation

pip install git+git://github.com/CurleySamuel/PyBase.git

or add following to requirements.txt

git+git://github.com/hzhaofb/PyBase.git#egg=pybase

Example Usage

Create a client

import pybase
client = pybase.NewClient(zkquorum)

Insert a cell

#   values = {
#      "cf1": {
#           "mycol": "hodor",
#           "mycol2": "alsohodor"
#      },
#      "cf2": {
#           "mycolumn7": "nothodor"
#      }
#   }
rsp = client.put(table, key, values)

Get an entire row

rsp = client.get(table, key)

Get specific cells

#    families = {
#        "columnFamily1": [
#            "qual1",
#            "qual2"
#        ],
#        "columnFamily2": [
#            "qual3"
#        ]
#    }
rsp = client.get(table, key, families=families)

Get specific cells with a filter

from pybase import filters
pFilter = filters.KeyOnlyFilter(True)
rsp = client.get(table, key, families=families, filters=pFilter)

Scan with a filter

pFilter = filters.KeyOnlyFilter(True)
rsp = client.scan(table, filters=pFilter)

Construct complex filters

# Method 1
cFilter1 = filters.ColumnCountGetFilter(24)
cFilter2 = filters.ColumnRangeFilter("min", True, "max", True)
pFilter = filters.FilterList(filters.MUST_PASS_ALL, cFilter1, cFilter2)

# Method 2
pFilter = filters.FilterList(filters.MUST_PASS_ALL)
pFilter.add_filters(cFilter1, cFilter2)

Increment a cell

# inc_values = {
#     cf1: {
#         "oberyn": "\x00\x00\x00\x00\x00\x00\x00\x05",
#     },
#     cf2: {
#         "one": "\x00\x00\x00\x00\x00\x00\x00\x08"
#     }
# }
rsp = c.increment(table, key, inc_values)

Contributing

Development has slowed down now that I'm back at school. Would love help moving forward.

  • Here's a knowledge transfer document to help get up to speed.
  • I've created a few Github issues as a starting point.
  • If you want to help out feel free to shoot me an email so we don't step on each other's toes.

Setting up HBase

Want to try out the client locally? mblair helped write a bash script to install + setup HBase in pseudo-distributed mode on a vagrant instance.

License

Copyright © 2015 Samuel Curley. All rights reserved. Use of this source code is governed by the Apache License 2.0 that can be found in the LICENSE file.

pybase's People

Contributors

curleysamuel avatar hzhaofb avatar spicavigo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.