impalathing

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

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

Go to latest
Published: Apr 10, 2018 License: MIT Imports: 9 Imported by: 0

README

Impalathing is a small Go wrapper library the thrift interface go Impala

It's based on hivething

Working on this you quickly realize that having strings deliminated by tabs is a ugly API... (That's the thrift side of things)

Usage

package main

import (
    "log"
    "fmt"
    "time"
    "github.com/moriarty-s3a/impalathing"
)

func main() {
    host := "impala-host"
    port := 21000

    con, err := impalathing.Connect(host, port, impalathing.DefaultOptions)

    if err != nil {
        log.Fatal("Error connecting", err)
        return
    }

    query, err := con.Query("SELECT user_id, action, yyyymm FROM engagements LIMIT 10000")

    startTime := time.Now()
    total := 0
    for query.Next() {
        var (
            user_id     string
            action      string
            yyyymm      int
        )

        query.Scan(&user_id, &action, &yyyymm)
        total += 1

        fmt.Println(user_id, action)
    }

    log.Printf("Fetch %d rows(s) in %.2fs", total, time.Duration(time.Since(startTime)).Seconds())
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultOptions = Options{PollIntervalSeconds: 0.1, BatchSize: 1024}
)

Functions

func CloseCnn

func CloseCnn(itf interface{}) (err error)

func Dial

func Dial(name, host, port string) (interface{}, error)

func KeepAlive

func KeepAlive(itf interface{}) (err error)

Types

type Connection

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

func Connect

func Connect(host, port string, options Options) (*Connection, error)

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Ping

func (c *Connection) Ping() error

Add ping func for connection

func (*Connection) Query

func (c *Connection) Query(query string) (RowSet, error)

type Options

type Options struct {
	PollIntervalSeconds float64
	BatchSize           int32
}

type RowSet

type RowSet interface {
	Columns() []string
	Next() bool
	Scan(dest ...interface{}) error
	Poll() (*Status, error)
	Wait() (*Status, error)
	FetchAll() []map[string]interface{}

	Close() (err error)
}

A RowSet represents an asyncronous hive operation. You can Reattach to a previously submitted hive operation if you have a valid thrift client, and the serialized Handle() from the prior operation.

type Status

type Status struct {
	Error error
	// contains filtered or unexported fields
}

Represents job status, including success state and time the status was updated.

func (*Status) IsComplete

func (s *Status) IsComplete() bool

func (*Status) IsSuccess

func (s *Status) IsSuccess() bool

Jump to

Keyboard shortcuts

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