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
- Variables
- func ValidFrameName(name string) bool
- func ValidIndexName(name string) bool
- func ValidKey(key string) bool
- func ValidLabel(label string) bool
- type Bit
- type BitmapResult
- type BoolResult
- type CSVIterator
- type CSVRecordUnmarshaller
- type CacheType
- type Client
- func (c *Client) CreateFrame(frame *Frame) error
- func (c *Client) CreateIndex(index *Index) error
- func (c *Client) CreateIntField(frame *Frame, name string, min int, max int) error
- func (c *Client) DeleteField(frame *Frame, name string) error
- func (c *Client) DeleteFrame(frame *Frame) error
- func (c *Client) DeleteIndex(index *Index) error
- func (c *Client) EnsureFrame(frame *Frame) error
- func (c *Client) EnsureIndex(index *Index) error
- func (c *Client) ExportFrame(frame *Frame, view string) (RecordIterator, error)
- func (c *Client) HttpRequest(method string, path string, data []byte, headers map[string]string) (*http.Response, []byte, error)
- func (c *Client) ImportFrame(frame *Frame, iterator RecordIterator, options ...ImportOption) error
- func (c *Client) ImportValueFrame(frame *Frame, field string, iterator RecordIterator, options ...ImportOption) error
- func (c *Client) Query(query PQLQuery, options ...interface{}) (*QueryResponse, error)
- func (c *Client) Schema() (*Schema, error)
- func (c *Client) Status() (Status, error)
- func (c *Client) SyncSchema(schema *Schema) error
- func (c *Client) Views(frame *Frame) ([]string, error)
- type ClientOption
- func ConnectTimeout(timeout time.Duration) ClientOption
- func LegacyMode(enable bool) ClientOption
- func OptClientConnectTimeout(timeout time.Duration) ClientOption
- func OptClientPoolSizePerRoute(size int) ClientOption
- func OptClientSocketTimeout(timeout time.Duration) ClientOption
- func OptClientTLSConfig(config *tls.Config) ClientOption
- func OptClientTotalPoolSize(size int) ClientOption
- func PoolSizePerRoute(size int) ClientOption
- func SkipVersionCheck() ClientOption
- func SocketTimeout(timeout time.Duration) ClientOption
- func TLSConfig(config *tls.Config) ClientOption
- func TotalPoolSize(size int) ClientOption
- type ClientOptions
- type Cluster
- type ColumnItem
- type CountResultItem
- type Error
- type FieldValue
- type Frame
- func (f *Frame) Bitmap(rowID uint64) *PQLBitmapQuery
- func (f *Frame) BitmapK(rowKey string) *PQLBitmapQuery
- func (f *Frame) BitmapTopN(n uint64, bitmap *PQLBitmapQuery) *PQLBitmapQuery
- func (f *Frame) ClearBit(rowID uint64, columnID uint64) *PQLBaseQuery
- func (f *Frame) ClearBitK(rowKey string, columnKey string) *PQLBaseQuery
- func (f *Frame) Field(name string) *RangeField
- func (f *Frame) Fields() map[string]*RangeField
- func (f *Frame) FilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery
- func (f *Frame) InverseBitmap(columnID uint64) *PQLBaseQuery
- func (f *Frame) InverseBitmapK(columnKey string) *PQLBaseQuery
- func (f *Frame) InverseBitmapTopN(n uint64, bitmap *PQLBitmapQuery) *PQLBitmapQuery
- func (f *Frame) InverseFilterFieldTopN(n uint64, bitmap *PQLBitmapQuery, field string, values ...interface{}) *PQLBitmapQuery
- func (f *Frame) InverseRange(columnID uint64, start time.Time, end time.Time) *PQLBitmapQuery
- func (f *Frame) InverseRangeK(columnKey string, start time.Time, end time.Time) *PQLBitmapQuery
- func (f *Frame) InverseTopN(n uint64) *PQLBitmapQuery
- func (f *Frame) Name() string
- func (f *Frame) Range(rowID uint64, start time.Time, end time.Time) *PQLBitmapQuery
- func (f *Frame) RangeK(rowKey string, start time.Time, end time.Time) *PQLBitmapQuery
- func (f *Frame) SetBit(rowID uint64, columnID uint64) *PQLBaseQuery
- func (f *Frame) SetBitK(rowKey string, columnKey string) *PQLBaseQuery
- func (f *Frame) SetBitTimestamp(rowID uint64, columnID uint64, timestamp time.Time) *PQLBaseQuery
- func (f *Frame) SetBitTimestampK(rowKey string, columnKey string, timestamp time.Time) *PQLBaseQuery
- func (f *Frame) SetIntFieldValue(columnID uint64, field string, value int) *PQLBaseQuery
- func (f *Frame) SetRowAttrs(rowID uint64, attrs map[string]interface{}) *PQLBaseQuery
- func (f *Frame) SetRowAttrsK(rowKey string, attrs map[string]interface{}) *PQLBaseQuery
- func (f *Frame) String() string
- func (f *Frame) Sum(bitmap *PQLBitmapQuery, field string) *PQLBaseQuery
- func (f *Frame) TopN(n uint64) *PQLBitmapQuery
- type FrameInfo
- type FrameOption
- type FrameOptions
- type ImportOption
- func OptImportBatchSize(batchSize int) ImportOption
- func OptImportStatusChannel(statusChan chan<- ImportStatusUpdate) ImportOption
- func OptImportStrategy(strategy ImportWorkerStrategy) ImportOption
- func OptImportThreadCount(count int) ImportOption
- func OptImportTimeout(timeout time.Duration) ImportOption
- type ImportOptions
- type ImportStatusUpdate
- type ImportWorkerStrategy
- type Index
- func (idx *Index) BatchQuery(queries ...PQLQuery) *PQLBatchQuery
- func (idx *Index) Count(bitmap *PQLBitmapQuery) *PQLBaseQuery
- func (idx *Index) Difference(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery
- func (idx *Index) Frame(name string, options ...interface{}) (*Frame, error)
- func (idx *Index) Frames() map[string]*Frame
- func (idx *Index) Intersect(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery
- func (idx *Index) Name() string
- func (idx *Index) RawQuery(query string) *PQLBaseQuery
- func (idx *Index) SetColumnAttrs(columnID uint64, attrs map[string]interface{}) *PQLBaseQuery
- func (idx *Index) String() string
- func (idx *Index) Union(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery
- func (idx *Index) Xor(bitmaps ...*PQLBitmapQuery) *PQLBitmapQuery
- type IntResult
- type NilResult
- type PQLBaseQuery
- type PQLBatchQuery
- type PQLBitmapQuery
- type PQLQuery
- type QueryOption
- func ColumnAttrs(enable bool) QueryOption
- func ExcludeAttrs(enable bool) QueryOption
- func ExcludeBits(enable bool) QueryOption
- func OptQueryColumnAttrs(enable bool) QueryOption
- func OptQueryExcludeAttrs(enable bool) QueryOption
- func OptQueryExcludeBits(enable bool) QueryOption
- func OptQuerySlices(slices ...uint64) QueryOption
- func Slices(slices ...uint64) QueryOption
- type QueryOptions
- type QueryResponse
- type QueryResult
- type RangeField
- func (field *RangeField) Between(a int, b int) *PQLBitmapQuery
- func (field *RangeField) Equals(n int) *PQLBitmapQuery
- func (field *RangeField) GT(n int) *PQLBitmapQuery
- func (field *RangeField) GTE(n int) *PQLBitmapQuery
- func (field *RangeField) LT(n int) *PQLBitmapQuery
- func (field *RangeField) LTE(n int) *PQLBitmapQuery
- func (field *RangeField) Max(bitmap *PQLBitmapQuery) *PQLBaseQuery
- func (field *RangeField) Min(bitmap *PQLBitmapQuery) *PQLBaseQuery
- func (field *RangeField) NotEquals(n int) *PQLBitmapQuery
- func (field *RangeField) NotNull() *PQLBitmapQuery
- func (field *RangeField) SetIntValue(columnID uint64, value int) *PQLBaseQuery
- func (field *RangeField) SetIntValueK(columnKey string, value int) *PQLBaseQuery
- func (field *RangeField) Sum(bitmap *PQLBitmapQuery) *PQLBaseQuery
- type Record
- type RecordIterator
- type Schema
- type SchemaInfo
- type Status
- type StatusField
- type StatusFrame
- type StatusIndex
- type StatusNode
- type StatusOptions
- type TimeQuantum
- type TopNResult
- type URI
- func (u URI) Equals(other *URI) bool
- func (u *URI) Error() error
- func (u *URI) Host() string
- func (u *URI) HostPort() string
- func (u *URI) Normalize() string
- func (u *URI) Port() uint16
- func (u *URI) Scheme() string
- func (u *URI) SetHost(host string) error
- func (u *URI) SetPort(port uint16)
- func (u *URI) SetScheme(scheme string) error
- func (u *URI) Valid() bool
- type ValCountResult
Constants ¶
const ( QueryResultTypeNil uint32 = iota QueryResultTypeBitmap QueryResultTypePairs QueryResultTypeValCount QueryResultTypeUint64 QueryResultTypeBool )
QueryResponse types.
const Version = "v0.8.0-16-g46c8a62"
Variables ¶
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.
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 ¶
ValidFrameName returns true if the given frame name is valid, otherwise false.
func ValidIndexName ¶
ValidIndexName returns true if the given index name is valid, otherwise false.
func ValidLabel ¶
ValidLabel returns true if the given label is valid, otherwise false.
Types ¶
type Bit ¶ added in v0.5.0
Bit defines a single Pilosa bit.
func (Bit) Int64Field ¶ added in v0.9.0
func (Bit) StringField ¶ added in v0.9.0
func (Bit) Uint64Field ¶ added in v0.9.0
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
func BitCSVUnmarshaller ¶ added in v0.9.0
func BitCSVUnmarshaller() CSVRecordUnmarshaller
func BitCSVUnmarshallerWithTimestamp ¶ added in v0.9.0
func BitCSVUnmarshallerWithTimestamp(timestampFormat string) CSVRecordUnmarshaller
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 ¶
CreateFrame creates a frame on the server using the given Frame struct.
func (*Client) CreateIndex ¶
CreateIndex creates an index on the server using the given Index struct.
func (*Client) CreateIntField ¶ added in v0.7.0
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
DeleteField delete a range field. *Experimental*: This feature may be removed or its interface may be modified in the future.
func (*Client) DeleteFrame ¶
DeleteFrame deletes a frame on the server.
func (*Client) DeleteIndex ¶
DeleteIndex deletes an index on the server.
func (*Client) EnsureFrame ¶
EnsureFrame creates a frame on the server if it doesn't exists.
func (*Client) EnsureIndex ¶
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) SyncSchema ¶ added in v0.5.0
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.
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 NewClusterWithHost ¶
NewClusterWithHost returns a cluster with the given URIs.
func (*Cluster) RemoveHost ¶
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 FieldValue ¶ added in v0.7.0
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
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
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) Range ¶
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
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 ¶
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) 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 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 (*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) 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) 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) 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) CountItems ¶ added in v0.9.0
func (IntResult) CountItems() []CountResultItem
type NilResult ¶ added in v0.9.0
type NilResult struct{}
func (NilResult) Bitmap ¶ added in v0.9.0
func (NilResult) Bitmap() BitmapResult
func (NilResult) CountItems ¶ added in v0.9.0
func (NilResult) CountItems() []CountResultItem
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 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
type RecordIterator ¶ added in v0.9.0
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema contains the index properties
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
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 NewURIFromAddress ¶
NewURIFromAddress parses the passed address and returns a URI.
func NewURIFromHostPort ¶
NewURIFromHostPort returns a URI with specified host and port.
func URIFromAddress ¶ added in v0.8.0
URIFromAddress creates a URI from the given address.
type ValCountResult ¶ added in v0.9.0
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
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package internal is a generated protocol buffer package.
|
Package internal is a generated protocol buffer package. |