Help us shape the future of Go! Take the 2026 Go Developer Survey

pilosa

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: BSD-3-Clause Imports: 21 Imported by: 0

README

Go Client for Pilosa

GoDoc

Go client for Pilosa high performance distributed bitmap index.

What's New?

See: CHANGELOG

Requirements

  • Go 1.9 and higher

Install

Download the library in your GOPATH using:

go get github.com/pilosa/go-pilosa

After that, you can import the library in your code using:

import "github.com/pilosa/go-pilosa"

Usage

Quick overview

Assuming Pilosa server is running at localhost:10101 (the default):

var err error

// Create the default client
client := pilosa.DefaultClient()

// Retrieve the schema
schema, err := client.Schema()

// Create an Index object
myindex, err := schema.Index("myindex")

// Create a Frame object
myframe, err := myindex.Frame("myframe")

// make sure the index and frame exists on the server
err = client.SyncSchema(schema)

// Send a SetBit query. PilosaException is thrown if execution of the query fails.
response, err := client.Query(myframe.SetBit(5, 42))

// Send a Bitmap query. PilosaException is thrown if execution of the query fails.
response, err = client.Query(myframe.Bitmap(5))

// Get the result
result := response.Result()
// Act on the result
if result != nil {
    bits := result.Bitmap().Bits
    fmt.Println("Got bits: ", bits)
}

// You can batch queries to improve throughput
response, err = client.Query(myindex.BatchQuery(
    myframe.Bitmap(5),
    myframe.Bitmap(10)))
if err != nil {
    fmt.Println(err)
}

for _, result := range response.Results() {
    // Act on the result
    fmt.Println(result.Bitmap().Bits)
}

Documentation

Data Model and Queries

See: Data Model and Queries

Executing Queries

See: Server Interaction

Importing and Exporting Data

See: Importing and Exporting Data

Contributing

See: CONTRIBUTING

License

See: LICENSE

Documentation

Overview

Package pilosa enables querying a Pilosa server.

This client uses Pilosa's http+protobuf API.

Usage:

import (
	"fmt"
	pilosa "github.com/pilosa/go-pilosa"
)

// Create a Client instance
client := pilosa.DefaultClient()

// Create a Schema instance
schema, err := client.Schema()
if err != nil {
	panic(err)
}

// Create an Index instance
index, err := schema.Index("repository")
if err != nil {
	panic(err)
}

// Create a Frame instance
stargazer, err := index.Frame("stargazer")
if err != nil {
	panic(err)
}

// Sync the schema with the server-side, so non-existing indexes/frames are created on the server-side.
err = client.SyncSchema(schema)
if err != nil {
	panic(err)
}

// Execute a query
response, err := client.Query(stargazer.Bitmap(5))
if err != nil {
	panic(err)
}

// Act on the result
fmt.Println(response.Result())

See also https://www.pilosa.com/docs/api-reference/ and https://www.pilosa.com/docs/query-language/.

Index

Constants

View Source
const (
	QueryResultTypeNil uint32 = iota
	QueryResultTypeBitmap
	QueryResultTypePairs
	QueryResultTypeValCount
	QueryResultTypeUint64
	QueryResultTypeBool
)

QueryResponse types.

View Source
const Version = "v0.8.0-16-g46c8a62"

Variables

View Source
var (
	ErrorEmptyCluster     = NewError("No usable addresses in the cluster")
	ErrorIndexExists      = NewError("Index exists")
	ErrorFrameExists      = NewError("Frame exists")
	ErrorInvalidIndexName = NewError("Invalid index name")
	ErrorInvalidFrameName = NewError("Invalid frame name")
	ErrorInvalidLabel     = NewError("Invalid label")
	ErrorTriedMaxHosts    = NewError("Tried max hosts, still failing")
)

Predefined Pilosa errors. Deprecated. Use Err forms instead.

View Source
var (
	ErrEmptyCluster           = NewError("No usable addresses in the cluster")
	ErrIndexExists            = NewError("Index exists")
	ErrFrameExists            = NewError("Frame exists")
	ErrInvalidIndexName       = NewError("Invalid index name")
	ErrInvalidFrameName       = NewError("Invalid frame name")
	ErrInvalidLabel           = NewError("Invalid label")
	ErrInvalidKey             = NewError("Invalid key")
	ErrTriedMaxHosts          = NewError("Tried max hosts, still failing")
	ErrAddrURIClusterExpected = NewError("Addresses, URIs or a cluster is expected")
	ErrInvalidQueryOption     = NewError("Invalid query option")
	ErrInvalidIndexOption     = NewError("Invalid index option")
	ErrInvalidFrameOption     = NewError("Invalid frame option")
	ErrNoFragmentNodes        = NewError("No fragment nodes")
	ErrNoSlice                = NewError("Index has no slices")
	ErrUnknownType            = NewError("Unknown type")
)

Predefined Pilosa errors.

Functions

func ValidFrameName

func ValidFrameName(name string) bool

ValidFrameName returns true if the given frame name is valid, otherwise false.

func ValidIndexName

func ValidIndexName(name string) bool

ValidIndexName returns true if the given index name is valid, otherwise false.

func ValidKey added in v0.9.0

func ValidKey(key string) bool

ValidKey returns true if the given key is valid, otherwise false.

func ValidLabel

func ValidLabel(label string) bool

ValidLabel returns true if the given label is valid, otherwise false.

Types

type Bit added in v0.5.0

type Bit struct {
	RowID     uint64
	ColumnID  uint64
	Timestamp int64
}

Bit defines a single Pilosa bit.

func (Bit) Int64Field added in v0.9.0

func (b Bit) Int64Field(index int) int64

func (Bit) Less added in v0.9.0

func (b Bit) Less(other Record) bool

func (Bit) StringField added in v0.9.0

func (b Bit) StringField(index int) string

func (Bit) Uint64Field added in v0.9.0

func (b Bit) Uint64Field(index int) uint64

type BitmapResult

type BitmapResult struct {
	Attributes map[string]interface{} `json:"attrs"`
	Bits       []uint64               `json:"bits"`
	Keys       []string               `json:"keys"`
}

BitmapResult represents a result from Bitmap, Union, Intersect, Difference and Range PQL calls.

func (BitmapResult) Bitmap added in v0.9.0

func (b BitmapResult) Bitmap() BitmapResult

func (BitmapResult) Changed added in v0.9.0

func (BitmapResult) Changed() bool

func (BitmapResult) Count added in v0.9.0

func (BitmapResult) Count() int64

func (BitmapResult) CountItems added in v0.9.0

func (BitmapResult) CountItems() []CountResultItem

func (BitmapResult) MarshalJSON added in v0.9.0

func (b BitmapResult) MarshalJSON() ([]byte, error)

func (BitmapResult) Type added in v0.9.0

func (BitmapResult) Type() uint32

func (BitmapResult) Value added in v0.9.0

func (BitmapResult) Value() int64

type BoolResult added in v0.9.0

type BoolResult bool

func (BoolResult) Bitmap added in v0.9.0

func (BoolResult) Bitmap() BitmapResult

func (BoolResult) Changed added in v0.9.0

func (b BoolResult) Changed() bool

func (BoolResult) Count added in v0.9.0

func (BoolResult) Count() int64

func (BoolResult) CountItems added in v0.9.0

func (BoolResult) CountItems() []CountResultItem

func (BoolResult) Type added in v0.9.0

func (BoolResult) Type() uint32

func (BoolResult) Value added in v0.9.0

func (BoolResult) Value() int64

type CSVIterator added in v0.9.0

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

CSVIterator reads records from a Reader. Each line should contain a single record in the following form: field1,field2,...

func NewCSVBitIterator added in v0.5.0

func NewCSVBitIterator(reader io.Reader) *CSVIterator

func NewCSVBitIteratorWithTimestampFormat added in v0.7.0

func NewCSVBitIteratorWithTimestampFormat(reader io.Reader, timestampFormat string) *CSVIterator

func NewCSVIterator added in v0.9.0

func NewCSVIterator(reader io.Reader, unmarshaller CSVRecordUnmarshaller) *CSVIterator

NewCSVIterator creates a CSVIterator from a Reader.

func NewCSVValueIterator added in v0.7.0

func NewCSVValueIterator(reader io.Reader) *CSVIterator

func (*CSVIterator) NextRecord added in v0.9.0

func (c *CSVIterator) NextRecord() (Record, error)

NextRecord iterates on lines of a Reader. Returns io.EOF on end of iteration.

type CSVRecordUnmarshaller added in v0.9.0

type CSVRecordUnmarshaller func(text string) (Record, error)

func BitCSVUnmarshaller added in v0.9.0

func BitCSVUnmarshaller() CSVRecordUnmarshaller

func BitCSVUnmarshallerWithTimestamp added in v0.9.0

func BitCSVUnmarshallerWithTimestamp(timestampFormat string) CSVRecordUnmarshaller

type CacheType

type CacheType string

CacheType represents cache type for a frame

const (
	CacheTypeDefault CacheType = ""
	CacheTypeLRU     CacheType = "lru"
	CacheTypeRanked  CacheType = "ranked"
)

CacheType constants

type Client

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

Client is the HTTP client for Pilosa server.

func DefaultClient

func DefaultClient() *Client

DefaultClient creates a client with the default address and options.

func NewClient added in v0.8.0

func NewClient(addrUriOrCluster interface{}, options ...ClientOption) (*Client, error)

NewClient creates a client with the given address, URI, or cluster and options.

func (*Client) CreateFrame

func (c *Client) CreateFrame(frame *Frame) error

CreateFrame creates a frame on the server using the given Frame struct.

func (*Client) CreateIndex

func (c *Client) CreateIndex(index *Index) error

CreateIndex creates an index on the server using the given Index struct.

func (*Client) CreateIntField added in v0.7.0

func (c *Client) CreateIntField(frame *Frame, name string, min int, max int) error

CreateIntField creates an integer range field. *Experimental*: This feature may be removed or its interface may be modified in the future.

func (*Client) DeleteField added in v0.7.0

func (c *Client) DeleteField(frame *Frame, name string) error

DeleteField delete a range field. *Experimental*: This feature may be removed or its interface may be modified in the future.

func (*Client) DeleteFrame

func (c *Client) DeleteFrame(frame *Frame) error

DeleteFrame deletes a frame on the server.

func (*Client) DeleteIndex

func (c *Client) DeleteIndex(index *Index) error

DeleteIndex deletes an index on the server.

func (*Client) EnsureFrame

func (c *Client) EnsureFrame(frame *Frame) error

EnsureFrame creates a frame on the server if it doesn't exists.

func (*Client) EnsureIndex

func (c *Client) EnsureIndex(index *Index) error

EnsureIndex creates an index on the server if it does not exist.

func (*Client) ExportFrame added in v0.5.0

func (c *Client) ExportFrame(frame *Frame, view string) (RecordIterator, error)

ExportFrame exports bits for a frame.

func (*Client) HttpRequest added in v0.8.0

func (c *Client) HttpRequest(method string, path string, data []byte, headers map[string]string) (*http.Response, []byte, error)

HttpRequest sends an HTTP request to the Pilosa server. **NOTE**: This function is experimental and may be removed in later revisions.

func (*Client) ImportFrame added in v0.5.0

func (c *Client) ImportFrame(frame *Frame, iterator RecordIterator, options ...ImportOption) error

ImportFrame imports bits from the given iterator.

