hbase

package module
v0.0.0-...-fb59d5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2017 License: BSD-3-Clause Imports: 17 Imported by: 1

README

go-hbase

UNMAINTAINED: See tsuna's implementation https://github.com/tsuna/gohbase

Implements a fully native HBase client for the Go programming language.

API Documentation: http://godoc.org/github.com/Lazyshot/go-hbase

Supported Versions

HBase >= 0.96.0

This version of HBase has a backwards incompatible change, which takes full use of protocol buffers for client interactions.

Installation

go get github.com/lazyshot/go-hbase

Example

package main

import (
	"github.com/lazyshot/go-hbase"

	"fmt"
	"log"
)

func main() {
	client := hbase.NewClient([]string{"localhost"}, "/hbase")

	put := hbase.CreateNewPut([]byte("test1"))
	put.AddStringValue("info", "test_qual", "test_val")
	res, err := client.Put("test", put)

	if err != nil {
		panic(err)
	}

	if !res {
		panic("No put results")
	}
	log.Println("Completed put")

	get := hbase.CreateNewGet([]byte("test1"))
	result, err := client.Get("test", get)

	if err != nil {
		panic(err)
	}

	if !bytes.Equal(result.Row, []byte("test1")) {
		panic("No row")
	}

	if !bytes.Equal(result.Columns["info:test_qual"].Value, []byte("test_val")) {
		panic("Value doesn't match")
	}

	log.Println("Completed get")

	results, err := client.Gets("test", []*hbase.Get{get})

	if err != nil {
		panic(err)
	}

	log.Printf("%#v", results)
}

License

Copyright (c) 2014-2015 Bryan Peterson. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(zkHosts []string, zkRoot string) *Client

func (*Client) AsyncGets

func (c *Client) AsyncGets(table string, results chan *ResultRow, gets []*Get)

func (*Client) Delete

func (c *Client) Delete(table string, del *Delete) (bool, error)

func (*Client) Deletes

func (c *Client) Deletes(table string, dels []*Delete) (bool, error)

func (*Client) Get

func (c *Client) Get(table string, get *Get) (*ResultRow, error)

func (*Client) GetTables

func (c *Client) GetTables() []TableInfo

func (*Client) Gets

func (c *Client) Gets(table string, gets []*Get) ([]*ResultRow, error)

func (*Client) Put

func (c *Client) Put(table string, put *Put) (bool, error)

func (*Client) Puts

func (c *Client) Puts(table string, puts []*Put) (bool, error)

func (*Client) Scan

func (c *Client) Scan(table string) *Scan

func (*Client) SetLogLevel

func (c *Client) SetLogLevel(level string)

type Delete

type Delete struct {
	// contains filtered or unexported fields
}

func CreateNewDelete

func CreateNewDelete(key []byte) *Delete

func (*Delete) AddColumn

func (this *Delete) AddColumn(family, qual []byte)

func (*Delete) AddFamily

func (this *Delete) AddFamily(family []byte)

func (*Delete) AddString

func (this *Delete) AddString(famqual string) error

func (*Delete) AddStringColumn

func (this *Delete) AddStringColumn(family, qual string)

func (*Delete) AddStringFamily

func (this *Delete) AddStringFamily(family string)

type EncodedValue

type EncodedValue []byte

func (EncodedValue) String

func (e EncodedValue) String() string

type Get

type Get struct {
	// contains filtered or unexported fields
}

func CreateNewGet

func CreateNewGet(key []byte) *Get

func (*Get) AddColumn

func (this *Get) AddColumn(family, qual []byte)

func (*Get) AddFamily

func (this *Get) AddFamily(family []byte)

func (*Get) AddString

func (this *Get) AddString(famqual string) error

func (*Get) AddStringColumn

func (this *Get) AddStringColumn(family, qual string)

func (*Get) AddStringFamily

func (this *Get) AddStringFamily(family string)

type Put

type Put struct {
	// contains filtered or unexported fields
}

func CreateNewPut

func CreateNewPut(key []byte) *Put

func (*Put) AddStringValue

func (this *Put) AddStringValue(family, column, value string)

func (*Put) AddStringValueTS

func (this *Put) AddStringValueTS(family, column, value string, ts int64)

AddStringValueTS use user specified timestamp

func (*Put) AddValue

func (this *Put) AddValue(family, column, value []byte)

func (*Put) AddValueTS

func (this *Put) AddValueTS(family, column, value []byte, ts int64)

AddValueTS use user specified timestamp

type ResultRow

type ResultRow struct {
	Row           EncodedValue
	Columns       map[string]*ResultRowColumn
	SortedColumns []*ResultRowColumn
}

type ResultRowColumn

type ResultRowColumn struct {
	ColumnName string

	Family    EncodedValue
	Qualifier EncodedValue

	Timestamp time.Time
	Value     EncodedValue

	Values map[time.Time]EncodedValue
}

type Scan

type Scan struct {
	StartRow []byte
	StopRow  []byte
	// contains filtered or unexported fields
}

func (*Scan) AddColumn

func (s *Scan) AddColumn(family, qual []byte)

func (*Scan) AddFamily

func (s *Scan) AddFamily(family []byte)

func (*Scan) AddString

func (s *Scan) AddString(famqual string) error

func (*Scan) AddStringColumn

func (s *Scan) AddStringColumn(family, qual string)

func (*Scan) AddStringFamily

func (s *Scan) AddStringFamily(family string)

func (*Scan) Close

func (s *Scan) Close()

func (*Scan) Map

func (s *Scan) Map(f func(*ResultRow))

func (*Scan) SetCached

func (s *Scan) SetCached(n int)

func (*Scan) SetTimeRange

func (s *Scan) SetTimeRange(from time.Time, to time.Time)

set scan time range

func (*Scan) SetTimeRangeFrom

func (s *Scan) SetTimeRangeFrom(from time.Time)

set scan time start only. if set start only, use a max timestamp as end automaticly. but since max timestamp is not a precise value, you'd better use `SetTimeRange()` set start and end yourself.

func (*Scan) SetTimeRangeTo

func (s *Scan) SetTimeRangeTo(to time.Time)

set scan time end only. if only set end, use time.Unix(0, 0)(Jan 1st, 1970) as start automaticly

type TableInfo

type TableInfo struct {
	TableName string
	Families  []string
}

type TimeRange

type TimeRange struct {
	From time.Time
	To   time.Time
}

Directories

Path Synopsis
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL