Documentation
¶
Index ¶
- Constants
- Variables
- type BridgeAccessor
- type ClientSettings
- type CompositeElementFilter
- type GsiAccessor
- type GsiClient
- func (c *GsiClient) Bridge() BridgeAccessor
- func (c *GsiClient) BucketSeqnos(bucketn string, hash64 uint64) (*TsConsistency, error)
- func (c *GsiClient) BucketTs(bucketn string) (*TsConsistency, error)
- func (c *GsiClient) BuildIndexes(defnIDs []uint64) error
- func (c *GsiClient) Close()
- func (c *GsiClient) CountLookup(defnID uint64, requestId string, values []common.SecondaryKey, ...) (count int64, err error)
- func (c *GsiClient) CountRange(defnID uint64, requestId string, low, high common.SecondaryKey, ...) (count int64, err error)
- func (c *GsiClient) CreateIndex(name, bucket, using, exprType, partnExpr, whereExpr string, secExprs []string, ...) (defnID uint64, err error)
- func (c *GsiClient) CreateIndex2(name, bucket, using, exprType, partnExpr, whereExpr string, secExprs []string, ...) (defnID uint64, err error)
- func (c *GsiClient) DescribeError(err error) string
- func (c *GsiClient) DropIndex(defnID uint64) error
- func (c *GsiClient) IndexState(defnID uint64) (common.IndexState, error)
- func (c *GsiClient) Lookup(defnID uint64, requestId string, values []common.SecondaryKey, distinct bool, ...) (err error)
- func (c *GsiClient) LookupStatistics(defnID uint64, requestId string, value common.SecondaryKey) (common.IndexStatistics, error)
- func (c *GsiClient) MoveIndex(defnID uint64, with map[string]interface{}) error
- func (c *GsiClient) MultiScan(defnID uint64, requestId string, scans Scans, reverse, distinct bool, ...) (err error)
- func (c *GsiClient) MultiScanCount(defnID uint64, requestId string, scans Scans, distinct bool, ...) (count int64, err error)
- func (c *GsiClient) Nodes() ([]*IndexerService, error)
- func (c *GsiClient) Range(defnID uint64, requestId string, low, high common.SecondaryKey, ...) (err error)
- func (c *GsiClient) RangeStatistics(defnID uint64, requestId string, low, high common.SecondaryKey, ...) (common.IndexStatistics, error)
- func (c *GsiClient) Refresh() ([]*mclient.IndexMetadata, uint64, uint64, error)
- func (c *GsiClient) ScanAll(defnID uint64, requestId string, limit int64, cons common.Consistency, ...) (err error)
- func (c *GsiClient) Settings() *ClientSettings
- func (c *GsiClient) Sync() error
- type GsiScanClient
- func (c *GsiScanClient) Close() error
- func (c *GsiScanClient) CountLookup(defnID uint64, requestId string, values []common.SecondaryKey, ...) (int64, error)
- func (c *GsiScanClient) CountLookupPrimary(defnID uint64, requestId string, values [][]byte, cons common.Consistency, ...) (int64, error)
- func (c *GsiScanClient) CountRange(defnID uint64, requestId string, low, high common.SecondaryKey, ...) (int64, error)
- func (c *GsiScanClient) CountRangePrimary(defnID uint64, requestId string, low, high []byte, inclusion Inclusion, ...) (int64, error)
- func (c *GsiScanClient) Helo() (uint32, error)
- func (c *GsiScanClient) Lookup(defnID uint64, requestId string, values []common.SecondaryKey, distinct bool, ...) (error, bool)
- func (c *GsiScanClient) LookupStatistics(defnID uint64, value common.SecondaryKey) (common.IndexStatistics, error)
- func (c *GsiScanClient) MultiScan(defnID uint64, requestId string, scans Scans, reverse, distinct bool, ...) (error, bool)
- func (c *GsiScanClient) MultiScanCount(defnID uint64, requestId string, scans Scans, distinct bool, ...) (int64, error)
- func (c *GsiScanClient) MultiScanCountPrimary(defnID uint64, requestId string, scans Scans, distinct bool, ...) (int64, error)
- func (c *GsiScanClient) MultiScanPrimary(defnID uint64, requestId string, scans Scans, reverse, distinct bool, ...) (error, bool)
- func (c *GsiScanClient) NeedSessionConsVector() bool
- func (c *GsiScanClient) Range(defnID uint64, requestId string, low, high common.SecondaryKey, ...) (error, bool)
- func (c *GsiScanClient) RangePrimary(defnID uint64, requestId string, low, high []byte, inclusion Inclusion, ...) (error, bool)
- func (c *GsiScanClient) RangeStatistics(defnID uint64, low, high common.SecondaryKey, inclusion Inclusion) (common.IndexStatistics, error)
- func (c *GsiScanClient) RefreshServerVersion()
- func (c *GsiScanClient) ScanAll(defnID uint64, requestId string, limit int64, cons common.Consistency, ...) (error, bool)
- type Inclusion
- type IndexIdList
- type IndexProjection
- type IndexRequest
- type IndexResponse
- type IndexerService
- type Remoteaddr
- type RequestType
- type ResponseHandler
- type ResponseReader
- type Scan
- type Scans
- type TsConsistency
Constants ¶
const ( RESP_SUCCESS string = "success" RESP_ERROR string = "error" )
Variables ¶
ConnPoolTimeout is notified whenever connections are acquired from a pool.
var ErrIndexNotFound = fmt.Errorf("Index not found")
These error strings need to be in sync with common.ErrIndexNotFound and common.ErrIndexNotReady.
var ErrIndexNotReady = fmt.Errorf("Index not ready for serving queries")
var ErrorClientUninitialized = errors.New("queryport.clientUninitialized")
ErrorClientUninitialized
var ErrorClosedPool = errors.New("queryport.closedPool")
ErrorClosedPool
var ErrorExpectedTimestamp = errors.New("queryport.expectedTimestamp")
ErrorExpectedTimestamp
var ErrorIndexNotFound = errors.New("queryport.indexNotFound")
ErrorIndexNotFound
var ErrorInstanceNotFound = errors.New("queryport.instanceNotFound")
ErrorInstanceNotFound
var ErrorInvalidConsistency = errors.New("queryport.invalidConsistency")
ErrorInvalidConsistency
var ErrorNoHost = errors.New("queryport.client.noHost")
ErrorNoHost
var ErrorNoPool = errors.New("queryport.errorNoPool")
ErrorNoPool
var ErrorNotImplemented = errors.New("queryport.notImplemented")
ErrorNotImplemented
var ErrorPoolTimeout = errors.New("queryport.connPoolTimeout")
ErrorPoolTimeout
var ErrorProtocol = errors.New("queryport.client.protocol")
ErrorProtocol
Functions ¶
This section is empty.
Types ¶
type BridgeAccessor ¶
type BridgeAccessor interface { // Synchronously update current server metadata to the client // A Refresh call followed by a Sync() ensures that client is // up to date wrt the server. Sync() error // Refresh shall refresh to latest set of index managed by GSI // cluster, cache it locally and return the list of index. Refresh() ([]*mclient.IndexMetadata, uint64, uint64, error) // Nodes shall return a map of adminport and queryport for indexer // nodes. Nodes() ([]*IndexerService, error) // CreateIndex and return defnID of created index. // name // index name // bucket // bucket name in which index is defined. // using // token should always be GSI. // exprType // token specifies how in interpret partnExpr, whereExpr, secExprs // partnExpr // marshalled expression of type `exprType` that emits partition // value from a kv-document. // whereExpr // marshalled predicate-expression of type `exprType` that emits // a boolean from a kv-document. // secExprs // marshalled list of expression of type `exprType` that emits // an array of secondary-key values from a kv-document. // isPrimary // specify whether the index is created on docid. // with // JSON marshalled description about index deployment (and more...). CreateIndex( name, bucket, using, exprType, partnExpr, whereExpr string, secExprs []string, desc []bool, isPrimary bool, with []byte) (defnID uint64, err error) // BuildIndexes to build a deferred set of indexes. This call implies // that indexes specified are already created. BuildIndexes(defnIDs []uint64) error // MoveIndex to move a set of indexes to different node. MoveIndex(defnID uint64, with map[string]interface{}) error // DropIndex to drop index specified by `defnID`. // - if index is in deferred build state, it shall be removed // from deferred list. DropIndex(defnID uint64) error // GetScanports shall return list of queryports for all indexer in // the cluster. GetScanports() (queryports []string) // GetScanport shall fetch queryport address for indexer, // if `retry` is ZERO, pick the indexer under least // load, else do a round-robin, based on the retry count, // if more than one indexer is found hosing the index or an // equivalent index. GetScanport( defnID uint64, retry int, excludes map[uint64]bool) (queryport string, targetDefnID uint64, targetInstID uint64, rollbackTime int64, ok bool) // GetIndex will return the index-definition structure for defnID. GetIndexDefn(defnID uint64) *common.IndexDefn // IndexState returns the current state of index `defnID` and error. IndexState(defnID uint64) (common.IndexState, error) // IsPrimary returns whether index is on primary key. IsPrimary(defnID uint64) bool // Timeit will add `value` to incrementalAvg for index-load. Timeit(instID uint64, value float64) // Close this accessor. Close() }
BridgeAccessor for Create,Drop,List,Refresh operations.
type ClientSettings ¶
type ClientSettings struct {
// contains filtered or unexported fields
}
func NewClientSettings ¶
func NewClientSettings(needRefresh bool) *ClientSettings
func (*ClientSettings) BackfillLimit ¶
func (s *ClientSettings) BackfillLimit() int32
func (*ClientSettings) Close ¶
func (s *ClientSettings) Close()
func (*ClientSettings) DisablePruneReplica ¶
func (s *ClientSettings) DisablePruneReplica() bool
func (*ClientSettings) NumReplica ¶
func (s *ClientSettings) NumReplica() int32
func (*ClientSettings) ScanLagItem ¶
func (s *ClientSettings) ScanLagItem() uint64
func (*ClientSettings) ScanLagPercent ¶
func (s *ClientSettings) ScanLagPercent() float64
type CompositeElementFilter ¶
type CompositeElementFilter struct { Low interface{} High interface{} Inclusion Inclusion }
type GsiAccessor ¶
type GsiAccessor interface { BridgeAccessor // LookupStatistics for a single secondary-key. LookupStatistics( defnID uint64, requestId string, v common.SecondaryKey) (common.IndexStatistics, error) // RangeStatistics for index range. RangeStatistics( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion) (common.IndexStatistics, error) // Lookup scan index between low and high. Lookup( defnID uint64, requestId string, values []common.SecondaryKey, distinct bool, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) error // Range scan index between low and high. Range( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion, distinct bool, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) error // ScanAll for full table scan. ScanAll( defnID uint64, requestId string, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) error // Multiple scans with composite index filters MultiScan( defnID uint64, requestId string, scans Scans, reverse, distinct bool, projection *IndexProjection, offset, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) error // CountLookup of all entries in index. CountLookup( defnID uint64, requestId string, values []common.SecondaryKey, cons common.Consistency, vector *TsConsistency) (int64, error) // CountRange of all entries in index. CountRange( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion, cons common.Consistency, vector *TsConsistency) (int64, error) // Count using MultiScan MultiScanCount( defnID uint64, requestId string, scans Scans, distinct bool, cons common.Consistency, vector *TsConsistency) (int64, error) }
GsiAccessor for index operation on GSI cluster.
type GsiClient ¶
type GsiClient struct {
// contains filtered or unexported fields
}
GsiClient for accessing GSI cluster. The client shall use `adminport` for meta-data operation and `queryport` for index-scan related operations.
func NewGsiClient ¶
NewGsiClient returns client to access GSI cluster.
func (*GsiClient) Bridge ¶
func (c *GsiClient) Bridge() BridgeAccessor
func (*GsiClient) BucketSeqnos ¶
func (c *GsiClient) BucketSeqnos( bucketn string, hash64 uint64) (*TsConsistency, error)
BucketSeqnos will return the current vbucket-timestamp using GET_SEQNOS command.
func (*GsiClient) BucketTs ¶
func (c *GsiClient) BucketTs(bucketn string) (*TsConsistency, error)
BucketTs will return the current vbucket-timestamp using STATS command.
func (*GsiClient) BuildIndexes ¶
BuildIndexes implements BridgeAccessor{} interface.
func (*GsiClient) Close ¶
func (c *GsiClient) Close()
Close the client and all open connections with server.
func (*GsiClient) CountLookup ¶
func (c *GsiClient) CountLookup( defnID uint64, requestId string, values []common.SecondaryKey, cons common.Consistency, vector *TsConsistency) (count int64, err error)
CountLookup to count number entries for given set of keys.
func (*GsiClient) CountRange ¶
func (c *GsiClient) CountRange( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion, cons common.Consistency, vector *TsConsistency) (count int64, err error)
CountRange to count number entries in the given range.
func (*GsiClient) CreateIndex ¶
func (c *GsiClient) CreateIndex( name, bucket, using, exprType, partnExpr, whereExpr string, secExprs []string, isPrimary bool, with []byte) (defnID uint64, err error)
CreateIndex implements BridgeAccessor{} interface.
func (*GsiClient) CreateIndex2 ¶
func (c *GsiClient) CreateIndex2( name, bucket, using, exprType, partnExpr, whereExpr string, secExprs []string, desc []bool, isPrimary bool, with []byte) (defnID uint64, err error)
CreateIndex implements BridgeAccessor{} interface.
func (*GsiClient) DescribeError ¶
DescribeError return error description as human readable string.
func (*GsiClient) IndexState ¶
func (c *GsiClient) IndexState(defnID uint64) (common.IndexState, error)
IndexState implements BridgeAccessor{} interface.
func (*GsiClient) Lookup ¶
func (c *GsiClient) Lookup( defnID uint64, requestId string, values []common.SecondaryKey, distinct bool, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) (err error)
Lookup scan index between low and high.
func (*GsiClient) LookupStatistics ¶
func (c *GsiClient) LookupStatistics( defnID uint64, requestId string, value common.SecondaryKey) (common.IndexStatistics, error)
LookupStatistics for a single secondary-key.
func (*GsiClient) MultiScan ¶
func (c *GsiClient) MultiScan( defnID uint64, requestId string, scans Scans, reverse, distinct bool, projection *IndexProjection, offset, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) (err error)
func (*GsiClient) MultiScanCount ¶
func (c *GsiClient) MultiScanCount( defnID uint64, requestId string, scans Scans, distinct bool, cons common.Consistency, vector *TsConsistency) (count int64, err error)
func (*GsiClient) Nodes ¶
func (c *GsiClient) Nodes() ([]*IndexerService, error)
Nodes implements BridgeAccessor{} interface.
func (*GsiClient) Range ¶
func (c *GsiClient) Range( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion, distinct bool, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) (err error)
Range scan index between low and high.
func (*GsiClient) RangeStatistics ¶
func (c *GsiClient) RangeStatistics( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion) (common.IndexStatistics, error)
RangeStatistics for index range.
func (*GsiClient) ScanAll ¶
func (c *GsiClient) ScanAll( defnID uint64, requestId string, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler) (err error)
ScanAll for full table scan.
func (*GsiClient) Settings ¶
func (c *GsiClient) Settings() *ClientSettings
DescribeError return error description as human readable string.
type GsiScanClient ¶
type GsiScanClient struct {
// contains filtered or unexported fields
}
GsiScanClient for scan operations.
func NewGsiScanClient ¶
func NewGsiScanClient(queryport string, config common.Config) (*GsiScanClient, error)
func (*GsiScanClient) Close ¶
func (c *GsiScanClient) Close() error
func (*GsiScanClient) CountLookup ¶
func (c *GsiScanClient) CountLookup( defnID uint64, requestId string, values []common.SecondaryKey, cons common.Consistency, vector *TsConsistency, rollbackTime int64) (int64, error)
CountLookup to count number entries for given set of keys.
func (*GsiScanClient) CountLookupPrimary ¶
func (c *GsiScanClient) CountLookupPrimary( defnID uint64, requestId string, values [][]byte, cons common.Consistency, vector *TsConsistency, rollbackTime int64) (int64, error)
CountLookup to count number entries for given set of keys for primary index
func (*GsiScanClient) CountRange ¶
func (c *GsiScanClient) CountRange( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion, cons common.Consistency, vector *TsConsistency, rollbackTime int64) (int64, error)
CountRange to count number entries in the given range.
func (*GsiScanClient) CountRangePrimary ¶
func (c *GsiScanClient) CountRangePrimary( defnID uint64, requestId string, low, high []byte, inclusion Inclusion, cons common.Consistency, vector *TsConsistency, rollbackTime int64) (int64, error)
CountRange to count number entries in the given range for primary index
func (*GsiScanClient) Helo ¶
func (c *GsiScanClient) Helo() (uint32, error)
func (*GsiScanClient) Lookup ¶
func (c *GsiScanClient) Lookup( defnID uint64, requestId string, values []common.SecondaryKey, distinct bool, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler, rollbackTime int64) (error, bool)
Lookup scan index between low and high.
func (*GsiScanClient) LookupStatistics ¶
func (c *GsiScanClient) LookupStatistics( defnID uint64, value common.SecondaryKey) (common.IndexStatistics, error)
LookupStatistics for a single secondary-key.
func (*GsiScanClient) MultiScan ¶
func (c *GsiScanClient) MultiScan( defnID uint64, requestId string, scans Scans, reverse, distinct bool, projection *IndexProjection, offset, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler, rollbackTime int64) (error, bool)
func (*GsiScanClient) MultiScanCount ¶
func (c *GsiScanClient) MultiScanCount( defnID uint64, requestId string, scans Scans, distinct bool, cons common.Consistency, vector *TsConsistency, rollbackTime int64) (int64, error)
func (*GsiScanClient) MultiScanCountPrimary ¶
func (c *GsiScanClient) MultiScanCountPrimary( defnID uint64, requestId string, scans Scans, distinct bool, cons common.Consistency, vector *TsConsistency, rollbackTime int64) (int64, error)
func (*GsiScanClient) MultiScanPrimary ¶
func (c *GsiScanClient) MultiScanPrimary( defnID uint64, requestId string, scans Scans, reverse, distinct bool, projection *IndexProjection, offset, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler, rollbackTime int64) (error, bool)
func (*GsiScanClient) NeedSessionConsVector ¶
func (c *GsiScanClient) NeedSessionConsVector() bool
func (*GsiScanClient) Range ¶
func (c *GsiScanClient) Range( defnID uint64, requestId string, low, high common.SecondaryKey, inclusion Inclusion, distinct bool, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler, rollbackTime int64) (error, bool)
Range scan index between low and high.
func (*GsiScanClient) RangePrimary ¶
func (c *GsiScanClient) RangePrimary( defnID uint64, requestId string, low, high []byte, inclusion Inclusion, distinct bool, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler, rollbackTime int64) (error, bool)
Range scan index between low and high.
func (*GsiScanClient) RangeStatistics ¶
func (c *GsiScanClient) RangeStatistics( defnID uint64, low, high common.SecondaryKey, inclusion Inclusion) (common.IndexStatistics, error)
RangeStatistics for index range.
func (*GsiScanClient) RefreshServerVersion ¶
func (c *GsiScanClient) RefreshServerVersion()
func (*GsiScanClient) ScanAll ¶
func (c *GsiScanClient) ScanAll( defnID uint64, requestId string, limit int64, cons common.Consistency, vector *TsConsistency, callb ResponseHandler, rollbackTime int64) (error, bool)
ScanAll for full table scan.
type IndexIdList ¶
type IndexIdList struct {
DefnIds []uint64 `json:"defnIds,omitempty"`
}
type IndexProjection ¶
type IndexRequest ¶
type IndexRequest struct { Version uint64 `json:"version,omitempty"` Type RequestType `json:"type,omitempty"` Index common.IndexDefn `json:"index,omitempty"` IndexIds IndexIdList `json:indexIds,omitempty"` Plan map[string]interface{} `json:plan,omitempty"` }
type IndexResponse ¶
type IndexerService ¶
type IndexerService struct { Adminport string Queryport string Status string // one of "initial", "online", "recovery" }
IndexerService returns the status of the indexer node as observed by the GsiClient.
type RequestType ¶
type RequestType string
const ( CREATE RequestType = "create" DROP RequestType = "drop" BUILD RequestType = "build" )
type ResponseHandler ¶
type ResponseHandler func(resp ResponseReader) bool
ResponseHandler shall interpret response packets from server and handle them. If handler is not interested in receiving any more response it shall return false, else it shall continue until *protobufEncode.StreamEndResponse message is received.
type ResponseReader ¶
type ResponseReader interface { // GetEntries returns a list of secondary-key and corresponding // primary-key if returned value is nil, then there are no more // entries for this query. GetEntries() ([]common.SecondaryKey, [][]byte, error) // Error returns the error value, if nil there is no error. Error() error }
ResponseReader to obtain the actual data returned from server, handlers, should first call Error() and then call GetEntries().
type Scan ¶
type Scan struct { Seek common.SecondaryKey Filter []*CompositeElementFilter }
type TsConsistency ¶
TsConsistency specifies a subset of vbuckets to be used as timestamp vector to specify consistency criteria.
Timestamp-vector will be ignored for AnyConsistency, computed locally by scan-coordinator or accepted as scan-arguments for SessionConsistency.
func NewTsConsistency ¶
func NewTsConsistency( vbnos []uint16, seqnos []uint64, vbuuids []uint64) *TsConsistency
NewTsConsistency returns a new consistency vector object.
func (*TsConsistency) Override ¶
func (ts *TsConsistency) Override( vbno uint16, seqno, vbuuid uint64) *TsConsistency
Override vbucket's {seqno, vbuuid} in the timestamp-vector, if vbucket is not present in the vector, append them to vector.