func (*Client) ImportValueFrame added in v0.7.0

func (c *Client) ImportValueFrame(frame *Frame, field string, iterator RecordIterator, options ...ImportOption) error

func (*Client) Query

func (c *Client) Query(query PQLQuery, options ...interface{}) (*QueryResponse, error)

Query runs the given query against the server with the given options. Pass nil for default options.

func (*Client) Schema

func (c *Client) Schema() (*Schema, error)

Schema returns the indexes and frames on the server.

func (*Client) Status added in v0.9.0

func (c *Client) Status() (Status, error)

Status returns the serves status.

func (*Client) SyncSchema added in v0.5.0

func (c *Client) SyncSchema(schema *Schema) error

SyncSchema updates a schema with the indexes and frames on the server and creates the indexes and frames in the schema on the server side. This function does not delete indexes and the frames on the server side nor in the schema.

func (*Client) Views added in v0.5.0

func (c *Client) Views(frame *Frame) ([]string, error)

Views fetches and returns the views of a frame

type ClientOption added in v0.8.0

type ClientOption func(options *ClientOptions) error

ClientOption is used when creating a PilosaClient struct.

func ConnectTimeout added in v0.8.0

func ConnectTimeout(timeout time.Duration) ClientOption

ConnectTimeout is the maximum time to connect in nanoseconds. *DEPRECATED* Use OptClientConnectTimeout instead.

func LegacyMode added in v0.9.0

func LegacyMode(enable bool) ClientOption

LegacyMode enables legacy mode *DEPRECATED*

func OptClientConnectTimeout added in v0.9.0

func OptClientConnectTimeout(timeout time.Duration) ClientOption

OptClientConnectTimeout is the maximum time to connect in nanoseconds.

func OptClientPoolSizePerRoute added in v0.9.0

func OptClientPoolSizePerRoute(size int) ClientOption

OptPoolSizePerRoute is the maximum number of active connections in the pool to a host.

func OptClientSocketTimeout added in v0.9.0

func OptClientSocketTimeout(timeout time.Duration) ClientOption

OptClientSocketTimeout is the maximum idle socket time in nanoseconds

func OptClientTLSConfig added in v0.9.0

func OptClientTLSConfig(config *tls.Config) ClientOption

OptClientTLSConfig contains the TLS configuration.

func OptClientTotalPoolSize added in v0.9.0

func OptClientTotalPoolSize(size int) ClientOption

OptClientTotalPoolSize is the maximum number of connections in the pool.

func PoolSizePerRoute added in v0.8.0

func PoolSizePerRoute(size int) ClientOption

PoolSizePerRoute is the maximum number of active connections in the pool to a host. *DEPRECATED* Use OptClientPoolSizePerRoute instead.

func SkipVersionCheck added in v0.9.0

func SkipVersionCheck() ClientOption

SkipVersionCheck disables version checking *DEPRECATED*

func SocketTimeout added in v0.8.0

func SocketTimeout(timeout time.Duration) ClientOption

SocketTimeout is the maximum idle socket time in nanoseconds *DEPRECATED* Use OptClientSocketTimeout instead.

func TLSConfig added in v0.8.0

func TLSConfig(config *tls.Config) ClientOption

TLSConfig contains the TLS configuration. *DEPRECATED* Use OptClientTLSConfig instead.

func TotalPoolSize added in v0.8.0

func TotalPoolSize(size int) ClientOption

TotalPoolSize is the maximum number of connections in the pool. *DEPRECATED* Use OptClientTotalPoolSize instead.

type ClientOptions

type ClientOptions struct {
	SocketTimeout    time.Duration
	ConnectTimeout   time.Duration
	PoolSizePerRoute int
	TotalPoolSize    int
	TLSConfig        *tls.Config
}

ClientOptions control the properties of client connection to the server.

type Cluster

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

Cluster contains hosts in a Pilosa cluster.

func DefaultCluster

func DefaultCluster() *Cluster

DefaultCluster returns the default Cluster.

func NewClusterWithHost

func NewClusterWithHost(hosts ...*URI) *Cluster

NewClusterWithHost returns a cluster with the given URIs.

func (*Cluster) AddHost

func (c *Cluster) AddHost(address *URI)

AddHost adds a host to the cluster.

func (*Cluster) Host

func (c *Cluster) Host() *URI

Host returns a host in the cluster.

func (*Cluster) Hosts

func (c *Cluster) Hosts() []URI

Hosts returns all available hosts in the cluster.

func (*Cluster) RemoveHost

func (c *Cluster) RemoveHost(address *URI)

RemoveHost black lists the host with the given URI from the cluster.

type ColumnItem

type ColumnItem struct {
	ID         uint64                 `json:"id,omitempty"`
	Key        string                 `json:"key,omitempty"`
	Attributes map[string]interface{} `json:"attributes,omitempty"`
}

ColumnItem represents data about a column. Column data is only returned if QueryOptions.Columns was set to true.

type CountResultItem

type CountResultItem struct {
	ID    uint64 `json:"id"`
	Key   string `json:"key,omitempty"`
	Count uint64 `json:"count"`
}

CountResultItem represents a result from TopN call.

func (*CountResultItem) String added in v0.8.0

func (c *CountResultItem) String() string

type Error

type Error struct {
	Message string
}

Error contains a Pilosa specific error.

func NewError

func NewError(message string) *Error

NewError creates a Pilosa error.

func (Error) Error

func (e Error) Error() string

type FieldValue added in v0.7.0

type FieldValue struct {
	ColumnID  uint64
	ColumnKey string
	Value     int64
}

FieldValue represents the value for a column within a range-encoded frame.

func (FieldValue) Int64Field added in v0.9.0

func (f FieldValue) Int64Field(index int) int64

