client

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 34 Imported by: 0

README

Go Client for Pilosa

Go client for Pilosa high performance distributed index.

Usage

If you have the pilosa repo in your GOPATH, you can import the library in your code using:

import "github.com/pilosa/pilosa/v2/client"
Quick overview

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

package main

import (
	"fmt"

	"github.com/pilosa/pilosa/v2/client"
)

func main() {
	// Create the default client
	cli := client.DefaultClient()

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

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

	// Create a Field object
	myfield := myindex.Field("myfield")

	// make sure the index and the field exists on the server
	err := cli.SyncSchema(schema)

	// Send a Set query. If err is non-nil, response will be nil.
	response, err := cli.Query(myfield.Set(5, 42))

	// Send a Row query. If err is non-nil, response will be nil.
	response, err = cli.Query(myfield.Row(5))

	// Get the result
	result := response.Result()
	// Act on the result
	if result != nil {
		columns := result.Row().Columns
		fmt.Println("Got columns: ", columns)
	}

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

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

Documentation

Data Model and Queries

See: Data Model and Queries

Executing Queries

See: Server Interaction

Other Documentation

Documentation

Overview

Copyright 2021 Molecula Corp. All rights reserved. package ctl contains all pilosa subcommands other than 'server'. These are generally administration, testing, and debugging tools.

Package client enables querying a Pilosa server.

This client uses Pilosa's http+protobuf API.

Usage:

import (
	"fmt"
	"github.com/featurebasedb/featurebase/v3/client"
)

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

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

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

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

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

// Execute a query
response, err := cli.Query(stargazer.Row(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/.

Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0

Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	QueryResultTypeNil uint32 = iota
	QueryResultTypeRow
	QueryResultTypePairs
	QueryResultTypePairsField
	QueryResultTypeValCount
	QueryResultTypeUint64
	QueryResultTypeBool
	QueryResultTypeRowIDs // this is not used by the client
	QueryResultTypeGroupCounts
	QueryResultTypeRowIdentifiers
	QueryResultTypePair
	QueryResultTypePairField
	QueryResultTypeSignedRow
)

QueryResponse types.

View Source
const CacheSizeDefault = 0

CacheSizeDefault is the default cache size

View Source
const DefaultShardWidth = pilosa.ShardWidth

DefaultShardWidth is used if an index doesn't have it defined.

View Source
const PQLVersion = "1.0"

PQLVersion is the version of PQL expected by the client

View Source
const Version = "v1.3.0"

Version is the client version.

Variables

View Source
var (
	ErrEmptyCluster                = errors.New("No usable addresses in the cluster")
	ErrIndexExists                 = errors.New("Index exists")
	ErrFieldExists                 = errors.New("Field exists")
	ErrInvalidIndexName            = errors.New("Invalid index name")
	ErrInvalidFieldName            = errors.New("Invalid field name")
	ErrInvalidLabel                = errors.New("Invalid label")
	ErrInvalidKey                  = errors.New("Invalid key")
	ErrHTTPRequest                 = errors.New("Failed all HTTP retries")
	ErrAddrURIClusterExpected      = errors.New("Addresses, URIs or a cluster is expected")
	ErrInvalidQueryOption          = errors.New("Invalid query option")
	ErrInvalidIndexOption          = errors.New("Invalid index option")
	ErrInvalidFieldOption          = errors.New("Invalid field option")
	ErrNoFragmentNodes             = errors.New("No fragment nodes")
	ErrNoShard                     = errors.New("Index has no shards")
	ErrUnknownType                 = errors.New("Unknown type")
	ErrSingleServerAddressRequired = errors.New("OptClientManualServerAddress requires a single URI or address")
	ErrPreconditionFailed          = errors.New("Precondition failed")
)

Predefined Pilosa errors.

View Source
var (
	DefaultEpoch = time.Unix(0, 0).UTC() // 1970-01-01T00:00:00Z

	MinTimestamp = time.Unix(-1<<32, 0).UTC() // 1833-11-24T17:31:44Z
	MaxTimestamp = time.Unix(1<<32, 0).UTC()  // 2106-02-07T06:28:16Z
)

Timestamp field range.

Functions

func FromClientFields

func FromClientFields(cf []*Field) []*featurebase.FieldInfo

FromClientFields converts a slice of client Fields to a slice of featurebase FieldInfo.

func FromClientIndex

func FromClientIndex(ci *Index) *featurebase.IndexInfo

FromClientIndex converts a client Index to a featurebase IndexInfo.

func NewImporter

func NewImporter(c *Client, sapi featurebase.SchemaAPI) *importer

func NewQueryAPI

func NewQueryAPI(c *Client) *queryAPI

func NewSchemaAPI

func NewSchemaAPI(c *Client) *schemaAPI

func TimeUnitNanos

func TimeUnitNanos(unit string) int64

TimeUnitNanos returns the number of nanoseconds in unit.

func ValidKey

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 BoolResult

type BoolResult bool

BoolResult is returned from Set and Clear calls.

func (BoolResult) Changed

func (b BoolResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (BoolResult) Count

func (BoolResult) Count() int64

Count returns the result of a Count call.

func (BoolResult) CountItem

func (BoolResult) CountItem() CountResultItem

CountItem returns a CountResultItem

func (BoolResult) CountItems

func (BoolResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (BoolResult) GroupCounts

func (BoolResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (BoolResult) Row

func (BoolResult) Row() RowResult

Row returns a RowResult.

func (BoolResult) RowIdentifiers

func (BoolResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (BoolResult) Type

func (BoolResult) Type() uint32

Type is the type of this result.

func (BoolResult) Value

func (BoolResult) Value() int64

Value returns the result of a Min, Max or Sum call.

type CacheType

type CacheType string

CacheType represents cache type for a field

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

CacheType constants

type Client

type Client struct {
	AuthToken string
	// 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

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

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

func (*Client) ApplyDataframeChangeset

func (c *Client) ApplyDataframeChangeset(indexName string, cr *pilosa.ChangesetRequest, shard uint64) (map[string]interface{}, error)

ApplyDataframeChangeset will create or append the existing dataframe if creating, the provided schema will be used if appending, the provided schema will be used to validate against Only one shard can be written to at a time so slight care must be taken Server side locking will prevent writting conflict

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateField

func (c *Client) CreateField(field *Field) error

CreateField creates a field on the server using the given Field struct.

func (*Client) CreateFieldKeys

func (c *Client) CreateFieldKeys(field *Field, keys ...string) (map[string]uint64, error)

CreateFieldKeys looks up the IDs associated with specified keys in a field. If a key does not exist, it will be created.

func (*Client) CreateIndex

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

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

func (*Client) CreateIndexKeys

func (c *Client) CreateIndexKeys(idx *Index, keys ...string) (map[string]uint64, error)

CreateIndexKeys looks up the IDs associated with specified column keys in an index. If a key does not exist, it will be created.

func (*Client) DeleteField

func (c *Client) DeleteField(field *Field) error

DeleteField deletes a field on the server.

func (*Client) DeleteIndex

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

DeleteIndex deletes an index on the server.

func (*Client) DeleteIndexByName

func (c *Client) DeleteIndexByName(index string) error

DeleteIndexByName deletes the named index on the server.

func (*Client) DoImport

func (c *Client) DoImport(index string, shard uint64, path string, data []byte) error

DoImport takes a path and data payload (normally from EncodeImport or EncodeImportValues), logs the import, finds all nodes which own this shard, and concurrently imports to those nodes.

func (*Client) DoImportValues

func (c *Client) DoImportValues(index string, shard uint64, path string, data []byte) error

DoImportValues is deprecated. Use DoImport.

func (*Client) EncodeImport

func (c *Client) EncodeImport(field *Field, shard uint64, vals, ids []uint64, clear bool) (path string, data []byte, err error)

EncodeImport computes the HTTP path and payload for an import request. It is typically followed by a call to DoImport.

func (*Client) EncodeImportValues

func (c *Client) EncodeImportValues(field *Field, shard uint64, vals []int64, ids []uint64, clear bool) (path string, data []byte, err error)

EncodeImportValues computes the HTTP path and payload for an import-values request. It is typically followed by a call to DoImportValues.

func (*Client) EnsureField

func (c *Client) EnsureField(field *Field) error

EnsureField creates a field 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) ExportField

func (c *Client) ExportField(field *Field) (io.Reader, error)

ExportField exports columns for a field.

func (*Client) FindFieldKeys

func (c *Client) FindFieldKeys(field *Field, keys ...string) (map[string]uint64, error)

FindFieldKeys looks up the IDs associated with specified keys in a field. If a key does not exist, the result will not include it.

func (*Client) FindIndexKeys

func (c *Client) FindIndexKeys(idx *Index, keys ...string) (map[string]uint64, error)

FindIndexKeys looks up the IDs associated with specified column keys in an index. If a key does not exist, the result will not include it.

func (*Client) FinishTransaction

func (c *Client) FinishTransaction(id string) (*pilosa.Transaction, error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(id string) (*pilosa.Transaction, error)

func (*Client) HTTPRequest

func (c *Client) HTTPRequest(method string, path string, data []byte, headers map[string]string) (status int, body []byte, err error)

HTTPRequest sends an HTTP request to the Pilosa server (used by idk)

func (*Client) Import

func (c *Client) Import(field *Field, shard uint64, vals, ids []uint64, clear bool) error

Import imports data for a single shard using the regular import endpoint rather than import-roaring. This is good for e.g. mutex or bool fields where import-roaring is not supported.

func (*Client) ImportRoaringBitmap

func (c *Client) ImportRoaringBitmap(field *Field, shard uint64, views map[string]*roaring.Bitmap, clear bool) error

ImportRoaringBitmap can import pre-made bitmaps for a number of different views into the given field/shard. If the view name in the map is an empty string, the standard view will be used.

func (*Client) ImportRoaringShard

func (c *Client) ImportRoaringShard(index string, shard uint64, request *pilosa.ImportRoaringShardRequest) error

ImportRoaringShard imports into the shard-transactional endpoint.

func (*Client) ImportValues

func (c *Client) ImportValues(field *Field, shard uint64, vals []int64, ids []uint64, clear bool) error

ImportValues takes the given integer values and column ids (which must all be in the given shard) and imports them into the given index,field,shard on all nodes which should hold that shard. It assumes that the ids have been translated from keys if necessary and so tells Pilosa to ignore checking if the index uses column keys. ImportValues wraps EncodeImportValues and DoImportValues — these are broken out and exported so that performance conscious users can re-use the same vals and ids byte buffers for local encoding, while performing the imports concurrently.

func (*Client) Info

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

Info returns the server's configuration/host information.

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 fields on the server.

func (*Client) SetAuthToken

func (c *Client) SetAuthToken(token string)

SetAuthToken sets the Client.AuthToken value. We needed this to be a method in order to satisfy the SchemaManager interface.

func (*Client) StartTransaction

func (c *Client) StartTransaction(id string, timeout time.Duration, exclusive bool, requestTimeout time.Duration) (*pilosa.Transaction, error)

StartTransaction tries to start a new transaction in Pilosa. It will continue trying until at least requestTimeout time has passed. If it fails due to an exclusive transaction already existing, it will return that transaction along with a non-nil error.

func (*Client) Status

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

Status returns the server's status.

func (*Client) SyncIndex

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

func (*Client) SyncSchema

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

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

func (*Client) Transactions

func (c *Client) Transactions() (map[string]*pilosa.Transaction, error)

type ClientOption

type ClientOption func(options *ClientOptions) error

ClientOption is used when creating a PilosaClient struct.

func OptClientConnectTimeout

func OptClientConnectTimeout(timeout time.Duration) ClientOption

OptClientConnectTimeout is the maximum time to connect in nanoseconds.

func OptClientManualServerAddress

func OptClientManualServerAddress(enabled bool) ClientOption

OptClientManualServerAddress forces the client use only the manual server address

func OptClientNAT

func OptClientNAT(nat map[string]string) ClientOption

OptClientNAT sets a NAT map used to translate the advertised URI to something else (for example, when accessing pilosa running in docker).

func OptClientPathPrefix

func OptClientPathPrefix(prefix string) ClientOption

OptClientPathPrefix sets the http path prefix.

func OptClientPoolSizePerRoute

func OptClientPoolSizePerRoute(size int) ClientOption

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

func OptClientRetries

func OptClientRetries(retries int) ClientOption

OptClientRetries sets the number of retries on HTTP request failures.

func OptClientSocketTimeout

func OptClientSocketTimeout(timeout time.Duration) ClientOption

OptClientSocketTimeout is the maximum idle socket time in nanoseconds

func OptClientTLSConfig

func OptClientTLSConfig(config *tls.Config) ClientOption

OptClientTLSConfig contains the TLS configuration.

func OptClientTotalPoolSize

func OptClientTotalPoolSize(size int) ClientOption

OptClientTotalPoolSize is the maximum number of connections in the pool.

func OptClientTracer

func OptClientTracer(tracer opentracing.Tracer) ClientOption

OptClientTracer sets the Open Tracing tracer See: https://opentracing.io

type ClientOptions

type ClientOptions struct {
	SocketTimeout    time.Duration
	ConnectTimeout   time.Duration
	PoolSizePerRoute int
	TotalPoolSize    int
	TLSConfig        *tls.Config
	// contains filtered or unexported fields
}

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 ...*pnet.URI) *Cluster

NewClusterWithHost returns a cluster with the given URIs.

func (*Cluster) AddHost

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

AddHost adds a host to the cluster.

func (*Cluster) Host

func (c *Cluster) Host() *pnet.URI

Host returns a host in the cluster.

func (*Cluster) Hosts

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

Hosts returns all available hosts in the cluster.

type Column

type Column struct {
	RowID     uint64
	ColumnID  uint64
	RowKey    string
	ColumnKey string
	Timestamp int64
}

Column defines a single Pilosa column.

func (Column) Less

func (b Column) Less(other Record) bool

Less returns true if this column sorts before the given Record.

func (Column) Shard

func (b Column) Shard(shardWidth uint64) uint64

Shard returns the shard for this column.

type CountItem

type CountItem struct {
	CountResultItem
}

func (CountItem) Changed

func (CountItem) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (CountItem) Count

func (CountItem) Count() int64

Count returns the result of a Count call.

func (CountItem) CountItem

func (t CountItem) CountItem() CountResultItem

CountItem returns a CountResultItem

func (CountItem) CountItems

func (t CountItem) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (CountItem) GroupCounts

func (CountItem) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (CountItem) Row

func (CountItem) Row() RowResult

Row returns a RowResult.

func (CountItem) RowIdentifiers

func (CountItem) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (CountItem) Type

func (CountItem) Type() uint32

Type is the type of this result.

func (CountItem) Value

func (CountItem) Value() int64

Value returns the result of a Min, Max or Sum call.

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

func (c *CountResultItem) String() string

type Field

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

Field structs are used to segment and define different functional characteristics within your entire index. You can think of a Field as a table-like data partition within your Index.

func TableFieldToClientField

func TableFieldToClientField(qtbl *dax.QualifiedTable, fname dax.FieldName) (*Field, error)

TableFieldToClientField

func ToClientField

func ToClientField(index string, ff *featurebase.FieldInfo) (*Field, error)

ToClientField

func (*Field) Between

func (f *Field) Between(a IntOrFloat, b IntOrFloat) *PQLRowQuery

Between creates a between query.

func (*Field) Clear

func (f *Field) Clear(rowIDOrKey, colIDOrKey interface{}) *PQLBaseQuery

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

func (*Field) ClearRow

func (f *Field) ClearRow(rowIDOrKey interface{}) *PQLBaseQuery

ClearRow creates a ClearRow query. ClearRow sets all bits to 0 in a given row of the binary matrix, thus disassociating the given row in the given field from all columns.

func (*Field) CreatedAt

func (f *Field) CreatedAt() int64

func (*Field) Distinct

func (f *Field) Distinct() *PQLRowQuery

Distinct creates a Distinct query.

func (*Field) Equals

func (f *Field) Equals(n IntOrFloat) *PQLRowQuery

Equals creates an equals query.

func (*Field) GT

func (f *Field) GT(n IntOrFloat) *PQLRowQuery

GT creates a greater than query.

func (*Field) GTE

func (f *Field) GTE(n IntOrFloat) *PQLRowQuery

GTE creates a greater than or equal query.

func (*Field) LT

func (f *Field) LT(n IntOrFloat) *PQLRowQuery

LT creates a less than query.

func (*Field) LTE

func (f *Field) LTE(n IntOrFloat) *PQLRowQuery

LTE creates a less than or equal query.

func (*Field) Like

func (f *Field) Like(pattern string) *PQLRowsQuery

Like creates a Rows query filtered by a pattern. An underscore ('_') can be used as a placeholder for a single UTF-8 codepoint or a percent sign ('%') can be used as a placeholder for 0 or more codepoints. All other codepoints in the pattern are matched exactly.

func (*Field) Max

func (f *Field) Max(row *PQLRowQuery) *PQLBaseQuery

Max creates a max query.

func (*Field) MaxRow

func (f *Field) MaxRow() *PQLBaseQuery

MaxRow creates a max row query.

func (*Field) Min

func (f *Field) Min(row *PQLRowQuery) *PQLBaseQuery

Min creates a min query.

func (*Field) MinRow

func (f *Field) MinRow() *PQLBaseQuery

MinRow creates a min row query.

func (*Field) Name

func (f *Field) Name() string

Name returns the name of the field

func (*Field) NotEquals

func (f *Field) NotEquals(n IntOrFloat) *PQLRowQuery

NotEquals creates a not equals query.

func (*Field) NotNull

func (f *Field) NotNull() *PQLRowQuery

NotNull creates a not equal to null query.

func (*Field) Options

func (f *Field) Options() *FieldOptions

Options returns the options set for the field. Which fields of the FieldOptions struct are actually being used depends on the field's type. *DEPRECATED*

func (*Field) Opts

func (f *Field) Opts() FieldOptions

Opts returns the options of the field

func (*Field) Range

func (f *Field) Range(rowIDOrKey interface{}, start time.Time, end time.Time) *PQLRowQuery

Range creates a Range query. Similar to Row, but only returns columns which were set with timestamps between the given start and end timestamps. *Deprecated at Pilosa 1.3*

func (*Field) Row

func (f *Field) Row(rowIDOrKey interface{}) *PQLRowQuery

Row creates a Row query. Row retrieves the indices of all the set columns in a row.

func (*Field) RowDistinct

func (f *Field) RowDistinct(row *PQLRowQuery) *PQLRowQuery

RowDistinct creates a Distinct query with the given row filter.

func (*Field) RowRange

func (f *Field) RowRange(rowIDOrKey interface{}, start time.Time, end time.Time) *PQLRowQuery

RowRange creates a Row query with timestamps. Similar to Row, but only returns columns which were set with timestamps between the given start and end timestamps. *Introduced at Pilosa 1.3*

func (*Field) RowTopN

func (f *Field) RowTopN(n uint64, row *PQLRowQuery) *PQLRowQuery

RowTopN creates a TopN query with the given item count and row. This variant supports customizing the row query.

func (*Field) Rows

func (f *Field) Rows() *PQLRowsQuery

Rows creates a Rows query with defaults

func (*Field) RowsColumn

func (f *Field) RowsColumn(columnIDOrKey interface{}) *PQLRowsQuery

RowsColumn creates a Rows query with the given column ID/key

func (*Field) RowsLimit

func (f *Field) RowsLimit(limit int64) *PQLRowsQuery

RowsLimit creates a Rows query with the given limit

func (*Field) RowsLimitColumn

func (f *Field) RowsLimitColumn(limit int64, columnIDOrKey interface{}) *PQLRowsQuery

RowsLimitColumn creates a Row query with the given limit and column ID/key

func (*Field) RowsPrevious

func (f *Field) RowsPrevious(rowIDOrKey interface{}) *PQLRowsQuery

RowsPrevious creates a Rows query with the given previous row ID/key

func (*Field) RowsPreviousColumn

func (f *Field) RowsPreviousColumn(rowIDOrKey interface{}, columnIDOrKey interface{}) *PQLRowsQuery

RowsPreviousColumn creates a Rows query with the given previous row ID/key and column ID/key

func (*Field) RowsPreviousLimit

func (f *Field) RowsPreviousLimit(rowIDOrKey interface{}, limit int64) *PQLRowsQuery

RowsPreviousLimit creates a Rows query with the given previous row ID/key and limit

func (*Field) RowsPreviousLimitColumn

func (f *Field) RowsPreviousLimitColumn(rowIDOrKey interface{}, limit int64, columnIDOrKey interface{}) *PQLRowsQuery

RowsPreviousLimitColumn creates a Row query with the given previous row ID/key, limit and column ID/key

func (*Field) Set

func (f *Field) Set(rowIDOrKey, colIDOrKey interface{}) *PQLBaseQuery

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

func (*Field) SetIntValue

func (f *Field) SetIntValue(colIDOrKey interface{}, value int) *PQLBaseQuery

SetIntValue creates a Set query.

func (*Field) SetTimestamp

func (f *Field) SetTimestamp(rowIDOrKey, colIDOrKey interface{}, timestamp time.Time) *PQLBaseQuery

SetTimestamp creates a Set query with timestamp. Set, assigns a value of 1 to a column in the binary matrix, thus associating the given row in the given field with the given column.

func (*Field) Store

func (f *Field) Store(row *PQLRowQuery, rowIDOrKey interface{}) *PQLBaseQuery

Store creates a Store call. Store writes the result of the row query to the specified row. If the row already exists, it will be replaced. The destination field must be of field type set.

func (*Field) String

func (f *Field) String() string

func (*Field) Sum

func (f *Field) Sum(row *PQLRowQuery) *PQLBaseQuery

Sum creates a sum query.

func (*Field) TopN

func (f *Field) TopN(n uint64) *PQLRowQuery

TopN creates a TopN query with the given item count. Returns the id and count of the top n rows (by count of columns) in the field.

type FieldInfo

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

FieldInfo represents schema information for a field.

type FieldOption

type FieldOption func(options *FieldOptions)

FieldOption is used to pass an option to index.Field function.

func OptFieldForeignIndex

func OptFieldForeignIndex(index string) FieldOption

func OptFieldKeys

func OptFieldKeys(keys bool) FieldOption

OptFieldKeys sets whether field uses string keys.

func OptFieldTTL

func OptFieldTTL(dur time.Duration) FieldOption

func OptFieldTypeBool

func OptFieldTypeBool() FieldOption

OptFieldTypeBool adds a bool field.

func OptFieldTypeDecimal

func OptFieldTypeDecimal(scale int64, minmax ...pql.Decimal) FieldOption

func OptFieldTypeInt

func OptFieldTypeInt(limits ...int64) FieldOption

OptFieldTypeInt adds an integer field. No arguments: min = min_int, max = max_int 1 argument: min = limit[0], max = max_int 2 or more arguments: min = limit[0], max = limit[1]

func OptFieldTypeMutex

func OptFieldTypeMutex(cacheType CacheType, cacheSize int) FieldOption

OptFieldTypeMutex adds a mutex field.

func OptFieldTypeSet

func OptFieldTypeSet(cacheType CacheType, cacheSize int) FieldOption

OptFieldTypeSet adds a set field. Specify CacheTypeDefault for the default cache type. Specify CacheSizeDefault for the default cache size.

func OptFieldTypeTime

func OptFieldTypeTime(quantum types.TimeQuantum, opts ...bool) FieldOption

OptFieldTypeTime adds a time field.

func OptFieldTypeTimestamp

func OptFieldTypeTimestamp(epoch time.Time, timeUnit string) FieldOption

type FieldOptions

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

FieldOptions contains options to customize Field objects and field queries.

func (FieldOptions) Base

func (fo FieldOptions) Base() int64

Base returns the base of the field.

func (FieldOptions) CacheSize

func (fo FieldOptions) CacheSize() int

CacheSize returns the cache size for a set field. Zero otherwise.

func (FieldOptions) CacheType

func (fo FieldOptions) CacheType() CacheType

CacheType returns the configured cache type for a "set" field. Empty string otherwise.

func (FieldOptions) ForeignIndex

func (fo FieldOptions) ForeignIndex() string

func (FieldOptions) Keys

func (fo FieldOptions) Keys() bool

Keys returns whether this field uses keys instead of IDs

func (FieldOptions) Max

func (fo FieldOptions) Max() pql.Decimal

Max returns the maximum accepted value for an integer field. Zero otherwise.

func (FieldOptions) MaxTimestamp

func (o FieldOptions) MaxTimestamp() time.Time

MaxTimestamp returns the maxnimum value for a timestamp field.

func (FieldOptions) Min

func (fo FieldOptions) Min() pql.Decimal

Min returns the minimum accepted value for an integer field. Zero otherwise.

func (FieldOptions) MinTimestamp

func (o FieldOptions) MinTimestamp() time.Time

MinTimestamp returns the minimum value for a timestamp field.

func (FieldOptions) NoStandardView

func (fo FieldOptions) NoStandardView() bool

NoStandardView suppresses creating the standard view for supported field types (currently, time)

func (FieldOptions) Scale

func (fo FieldOptions) Scale() int64

Scale returns the scale for a decimal field.

func (FieldOptions) String

func (fo FieldOptions) String() string

func (FieldOptions) TTL

func (fo FieldOptions) TTL() time.Duration

TTL returns the configured ttl for a time field.

func (FieldOptions) TimeQuantum

func (fo FieldOptions) TimeQuantum() types.TimeQuantum

TimeQuantum returns the configured time quantum for a time field. Empty string otherwise.

func (FieldOptions) TimeUnit

func (fo FieldOptions) TimeUnit() string

func (FieldOptions) Type

func (fo FieldOptions) Type() FieldType

Type returns the type of the field. Currently "set", "int", or "time".

type FieldRow

type FieldRow struct {
	FieldName string `json:"field"`
	RowID     uint64 `json:"rowID"`
	RowKey    string `json:"rowKey"`
	Value     *int64 `json:"value,omitempty"`
}

FieldRow represents a Group in a GroupBy call result.

type FieldType

type FieldType string

FieldType is the type of a field. See: https://www.pilosa.com/docs/latest/data-model/#field-type

const (
	// FieldTypeDefault is the default field type.
	FieldTypeDefault FieldType = ""
	// FieldTypeSet is the set field type.
	// See: https://www.pilosa.com/docs/latest/data-model/#set
	FieldTypeSet FieldType = "set"
	// FieldTypeInt is the int field type.
	// See: https://www.pilosa.com/docs/latest/data-model/#int
	FieldTypeInt FieldType = "int"
	// FieldTypeTime is the time field type.
	// See: https://www.pilosa.com/docs/latest/data-model/#time
	FieldTypeTime FieldType = "time"
	// FieldTypeMutex is the mutex field type.
	// See: https://www.pilosa.com/docs/latest/data-model/#mutex
	FieldTypeMutex FieldType = "mutex"
	// FieldTypeBool is the boolean field type.
	// See: https://www.pilosa.com/docs/latest/data-model/#boolean
	FieldTypeBool FieldType = "bool"
	// FieldTypeDecimal can store floating point numbers as integers
	// with a scale factor. This field type is only available in
	// Molecula's Pilosa with enterprise extensions.
	FieldTypeDecimal   FieldType = "decimal"
	FieldTypeTimestamp FieldType = "timestamp"
)

type FieldValue

type FieldValue struct {
	ColumnID  uint64
	ColumnKey string
	Value     int64
}

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

func (FieldValue) Less

func (v FieldValue) Less(other Record) bool

Less returns true if this field value sorts before the given Record.

func (FieldValue) Shard

func (v FieldValue) Shard(shardWidth uint64) uint64

Shard returns the shard for this field value.

type GroupByBuilderOption

type GroupByBuilderOption func(g *groupByBuilder) error

GroupByBuilderOption is a functional option type for index.GroupBy

func OptGroupByBuilderAggregate

func OptGroupByBuilderAggregate(agg *PQLBaseQuery) GroupByBuilderOption

OptGroupByBuilderAggregate is a functional option on groupByBuilder used to set the aggregate.

func OptGroupByBuilderFilter

func OptGroupByBuilderFilter(q *PQLRowQuery) GroupByBuilderOption

OptGroupByBuilderFilter is a functional option on groupByBuilder used to set the filter.

func OptGroupByBuilderHaving

func OptGroupByBuilderHaving(having *PQLBaseQuery) GroupByBuilderOption

OptGroupByBuilderHaving is a functional option on groupByBuilder used to set the having clause.

func OptGroupByBuilderLimit

func OptGroupByBuilderLimit(l int64) GroupByBuilderOption

OptGroupByBuilderLimit is a functional option on groupByBuilder used to set the limit.

func OptGroupByBuilderRows

func OptGroupByBuilderRows(rows ...*PQLRowsQuery) GroupByBuilderOption

OptGroupByBuilderRows is a functional option on groupByBuilder used to set the rows.

type GroupCount

type GroupCount struct {
	Groups []FieldRow `json:"groups"`
	Count  int64      `json:"count"`
	Agg    int64      `json:"agg"`
}

GroupCount contains groups and their count in a GroupBy call result.

type GroupCountResult

type GroupCountResult []GroupCount

GroupCountResult is returned from GroupBy call.

func (GroupCountResult) Changed

func (GroupCountResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (GroupCountResult) Count

func (GroupCountResult) Count() int64

Count returns the result of a Count call.

func (GroupCountResult) CountItem

func (GroupCountResult) CountItem() CountResultItem

CountItem returns a CountResultItem

func (GroupCountResult) CountItems

func (GroupCountResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (GroupCountResult) GroupCounts

func (r GroupCountResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (GroupCountResult) Row

Row returns a RowResult.

func (GroupCountResult) RowIdentifiers

func (GroupCountResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (GroupCountResult) Type

func (GroupCountResult) Type() uint32

Type is the type of this result.

func (GroupCountResult) Value

func (GroupCountResult) Value() int64

Value returns the result of a Min, Max or Sum call.

type ImportOption

type ImportOption func(options *ImportOptions) error

ImportOption is used when running imports.

func OptImportBatchSize

func OptImportBatchSize(batchSize int) ImportOption

OptImportBatchSize is the number of records read before importing them.

func OptImportClear

func OptImportClear(clear bool) ImportOption

OptImportClear sets clear import, which clears bits instead of setting them.

func OptImportRoaring

func OptImportRoaring(enable bool) ImportOption

OptImportRoaring enables importing using roaring bitmaps which is more performant.

func OptImportSort

func OptImportSort(sorting bool) ImportOption

OptImportSort tells the importer whether or not to sort batches of records, on by default. Sorting imposes some performance cost, especially on data that's already sorted, but dramatically improves performance in pathological cases. It is enabled by default because the pathological cases are awful, and the performance hit is comparatively small, but the performance cost can be significant if you know your data is sorted.

func OptImportThreadCount

func OptImportThreadCount(count int) ImportOption

OptImportThreadCount is the number of goroutines allocated for import.

type ImportOptions

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

ImportOptions are the options for controlling the importer

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.

func NewIndex

func NewIndex(name string) *Index

NewIndex creates an index with a name.

func QTableToClientIndex

func QTableToClientIndex(qtbl *dax.QualifiedTable) *Index

QTableToClientIndex

func TableToClientIndex

func TableToClientIndex(tbl *dax.Table) *Index

TableToClientIndex

func ToClientIndex

func ToClientIndex(fi *featurebase.IndexInfo) *Index

ToClientIndex

func (*Index) All

func (idx *Index) All() *PQLRowQuery

All creates an All query. Returns the set columns with existence true.

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(row *PQLRowQuery) *PQLBaseQuery

Count creates a Count query. Returns the number of set columns in the ROW_CALL passed in.

func (*Index) CreatedAt

func (idx *Index) CreatedAt() int64

func (*Index) Difference

func (idx *Index) Difference(rows ...*PQLRowQuery) *PQLRowQuery

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

func (*Index) Field

func (idx *Index) Field(name string, options ...FieldOption) *Field

Field creates a Field struct with the specified name and defaults.

func (*Index) Fields

func (idx *Index) Fields() map[string]*Field

Fields return a copy of the fields in this index

func (*Index) GroupBy

func (idx *Index) GroupBy(rowsQueries ...*PQLRowsQuery) *PQLBaseQuery

GroupBy creates a GroupBy query with the given Rows queries

func (*Index) GroupByBase

func (idx *Index) GroupByBase(opts ...GroupByBuilderOption) *PQLBaseQuery

GroupByBase creates a GroupBy query with the given functional options.

func (*Index) GroupByFilter

func (idx *Index) GroupByFilter(filterQuery *PQLRowQuery, rowsQueries ...*PQLRowsQuery) *PQLBaseQuery

GroupByFilter creates a GroupBy query with the given filter and Rows queries

func (*Index) GroupByLimit

func (idx *Index) GroupByLimit(limit int64, rowsQueries ...*PQLRowsQuery) *PQLBaseQuery

GroupByLimit creates a GroupBy query with the given limit and Rows queries

func (*Index) GroupByLimitFilter

func (idx *Index) GroupByLimitFilter(limit int64, filterQuery *PQLRowQuery, rowsQueries ...*PQLRowsQuery) *PQLBaseQuery

GroupByLimitFilter creates a GroupBy query with the given filter and Rows queries

func (*Index) HasField

func (idx *Index) HasField(fieldName string) bool

HasFields returns true if the given field exists in the index.

func (*Index) Intersect

func (idx *Index) Intersect(rows ...*PQLRowQuery) *PQLRowQuery

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

func (*Index) Name

func (idx *Index) Name() string

Name returns the name of this index.

func (*Index) Not

func (idx *Index) Not(row *PQLRowQuery) *PQLRowQuery

Not creates a Not query.

func (*Index) Options

func (idx *Index) Options(row *PQLRowQuery, opts ...OptionsOption) *PQLBaseQuery

Options creates an Options query.

func (*Index) Opts

func (idx *Index) Opts() IndexOptions

Opts returns the options 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) ShardWidth

func (idx *Index) ShardWidth() uint64

func (*Index) String

func (idx *Index) String() string

func (*Index) Union

func (idx *Index) Union(rows ...*PQLRowQuery) *PQLRowQuery

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

func (*Index) Xor

func (idx *Index) Xor(rows ...*PQLRowQuery) *PQLRowQuery

Xor creates an Xor query.

type IndexOption

type IndexOption func(options *IndexOptions)

IndexOption is used to pass an option to Index function.

func OptIndexKeys

func OptIndexKeys(keys bool) IndexOption

OptIndexKeys sets whether index uses string keys.

func OptIndexTrackExistence

func OptIndexTrackExistence(trackExistence bool) IndexOption

OptIndexTrackExistence enables keeping track of existence of columns.

type IndexOptions

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

IndexOptions contains options to customize Index objects.

func (IndexOptions) Keys

func (io IndexOptions) Keys() bool

Keys return true if this index has keys.

func (IndexOptions) String

func (io IndexOptions) String() string

String serializes this index to a JSON string.

func (IndexOptions) TrackExistence

func (io IndexOptions) TrackExistence() bool

TrackExistence returns true if existence is tracked for this index.

type Info

type Info struct {
	ShardWidth       uint64 `json:"shardWidth"`       // width of each shard
	Memory           uint64 `json:"memory"`           // approximate host physical memory
	CPUType          string `json:"cpuType"`          // "brand name string" from cpuid
	CPUPhysicalCores int    `json:"CPUPhysicalCores"` // physical cores (cpuid)
	CPULogicalCores  int    `json:"CPULogicalCores"`  // logical cores cpuid
	CPUMHz           uint64 `json:"CPUMHz"`           // estimated clock speed
}

Info contains the configuration/host information from a Pilosa server.

type IntOrFloat

type IntOrFloat interface{}

type IntResult

type IntResult int64

IntResult is returned from Count call.

func (IntResult) Changed

func (IntResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (IntResult) Count

func (i IntResult) Count() int64

Count returns the result of a Count call.

func (IntResult) CountItem

func (IntResult) CountItem() CountResultItem

CountItem returns a CountResultItem

func (IntResult) CountItems

func (IntResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (IntResult) GroupCounts

func (IntResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (IntResult) Row

func (IntResult) Row() RowResult

Row returns a RowResult.

func (IntResult) RowIdentifiers

func (IntResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (IntResult) Type

func (IntResult) Type() uint32

Type is the type of this result.

func (IntResult) Value

func (IntResult) Value() int64

Value returns the result of a Min, Max or Sum call.

type NilResult

type NilResult struct{}

NilResult is returned from calls which don't return a value.

func (NilResult) Changed

func (NilResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (NilResult) Count

func (NilResult) Count() int64

Count returns the result of a Count call.

func (NilResult) CountItem

func (NilResult) CountItem() CountResultItem

CountItem returns a CountResultItem

func (NilResult) CountItems

func (NilResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (NilResult) GroupCounts

func (NilResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (NilResult) Row

func (NilResult) Row() RowResult

Row returns a RowResult.

func (NilResult) RowIdentifiers

func (NilResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (NilResult) Type

func (NilResult) Type() uint32

Type is the type of this result.

func (NilResult) Value

func (NilResult) Value() int64

Value returns the result of a Min, Max or Sum call.

type NoopSpan

type NoopSpan struct{}

func (NoopSpan) BaggageItem

func (s NoopSpan) BaggageItem(restrictedKey string) string

func (NoopSpan) Context

func (s NoopSpan) Context() opentracing.SpanContext

func (NoopSpan) Finish

func (s NoopSpan) Finish()

func (NoopSpan) FinishWithOptions

func (s NoopSpan) FinishWithOptions(opts opentracing.FinishOptions)

func (NoopSpan) Log

func (s NoopSpan) Log(data opentracing.LogData)

func (NoopSpan) LogEvent

func (s NoopSpan) LogEvent(event string)

func (NoopSpan) LogEventWithPayload

func (s NoopSpan) LogEventWithPayload(event string, payload interface{})

func (NoopSpan) LogFields

func (s NoopSpan) LogFields(fields ...log.Field)

func (NoopSpan) LogKV

func (s NoopSpan) LogKV(alternatingKeyValues ...interface{})

func (NoopSpan) SetBaggageItem

func (s NoopSpan) SetBaggageItem(restrictedKey, value string) opentracing.Span

func (NoopSpan) SetOperationName

func (s NoopSpan) SetOperationName(operationName string) opentracing.Span

func (NoopSpan) SetTag

func (s NoopSpan) SetTag(key string, value interface{}) opentracing.Span

func (NoopSpan) Tracer

func (s NoopSpan) Tracer() opentracing.Tracer

type NoopTracer

type NoopTracer struct{}

func (NoopTracer) Extract

func (t NoopTracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)

func (NoopTracer) Inject

func (t NoopTracer) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error

func (NoopTracer) StartSpan

func (t NoopTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span

type OptionsOption

type OptionsOption func(options *OptionsOptions)

OptionsOption is an option for Index.Options call.

func OptOptionsShards

func OptOptionsShards(shards ...uint64) OptionsOption

OptOptionsShards run the query using only the data from the given shards. By default, the entire data set (i.e. data from all shards) is used.

type OptionsOptions

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

OptionsOptions is used to pass an option to Option call.

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

func (*PQLBaseQuery) Serialize

func (q *PQLBaseQuery) Serialize() SerializedQuery

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:

repo, err := NewIndex("repository")
stargazer, err := repo.Field("stargazer")
query := repo.BatchQuery(
	stargazer.Row(5),
	stargazer.Row(15),
	repo.Union(stargazer.Row(20), stargazer.Row(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.

func (*PQLBatchQuery) Serialize

func (q *PQLBatchQuery) Serialize() SerializedQuery

type PQLQuery

type PQLQuery interface {
	Index() *Index
	Serialize() SerializedQuery
	Error() error
}

PQLQuery is an interface for PQL queries.

type PQLRowQuery

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

PQLRowQuery is the return type for row queries.

func NewPQLRowQuery

func NewPQLRowQuery(pql string, index *Index, err error) *PQLRowQuery

NewPQLRowQuery creates a new PqlRowQuery.

func (PQLRowQuery) Error

func (q PQLRowQuery) Error() error

Error returns the error or nil for this query.

func (*PQLRowQuery) Index

func (q *PQLRowQuery) Index() *Index

Index returns the index for this query/

func (*PQLRowQuery) Serialize

func (q *PQLRowQuery) Serialize() SerializedQuery

type PQLRowsQuery

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

PQLRowsQuery is the return type for Rows calls.

func NewPQLRowsQuery

func NewPQLRowsQuery(pql string, index *Index, err error) *PQLRowsQuery

NewPQLRowsQuery creates a new PQLRowsQuery.

func (PQLRowsQuery) Error

func (q PQLRowsQuery) Error() error

Error returns the error or nil for this query.

func (*PQLRowsQuery) Index

func (q *PQLRowsQuery) Index() *Index

Index returns the index for this query/

func (*PQLRowsQuery) Serialize

func (q *PQLRowsQuery) Serialize() SerializedQuery

func (*PQLRowsQuery) Union

func (q *PQLRowsQuery) Union() *PQLRowQuery

Union returns the union of all matched rows.

type QueryOption

type QueryOption func(options *QueryOptions) error

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

func OptQueryShards

func OptQueryShards(shards ...uint64) QueryOption

OptQueryShards restricts the set of shards on which a query operates.

type QueryOptions

type QueryOptions struct {
	// Shards restricts query to a subset of shards. Queries all shards if nil.
	Shards []uint64
}

QueryOptions contains options to customize the Query function.

type QueryResponse

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

QueryResponse represents the response from a Pilosa query.

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
	Row() RowResult
	CountItems() []CountResultItem
	CountItem() CountResultItem
	Count() int64
	Value() int64
	Changed() bool
	GroupCounts() []GroupCount
	RowIdentifiers() RowIdentifiersResult
}

QueryResult represents one of the results in the response.

type Record

type Record interface {
	Shard(shardWidth uint64) uint64
	Less(other Record) bool
}

Record is a Column or a FieldValue.

type RecordIterator

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

RecordIterator is an iterator for a record.

type RowIdentifiersResult

type RowIdentifiersResult struct {
	IDs  []uint64 `json:"ids"`
	Keys []string `json:"keys,omitempty"`
}

RowIdentifiersResult is returned from a Rows call.

func (RowIdentifiersResult) Changed

func (RowIdentifiersResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (RowIdentifiersResult) Count

func (RowIdentifiersResult) Count() int64

Count returns the result of a Count call.

func (RowIdentifiersResult) CountItem

CountItem returns a CountResultItem

func (RowIdentifiersResult) CountItems

func (RowIdentifiersResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (RowIdentifiersResult) GroupCounts

func (RowIdentifiersResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (RowIdentifiersResult) Row

Row returns a RowResult.

func (RowIdentifiersResult) RowIdentifiers

func (r RowIdentifiersResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (RowIdentifiersResult) Type

Type is the type of this result.

func (RowIdentifiersResult) Value

func (RowIdentifiersResult) Value() int64

Value returns the result of a Min, Max or Sum call.

type RowResult

type RowResult struct {
	Columns []uint64 `json:"columns"`
	Keys    []string `json:"keys"`
}

RowResult represents a result from Row, Union, Intersect, Difference and Range PQL calls.

func (RowResult) Changed

func (RowResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (RowResult) Count

func (RowResult) Count() int64

Count returns the result of a Count call.

func (RowResult) CountItem

func (RowResult) CountItem() CountResultItem

CountItem returns a CountResultItem

func (RowResult) CountItems

func (RowResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (RowResult) GroupCounts

func (RowResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (RowResult) MarshalJSON

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

MarshalJSON serializes this row result.

func (RowResult) Row

func (b RowResult) Row() RowResult

Row returns a RowResult.

func (RowResult) RowIdentifiers

func (RowResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (RowResult) Type

func (RowResult) Type() uint32

Type is the type of this result.

func (RowResult) Value

func (RowResult) Value() int64

Value returns the result of a Min, Max or Sum call.

type Schema

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

Schema contains the index properties

func NewSchema

func NewSchema() *Schema

NewSchema creates a new Schema

func (*Schema) HasIndex

func (s *Schema) HasIndex(indexName string) bool

HasIndex returns true if the given index is in the schema.

func (*Schema) Index

func (s *Schema) Index(name string, options ...IndexOption) *Index

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

func (s *Schema) String() string

type SchemaField

type SchemaField struct {
	Name      string        `json:"name"`
	CreatedAt int64         `json:"createdAt,omitempty"`
	Options   SchemaOptions `json:"options"`
}

SchemaField contains field information.

type SchemaIndex

type SchemaIndex struct {
	Name       string        `json:"name"`
	CreatedAt  int64         `json:"createdAt,omitempty"`
	Options    SchemaOptions `json:"options"`
	Fields     []SchemaField `json:"fields"`
	Shards     []uint64      `json:"shards"`
	ShardWidth uint64        `json:"shardWidth"`
}

SchemaIndex contains index information.

type SchemaInfo

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

SchemaInfo contains the indexes.

type SchemaOptions

type SchemaOptions struct {
	FieldType      FieldType     `json:"type"`
	CacheType      string        `json:"cacheType"`
	CacheSize      uint          `json:"cacheSize"`
	TimeQuantum    string        `json:"timeQuantum"`
	TTL            time.Duration `json:"ttl"`
	Min            pql.Decimal   `json:"min"`
	Max            pql.Decimal   `json:"max"`
	Scale          int64         `json:"scale"`
	Keys           bool          `json:"keys"`
	NoStandardView bool          `json:"noStandardView"`
	TrackExistence bool          `json:"trackExistence"`
	TimeUnit       string        `json:"timeUnit"`
	Base           int64         `json:"base"`
	Epoch          time.Time     `json:"epoch"`
	ForeignIndex   string        `json:"foreignIndex"`
}

SchemaOptions contains options for a field or an index.

type SerializedQuery

type SerializedQuery interface {
	String() string
	HasWriteKeys() bool
}

type Status

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

Status contains the status information from a Pilosa server.

type StatusNode

type StatusNode struct {
	ID        string    `json:"id"`
	URI       StatusURI `json:"uri"`
	IsPrimary bool      `json:"isPrimary"`
}

StatusNode contains information about a node in the cluster.

type StatusURI

type StatusURI struct {
	Scheme string `json:"scheme"`
	Host   string `json:"host"`
	Port   uint16 `json:"port"`
}

StatusURI contains node information.

func (StatusURI) URI

func (s StatusURI) URI() pnet.URI

URI returns the StatusURI as a URI.

type TopNResult

type TopNResult []CountResultItem

TopNResult is returned from TopN call.

func (TopNResult) Changed

func (TopNResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (TopNResult) Count

func (TopNResult) Count() int64

Count returns the result of a Count call.

func (TopNResult) CountItem

func (t TopNResult) CountItem() CountResultItem

CountItem returns a CountResultItem

func (TopNResult) CountItems

func (t TopNResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (TopNResult) GroupCounts

func (TopNResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (TopNResult) Row

func (TopNResult) Row() RowResult

Row returns a RowResult.

func (TopNResult) RowIdentifiers

func (TopNResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (TopNResult) Type

func (TopNResult) Type() uint32

Type is the type of this result.

func (TopNResult) Value

func (TopNResult) Value() int64

Value returns the result of a Min, Max or Sum call.

type TransactionResponse

type TransactionResponse struct {
	Transaction *pilosa.Transaction `json:"transaction,omitempty"`
	Error       string              `json:"error,omitempty"`
}

type ValCountResult

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

ValCountResult is returned from Min, Max and Sum calls.

func (ValCountResult) Changed

func (ValCountResult) Changed() bool

Changed returns whether the corresponding Set or Clear call changed the value of a bit.

func (ValCountResult) Count

func (c ValCountResult) Count() int64

Count returns the result of a Count call.

func (ValCountResult) CountItem

func (ValCountResult) CountItem() CountResultItem

CountItem returns a CountResultItem

func (ValCountResult) CountItems

func (ValCountResult) CountItems() []CountResultItem

CountItems returns a CountResultItem slice.

func (ValCountResult) GroupCounts

func (ValCountResult) GroupCounts() []GroupCount

GroupCounts returns the result of a GroupBy call.

func (ValCountResult) Row

func (ValCountResult) Row() RowResult

Row returns a RowResult.

func (ValCountResult) RowIdentifiers

func (ValCountResult) RowIdentifiers() RowIdentifiersResult

RowIdentifiers returns the result of a Rows call.

func (ValCountResult) Type

func (ValCountResult) Type() uint32

Type is the type of this result.

func (ValCountResult) Value

func (c ValCountResult) Value() int64

Value returns the result of a Min, Max or Sum call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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