func (FieldValue) Less added in v0.9.0

func (v FieldValue) Less(other Record) bool

func (FieldValue) StringField added in v0.9.0

func (f FieldValue) StringField(index int) string

func (FieldValue) Uint64Field added in v0.9.0

func (f FieldValue) Uint64Field(index int) uint64

type Frame

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

Frame structs are used to segment and define different functional characteristics within your entire index. You can think of a Frame as a table-like data partition within your Index. Row-level attributes are namespaced at the Frame level.

func (*Frame) Bitmap

func (f *Frame) Bitmap(rowID uint64) *PQLBitmapQuery

Bitmap creates a bitmap query. Bitmap retrieves the indices of all the set bits in a row or column based on whether the row label or column label is given in the query. It also retrieves any attributes set on that row or column.

func (*Frame) BitmapK added in v0.9.0

func (f *Frame) BitmapK(rowKey string) *PQLBitmapQuery

BitmapK creates a Bitmap query using a string key instead of an integer rowID. This will only work against a Pilosa Enterprise server.

func (*Frame) BitmapTopN

func (f *Frame) BitmapTopN(n uint64, bitmap *PQLBitmapQuery) *PQLBitmapQuery

BitmapTopN creates a TopN query with the given item count and bitmap. This variant supports customizing the bitmap query.

func (*Frame) ClearBit

func (f *Frame) ClearBit(rowID uint64, columnID uint64) *PQLBaseQuery

ClearBit creates a ClearBit query. ClearBit, assigns a value of 0 to a bit in the binary matrix, thus disassociating the given row in the given frame from the given column.

func (*Frame) ClearBitK added in v0.9.0

func (f *Frame) ClearBitK(rowKey string, columnKey string) *PQLBaseQuery

ClearBitK creates a ClearBit query using string row and column keys. This will only work against a Pilosa Enterprise server.

func (*Frame) Field added in v0.7.0

func (f *Frame) Field(name string) *RangeField

Field returns a field to operate on.

func (*Frame) Fields added in v0.8.0

func (f *Frame) Fields() map[string]*RangeField

Fields return a copy of the fields in this frame

func (*Frame) FilterFieldTopN

func (f *Frame) FilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery

FilterFieldTopN creates a TopN query with the given item count, bitmap, field and the filter for that field The field and filters arguments work together to only return Bitmaps which have the attribute specified by field with one of the values specified in filters.

func (*Frame) InverseBitmap

func (f *Frame) InverseBitmap(columnID uint64) *PQLBaseQuery

InverseBitmap creates a bitmap query using the column label. Bitmap retrieves the indices of all the set bits in a row or column based on whether the row label or column label is given in the query. It also retrieves any attributes set on that row or column. *DEPRECATED*

func (*Frame) InverseBitmapK added in v0.9.0

func (f *Frame) InverseBitmapK(columnKey string) *PQLBaseQuery

InverseBitmapK creates a Bitmap query using a string key instead of an integer columnID. This will only work against a Pilosa Enterprise server.

func (*Frame) InverseBitmapTopN added in v0.4.0

func (f *Frame) InverseBitmapTopN(n uint64, bitmap *PQLBitmapQuery) *PQLBitmapQuery

InverseBitmapTopN creates a TopN query with the given item count and bitmap. This variant supports customizing the bitmap query and sets inverse=true. *DEPRECATED*

func (*Frame) InverseFilterFieldTopN added in v0.4.0

func (f *Frame) InverseFilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery

InverseFilterFieldTopN creates a TopN query with the given item count, bitmap, field and the filter for that field The field and filters arguments work together to only return Bitmaps which have the attribute specified by field with one of the values specified in filters. This variant sets inverse=true. *DEPRECATED*

func (*Frame) InverseRange added in v0.4.0

func (f *Frame) InverseRange(columnID uint64, start time.Time, end time.Time) *PQLBitmapQuery

InverseRange creates a Range query. Similar to Bitmap, but only returns bits which were set with timestamps between the given start and end timestamps. *DEPRECATED*

func (*Frame) InverseRangeK added in v0.9.0

func (f *Frame) InverseRangeK(columnKey string, start time.Time, end time.Time) *PQLBitmapQuery

InverseRangeK creates a Range query using a string column key. This will only work against a Pilosa Enterprise server. *DEPRECATED*

func (*Frame) InverseTopN added in v0.4.0

func (f *Frame) InverseTopN(n uint64) *PQLBitmapQuery

InverseTopN creates a TopN query with the given item count. Returns the id and count of the top n bitmaps (by count of bits) in the frame. This variant sets inverse=true *DEPRECATED*

func (*Frame) Name added in v0.5.0

func (f *Frame) Name() string

Name returns the name of the frame

func (*Frame) Range

func (f *Frame) Range(rowID uint64, start time.Time, end time.Time) *PQLBitmapQuery

Range creates a Range query. Similar to Bitmap, but only returns bits which were set with timestamps between the given start and end timestamps.

func (*Frame) RangeK added in v0.9.0

func (f *Frame) RangeK(rowKey string, start time.Time, end time.Time) *PQLBitmapQuery

RangeK creates a Range query using a string row key. This will only work against a Pilosa Enterprise server.

func (*Frame) SetBit

func (f *Frame) SetBit(rowID uint64, columnID uint64) *PQLBaseQuery

SetBit creates a SetBit query. SetBit, assigns a value of 1 to a bit in the binary matrix, thus associating the given row in the given frame with the given column.

func (*Frame) SetBitK added in v0.9.0

func (f *Frame) SetBitK(rowKey string, columnKey string) *PQLBaseQuery

SetBitK creates a SetBit query using string row and column keys. This will only work against a Pilosa Enterprise server.

func (*Frame) SetBitTimestamp

func (f *Frame) SetBitTimestamp(rowID uint64, columnID uint64, timestamp time.Time) *PQLBaseQuery

SetBitTimestamp creates a SetBit query with timestamp. SetBit, assigns a value of 1 to a bit in the binary matrix, thus associating the given row in the given frame with the given column.

func (*Frame) SetBitTimestampK added in v0.9.0

func (f *Frame) SetBitTimestampK(rowKey string, columnKey string, timestamp time.Time) *PQLBaseQuery

SetBitTimestampK creates a SetBitK query with timestamp.

func (*Frame) SetIntFieldValue added in v0.7.0

func (f *Frame) SetIntFieldValue(columnID uint64, field string, value int) *PQLBaseQuery

SetIntFieldValue creates a SetFieldValue query. *DEPRECATED* Use `frame.SetIntValue(columnID, value)` instead.

func (*Frame) SetRowAttrs

func (f *Frame) SetRowAttrs(rowID uint64, attrs map[string]interface{}) *PQLBaseQuery

SetRowAttrs creates a SetRowAttrs query. SetRowAttrs associates arbitrary key/value pairs with a row in a frame. Following types are accepted: integer, float, string and boolean types.

func (*Frame) SetRowAttrsK added in v0.9.0

func (f *Frame) SetRowAttrsK(rowKey string, attrs map[string]interface{}) *PQLBaseQuery

SetRowAttrsK creates a SetRowAttrs query using a string row key. This will only work against a Pilosa Enterprise server.

func (*Frame) String added in v0.8.0

func (f *Frame) String() string

func (*Frame) Sum added in v0.7.0

func (f *Frame) Sum(bitmap *PQLBitmapQuery, field string) *PQLBaseQuery

Sum creates a Sum query. The corresponding frame should include the field in its options. *DEPRECATED* Use `field.Sum(bitmap)` instead.

func (*Frame) TopN

func (f *Frame) TopN(n uint64) *PQLBitmapQuery

TopN creates a TopN query with the given item count. Returns the id and count of the top n bitmaps (by count of bits) in the frame.

type FrameInfo

type FrameInfo struct {
	Name string `json:"name"`
}

FrameInfo represents schema information for a frame.

type FrameOption added in v0.8.0

type FrameOption func(options *FrameOptions) error

FrameOption is used to pass an option to index.Frame function.

func CacheSize added in v0.8.0

func CacheSize(size uint) FrameOption

CacheSize sets the cache size. *DEPRECATED* Use OptFrameCacheSize instead.

func IntField added in v0.8.0

func IntField(name string, min int, max int) FrameOption

IntField adds an integer field to the frame. *DEPRECATED* Use OptFrameIntField instead.

func InverseEnabled added in v0.8.0

func InverseEnabled(enabled bool) FrameOption

InverseEnabled enables inverse frame. *DEPRECATED*

func OptFrameCacheSize added in v0.9.0

func OptFrameCacheSize(size uint) FrameOption

OptFrameCacheSize sets the cache size.

func OptFrameIntField added in v0.9.0

func OptFrameIntField(name string, min int, max int) FrameOption

OptFrameIntField adds an integer field to the frame.

func RangeEnabled added in v0.8.0

func RangeEnabled(enabled bool) FrameOption

RangeEnabled enables range encoding for a frame. *DEPRECATED*

type FrameOptions

type FrameOptions struct {
	// If a Frame has a time quantum, then Views are generated for each of the defined time segments.
	TimeQuantum TimeQuantum
	// Enables inverted frames
	InverseEnabled bool
	CacheType      CacheType
	CacheSize      uint
	RangeEnabled   bool
	// contains filtered or unexported fields
}

FrameOptions contains options to customize Frame objects and frame queries. *DEPRECATED* `RowLabel` field is deprecated and will be removed in a future release.

func (*FrameOptions) AddIntField added in v0.7.0

func (fo *FrameOptions) AddIntField(name string, min int, max int) error

AddIntField adds an integer field to the frame options

func (FrameOptions) String

func (fo FrameOptions) String() string

type ImportOption added in v0.9.0

type ImportOption func(options *ImportOptions) error

ImportOption is used when running imports.

func OptImportBatchSize added in v0.9.0

func OptImportBatchSize(batchSize int) ImportOption

func OptImportStatusChannel added in v0.9.0

func OptImportStatusChannel(statusChan chan<- ImportStatusUpdate) ImportOption

func OptImportStrategy added in v0.9.0

func OptImportStrategy(strategy ImportWorkerStrategy) ImportOption

func OptImportThreadCount added in v0.9.0

func OptImportThreadCount(count int) ImportOption

func OptImportTimeout added in v0.9.0

func OptImportTimeout(timeout time.Duration) ImportOption

type ImportOptions added in v0.9.0

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

type ImportStatusUpdate added in v0.9.0

type ImportStatusUpdate struct {
	ThreadID      int
	Slice         uint64
	ImportedCount int
	Time          time.Duration
}

type ImportWorkerStrategy added in v0.9.0

type ImportWorkerStrategy int
const (
	DefaultImport ImportWorkerStrategy = iota
	BatchImport
	TimeoutImport
)

type Index

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

Index is a Pilosa index. The purpose of the Index is to represent a data namespace. You cannot perform cross-index queries. Column-level attributes are global to the Index.

func NewIndex

func NewIndex(name string) (*Index, error)

NewIndex creates an index with a name.

func (*Index) BatchQuery

func (idx *Index) BatchQuery(queries ...PQLQuery) *PQLBatchQuery

BatchQuery creates a batch query with the given queries.

func (*Index) Count

func (idx *Index) Count(bitmap *PQLBitmapQuery) *PQLBaseQuery

Count creates a Count query. Returns the number of set bits in the BITMAP_CALL passed in.

func (*Index) Difference

func (idx *Index) Difference(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery

Difference creates an Intersect query. Difference returns all of the bits from the first BITMAP_CALL argument passed to it, without the bits from each subsequent BITMAP_CALL.

func (*Index) Frame

func (idx *Index) Frame(name string, options ...interface{}) (*Frame, error)

Frame creates a frame struct with the specified name and defaults.

func (*Index) Frames added in v0.5.0

func (idx *Index) Frames() map[string]*Frame

Frames return a copy of the frames in this index

func (*Index) Intersect

func (idx *Index) Intersect(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery

Intersect creates an Intersect query. Intersect performs a logical AND on the results of each BITMAP_CALL query passed to it.

func (*Index) Name

func (idx *Index) Name() string

Name returns the name of this index.

func (*Index) RawQuery

func (idx *Index) RawQuery(query string) *PQLBaseQuery

RawQuery creates a query with the given string. Note that the query is not validated before sending to the server.

func (*Index) SetColumnAttrs

func (idx *Index) SetColumnAttrs(columnID uint64, attrs map[string]interface{}) *PQLBaseQuery

SetColumnAttrs creates a SetColumnAttrs query. SetColumnAttrs associates arbitrary key/value pairs with a column in an index. Following types are accepted: integer, float, string and boolean types.

func (*Index) String added in v0.8.0

func (idx *Index) String() string

func (*Index) Union

func (idx *Index) Union(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery

Union creates a Union query. Union performs a logical OR on the results of each BITMAP_CALL query passed to it.

func (*Index) Xor added in v0.7.0

func (idx *Index) Xor(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery

Xor creates an Xor query.

type IntResult added in v0.9.0

type IntResult int64

func (IntResult) Bitmap added in v0.9.0

func (IntResult) Bitmap() BitmapResult

func (IntResult) Changed added in v0.9.0

func (IntResult) Changed() bool

func (IntResult) Count added in v0.9.0

func (i IntResult) Count() int64

func (IntResult) CountItems added in v0.9.0

func (IntResult) CountItems() []CountResultItem

func (IntResult) Type added in v0.9.0

func (IntResult) Type() uint32

func (IntResult) Value added in v0.9.0

func (IntResult) Value() int64

type NilResult added in v0.9.0

type NilResult struct{}

func (NilResult) Bitmap added in v0.9.0

func (NilResult) Bitmap() BitmapResult

func (NilResult) Changed added in v0.9.0

func (NilResult) Changed() bool

func (NilResult) Count added in v0.9.0

func (NilResult) Count() int64

func (NilResult) CountItems added in v0.9.0

func (NilResult) CountItems() []CountResultItem

func (NilResult) Type added in v0.9.0

func (NilResult) Type() uint32

func (NilResult) Value added in v0.9.0

func (NilResult) Value() int64

type PQLBaseQuery

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

PQLBaseQuery is the base implementation for PQLQuery.

func NewPQLBaseQuery

func NewPQLBaseQuery(pql string, index *Index, err error) *PQLBaseQuery

NewPQLBaseQuery creates a new PQLQuery with the given PQL and index.

func (PQLBaseQuery) Error

func (q PQLBaseQuery) Error() error

Error returns the error or nil for this query.

func (*PQLBaseQuery) Index

func (q *PQLBaseQuery) Index() *Index

Index returns the index for this query

type PQLBatchQuery

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

PQLBatchQuery contains a batch of PQL queries. Use Index.BatchQuery function to create an instance.

Usage:

index, err := NewIndex("repository", nil)
stargazer, err := index.Frame("stargazer", nil)
query := repo.BatchQuery(
	stargazer.Bitmap(5),
	stargazer.Bitmap(15),
	repo.Union(stargazer.Bitmap(20), stargazer.Bitmap(25)))

func (*PQLBatchQuery) Add

func (q *PQLBatchQuery) Add(query PQLQuery)

Add adds a query to the batch.

func (*PQLBatchQuery) Error

func (q *PQLBatchQuery) Error() error

func (*PQLBatchQuery) Index

func (q *PQLBatchQuery) Index() *Index

Index returns the index for this query.

type PQLBitmapQuery

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

PQLBitmapQuery is the return type for bitmap queries.

func NewPQLBitmapQuery

func NewPQLBitmapQuery(pql string, index *Index, err error) *PQLBitmapQuery

NewPQLBitmapQuery creates a new PqlBitmapQuery.

func (PQLBitmapQuery) Error

func (q PQLBitmapQuery) Error() error

Error returns the error or nil for this query.

func (*PQLBitmapQuery) Index

func (q *PQLBitmapQuery) Index() *Index

Index returns the index for this query/

type PQLQuery

type PQLQuery interface {
	Index() *Index

	Error() error
	// contains filtered or unexported methods
}

PQLQuery is an interface for PQL queries.

type QueryOption added in v0.8.0

type QueryOption func(options *QueryOptions) error

QueryOption is used when using options with a client.Query,

func ColumnAttrs added in v0.8.0

func ColumnAttrs(enable bool) QueryOption

ColumnAttrs enables returning column attributes in the result. *DEPRECATED* Use OptQueryColumnAttrs instead.

func ExcludeAttrs added in v0.8.0

func ExcludeAttrs(enable bool) QueryOption

ExcludeAttrs enables discarding attributes from a result, *DEPRECATED* Use OptQueryExcludeAttrs instead.

func ExcludeBits added in v0.8.0

func ExcludeBits(enable bool) QueryOption

ExcludeBits enables discarding bits from a result, *DEPRECATED* Use OptQueryExcludeBits instead.

func OptQueryColumnAttrs added in v0.9.0

func OptQueryColumnAttrs(enable bool) QueryOption

OptQueryColumnAttrs enables returning column attributes in the result.

func OptQueryExcludeAttrs added in v0.9.0

func OptQueryExcludeAttrs(enable bool) QueryOption

OptQueryExcludeAttrs enables discarding attributes from a result,

func OptQueryExcludeBits added in v0.9.0

func OptQueryExcludeBits(enable bool) QueryOption

OptQueryExcludeBits enables discarding bits from a result,

func OptQuerySlices added in v0.9.0

func OptQuerySlices(slices ...uint64) QueryOption

OptQuerySlices restricts the set of slices on which a query operates.

func Slices added in v0.9.0

func Slices(slices ...uint64) QueryOption

Slices restricts the set of slices on which a query operates. *DEPRECATED* Use OptQuerySlices instead.

type QueryOptions

type QueryOptions struct {
	// Slices restricts query to a subset of slices. Queries all slices if nil.
	Slices []uint64
	// Columns enables returning columns in the query response.
	Columns bool
	// ExcludeAttrs inhibits returning attributes
	ExcludeAttrs bool
	// ExcludeBits inhibits returning bits
	ExcludeBits bool
}

QueryOptions contains options to customize the Query function.

type QueryResponse

type QueryResponse struct {
	ResultList   []QueryResult `json:"results,omitempty"`
	ColumnList   []ColumnItem  `json:"columns,omitempty"`
	ErrorMessage string        `json:"error-message,omitempty"`
	Success      bool          `json:"success,omitempty"`
}

QueryResponse represents the response from a Pilosa query.

func (*QueryResponse) Column

func (qr *QueryResponse) Column() ColumnItem

Column returns the first column.

func (*QueryResponse) Columns

func (qr *QueryResponse) Columns() []ColumnItem

Columns returns all columns in the response.

func (*QueryResponse) Result

func (qr *QueryResponse) Result() QueryResult

Result returns the first result or nil.

func (*QueryResponse) Results

func (qr *QueryResponse) Results() []QueryResult

Results returns all results in the response.

type QueryResult

type QueryResult interface {
	Type() uint32
	Bitmap() BitmapResult
	CountItems() []CountResultItem
	Count() int64
	Value() int64
	Changed() bool
}

QueryResult represents one of the results in the response.

type RangeField added in v0.7.0

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

RangeField enables writing queries for range encoded fields.

func (*RangeField) Between added in v0.7.0

func (field *RangeField) Between(a int, b int) *PQLBitmapQuery

Between creates a between query.

func (*RangeField) Equals added in v0.9.0

func (field *RangeField) Equals(n int) *PQLBitmapQuery

Equals creates an equals query.

func (*RangeField) GT added in v0.7.0

func (field *RangeField) GT(n int) *PQLBitmapQuery

GT creates a greater than query.

func (*RangeField) GTE added in v0.7.0

func (field *RangeField) GTE(n int) *PQLBitmapQuery

GTE creates a greater than or equal query.

func (*RangeField) LT added in v0.7.0

func (field *RangeField) LT(n int) *PQLBitmapQuery

LT creates a less than query.

func (*RangeField) LTE added in v0.7.0

func (field *RangeField) LTE(n int) *PQLBitmapQuery

LTE creates a less than or equal query.

func (*RangeField) Max added in v0.9.0

func (field *RangeField) Max(bitmap *PQLBitmapQuery) *PQLBaseQuery

Max creates a min query.

func (*RangeField) Min added in v0.9.0

func (field *RangeField) Min(bitmap *PQLBitmapQuery) *PQLBaseQuery

Min creates a min query.

func (*RangeField) NotEquals added in v0.9.0

func (field *RangeField) NotEquals(n int) *PQLBitmapQuery

NotEquals creates a not equals query.

func (*RangeField) NotNull added in v0.9.0

func (field *RangeField) NotNull() *PQLBitmapQuery

NotNull creates a not equal to null query.

func (*RangeField) SetIntValue added in v0.7.0

func (field *RangeField) SetIntValue(columnID uint64, value int) *PQLBaseQuery

SetIntValue creates a SetValue query.

func (*RangeField) SetIntValueK added in v0.9.0

func (field *RangeField) SetIntValueK(columnKey string, value int) *PQLBaseQuery

SetIntValueK creates a SetValue query using a string column key. This will only work against a Pilosa Enterprise server.

func (*RangeField) Sum added in v0.7.0

func (field *RangeField) Sum(bitmap *PQLBitmapQuery) *PQLBaseQuery

Sum creates a sum query.

type Record added in v0.9.0

type Record interface {
	Int64Field(index int) int64
	Uint64Field(index int) uint64
	StringField(index int) string
	Less(other Record) bool
}

func FieldValueCSVUnmarshaller added in v0.9.0

func FieldValueCSVUnmarshaller(text string) (Record, error)

type RecordIterator added in v0.9.0

type RecordIterator interface {
	NextRecord() (Record, error)
}

type Schema

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

Schema contains the index properties

func NewSchema added in v0.5.0

func NewSchema() *Schema

NewSchema creates a new Schema

func (*Schema) Index added in v0.5.0

func (s *Schema) Index(name string) (*Index, error)

Index returns an index with a name.

func (*Schema) Indexes

func (s *Schema) Indexes() map[string]*Index

Indexes return a copy of the indexes in this schema

func (*Schema) String added in v0.8.0

func (s *Schema) String() string

type SchemaInfo added in v0.9.0

type SchemaInfo struct {
	Indexes []StatusIndex `json:"indexes"`
}

type Status added in v0.5.0

type Status struct {
	Nodes []StatusNode `json:"nodes"`
	// contains filtered or unexported fields
}

Status contains the status information from a Pilosa server.

type StatusField added in v0.8.0

type StatusField struct {
	Name string
	Type string
	Max  int64
	Min  int64
}

StatusField contains a field in the status.

type StatusFrame added in v0.5.0

type StatusFrame struct {
	Name    string        `json:"name"`
	Options StatusOptions `json:"options"`
}

StatusFrame contains frame information.

type StatusIndex added in v0.5.0

type StatusIndex struct {
	Name    string        `json:"name"`
	Options StatusOptions `json:"options"`
	Frames  []StatusFrame `json:"frames"`
	Slices  []uint64      `json:"slices"`
}

StatusIndex contains index information.

type StatusNode added in v0.5.0

type StatusNode struct {
	Scheme  string        `json:"scheme"`
	Host    string        `json:"host"`
	Port    int           `json:"port"`
	Indexes []StatusIndex `json:"indexes"`
}

StatusNode contains node information.

type StatusOptions added in v0.9.0

type StatusOptions struct {
	CacheType      string        `json:"cacheType"`
	CacheSize      uint          `json:"cacheSize"`
	InverseEnabled bool          `json:"inverseEnabled"`
	RangeEnabled   bool          `json:"rangeEnabled"`
	Fields         []StatusField `json:"fields"`
	TimeQuantum    string        `json:"timeQuantum"`
}

StatusOptions contains options for a frame or an index.

type TimeQuantum

type TimeQuantum string

TimeQuantum type represents valid time quantum values for frames having support for that.

const (
	TimeQuantumNone             TimeQuantum = ""
	TimeQuantumYear             TimeQuantum = "Y"
	TimeQuantumMonth            TimeQuantum = "M"
	TimeQuantumDay              TimeQuantum = "D"
	TimeQuantumHour             TimeQuantum = "H"
	TimeQuantumYearMonth        TimeQuantum = "YM"
	TimeQuantumMonthDay         TimeQuantum = "MD"
	TimeQuantumDayHour          TimeQuantum = "DH"
	TimeQuantumYearMonthDay     TimeQuantum = "YMD"
	TimeQuantumMonthDayHour     TimeQuantum = "MDH"
	TimeQuantumYearMonthDayHour TimeQuantum = "YMDH"
)

TimeQuantum constants

type TopNResult added in v0.9.0

type TopNResult []CountResultItem

func (TopNResult) Bitmap added in v0.9.0

func (TopNResult) Bitmap() BitmapResult

func (TopNResult) Changed added in v0.9.0

func (TopNResult) Changed() bool

func (TopNResult) Count added in v0.9.0

func (TopNResult) Count() int64

func (TopNResult) CountItems added in v0.9.0

func (t TopNResult) CountItems() []CountResultItem

func (TopNResult) Type added in v0.9.0

func (TopNResult) Type() uint32

func (TopNResult) Value added in v0.9.0

func (TopNResult) Value() int64

type URI

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

URI represents a Pilosa URI. A Pilosa URI consists of three parts: 1) Scheme: Protocol of the URI. Default: http. 2) Host: Hostname or IP URI. Default: localhost. IPv6 addresses should be written in brackets, e.g., `[fd42:4201:f86b:7e09:216:3eff:fefa:ed80]`. 3) Port: Port of the URI. Default: 10101.

All parts of the URI are optional. The following are equivalent:

http://localhost:10101
http://localhost
http://:10101
localhost:10101
localhost
:10101

func DefaultURI

func DefaultURI() *URI

DefaultURI creates and returns the default URI.

func NewURIFromAddress

func NewURIFromAddress(address string) (*URI, error)

NewURIFromAddress parses the passed address and returns a URI.

func NewURIFromHostPort

func NewURIFromHostPort(host string, port uint16) (*URI, error)

NewURIFromHostPort returns a URI with specified host and port.

func URIFromAddress added in v0.8.0

func URIFromAddress(host string) *URI

URIFromAddress creates a URI from the given address.

func (URI) Equals

func (u URI) Equals(other *URI) bool

Equals returns true if the checked URI is equivalent to this URI.

func (*URI) Error added in v0.8.0

func (u *URI) Error() error

Error returns the error if this URI has one.

func (*URI) Host

func (u *URI) Host() string

Host returns the host of this URI.

func (*URI) HostPort added in v0.8.0

func (u *URI) HostPort() string

HostPort returns `Host:Port`

func (*URI) Normalize

func (u *URI) Normalize() string

Normalize returns the address in a form usable by a HTTP client.

func (*URI) Port

func (u *URI) Port() uint16

Port returns the port of this URI.

func (*URI) Scheme

func (u *URI) Scheme() string

Scheme returns the scheme of this URI.

func (*URI) SetHost added in v0.8.0

func (u *URI) SetHost(host string) error

SetHost sets the host of this URI.

func (*URI) SetPort added in v0.8.0

func (u *URI) SetPort(port uint16)

SetPort sets the port of this URI.

func (*URI) SetScheme added in v0.8.0

func (u *URI) SetScheme(scheme string) error

SetScheme sets the scheme of this URI.

func (*URI) Valid added in v0.8.0

func (u *URI) Valid() bool

Valid returns true if this is a valid URI.

type ValCountResult added in v0.9.0

type ValCountResult struct {
	Val int64 `json:"val"`
	Cnt int64 `json:"count"`
}

func (ValCountResult) Bitmap added in v0.9.0

func (ValCountResult) Bitmap() BitmapResult

func (ValCountResult) Changed added in v0.9.0

func (ValCountResult) Changed() bool

func (ValCountResult) Count added in v0.9.0

func (c ValCountResult) Count() int64

func (ValCountResult) CountItems added in v0.9.0

func (ValCountResult) CountItems() []CountResultItem

func (ValCountResult) Type added in v0.9.0

func (ValCountResult) Type() uint32

func (ValCountResult) Value added in v0.9.0

func (c ValCountResult) Value() int64

Directories

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

Jump to

Keyboard shortcuts

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