Documentation
¶
Index ¶
- Constants
- Variables
- func CreateInt64FromLSN(v LsnT) int64
- func GetCondType(name string) (int, error)
- func WithAppName(appName string) interface{}
- func WithCgoLimit(cgoLimit int) interface{}
- func WithConnPoolSize(connPoolSize int) interface{}
- func WithCreateDBIfMissing() interface{}
- func WithDedicatedServerThreads() interface{}
- func WithNetCompression() interface{}
- func WithReconnectionStrategy(strategy ReconnectStrategy, allowUnknownNodes bool) interface{}
- func WithRetryAttempts(read int, write int) interface{}
- func WithServerConfig(startupTimeout time.Duration, serverConfig *config.ServerConfig) interface{}
- func WithTimeouts(loginTimeout time.Duration, requestTimeout time.Duration) interface{}
- type AggregateFacetRequest
- type AggregationResult
- type CacheMemStat
- type ClientConnectionStat
- type DBAsyncReplicationConfig
- type DBAsyncReplicationNode
- type DBConfigItem
- type DBNamespacesConfig
- type DBProfilingConfig
- type DBReplicationConfig
- type DeepCopy
- type Error
- type ExplainResults
- type ExplainSelector
- type FtFastConfig
- type FtFastFieldConfig
- type FtFuzzyConfig
- type IndexDef
- type IndexDescription
- type Iterator
- func (it *Iterator) AggResults() (v []AggregationResult)
- func (it *Iterator) AllowUnsafe(allow bool) *Iterator
- func (it *Iterator) Close()
- func (it *Iterator) Count() int
- func (it *Iterator) Error() error
- func (it *Iterator) FetchAll() (items []interface{}, err error)
- func (it *Iterator) FetchAllWithRank() (items []interface{}, ranks []int, err error)
- func (it *Iterator) FetchOne() (item interface{}, err error)
- func (it *Iterator) GetAggreatedValue(idx int) float64
- func (it *Iterator) GetExplainResults() (*ExplainResults, error)
- func (it *Iterator) GetTagsMatcherInfo(nsName string) (stateToken int32, version int32)
- func (it *Iterator) HasRank() bool
- func (it *Iterator) JoinedObjects(field string) (objects []interface{}, err error)
- func (it *Iterator) Next() (hasNext bool)
- func (it *Iterator) NextObj(obj interface{}) (hasNext bool)
- func (it *Iterator) Object() interface{}
- func (it *Iterator) Rank() int
- func (it *Iterator) TotalCount() int
- type JSONIterator
- func (it *JSONIterator) Close()
- func (it *JSONIterator) Count() int
- func (it *JSONIterator) Error() error
- func (it *JSONIterator) FetchAll() (json []byte, err error)
- func (it *JSONIterator) GetExplainResults() (*ExplainResults, error)
- func (it *JSONIterator) JSON() (json []byte)
- func (it *JSONIterator) Next() bool
- type JoinHandler
- type Joinable
- type Logger
- type LsnT
- type NamespaceDescription
- type NamespaceMemStat
- type NamespaceOptions
- func (opts *NamespaceOptions) DisableObjCache() *NamespaceOptions
- func (opts *NamespaceOptions) DropOnFileFormatError() *NamespaceOptions
- func (opts *NamespaceOptions) DropOnIndexesConflict() *NamespaceOptions
- func (opts *NamespaceOptions) NoStorage() *NamespaceOptions
- func (opts *NamespaceOptions) ObjCacheSize(count int) *NamespaceOptions
- type NamespacePerfStat
- type PerfStat
- type Query
- func (q *Query) AggregateAvg(field string)
- func (q *Query) AggregateFacet(fields ...string) *AggregateFacetRequest
- func (q *Query) AggregateMax(field string)
- func (q *Query) AggregateMin(field string)
- func (q *Query) AggregateSum(field string)
- func (q *Query) CachedTotal(totalNames ...string) *Query
- func (q *Query) CloseBracket() *Query
- func (q *Query) DWithin(index string, point [2]float64, distance float64) *Query
- func (q *Query) Debug(level int) *Query
- func (q *Query) Delete() (int, error)
- func (q *Query) DeleteCtx(ctx context.Context) (int, error)
- func (q *Query) Distinct(distinctIndex string) *Query
- func (q *Query) Drop(field string) *Query
- func (q *Query) EqualPosition(fields ...string) *Query
- func (q *Query) Exec() *Iterator
- func (q *Query) ExecCtx(ctx context.Context) *Iterator
- func (q *Query) ExecToJson(jsonRoots ...string) *JSONIterator
- func (q *Query) ExecToJsonCtx(ctx context.Context, jsonRoots ...string) *JSONIterator
- func (q *Query) Explain() *Query
- func (q *Query) FetchCount(n int) *Query
- func (q *Query) Functions(fields ...string) *Query
- func (q *Query) Get() (item interface{}, found bool)
- func (q *Query) GetCtx(ctx context.Context) (item interface{}, found bool)
- func (q *Query) GetJson() (json []byte, found bool)
- func (q *Query) GetJsonCtx(ctx context.Context) (json []byte, found bool)
- func (q *Query) InnerJoin(q2 *Query, field string) *Query
- func (q *Query) Join(q2 *Query, field string) *Query
- func (q *Query) JoinHandler(field string, handler JoinHandler) *Query
- func (q *Query) LeftJoin(q2 *Query, field string) *Query
- func (q *Query) Limit(limitItems int) *Query
- func (q *Query) MakeCopy(db *Reindexer) *Query
- func (q *Query) Match(index string, keys ...string) *Query
- func (q *Query) Merge(q2 *Query) *Query
- func (q *Query) MustExec() *Iterator
- func (q *Query) MustExecCtx(ctx context.Context) *Iterator
- func (q *Query) Not() *Query
- func (q *Query) Offset(startOffset int) *Query
- func (q *Query) On(index string, condition int, joinIndex string) *Query
- func (q *Query) OpenBracket() *Query
- func (q *Query) Or() *Query
- func (q *Query) ReqTotal(totalNames ...string) *Query
- func (q *Query) Select(fields ...string) *Query
- func (q *Query) Set(field string, values interface{}) *Query
- func (q *Query) SetContext(ctx interface{}) *Query
- func (q *Query) SetExpression(field string, value string) *Query
- func (q *Query) SetObject(field string, values interface{}) *Query
- func (q *Query) Sort(sortIndex string, desc bool, values ...interface{}) *Query
- func (q *Query) Strict(mode QueryStrictMode) *Query
- func (q *Query) Update() *Iterator
- func (q *Query) UpdateCtx(ctx context.Context) *Iterator
- func (q *Query) Where(index string, condition int, keys interface{}) *Query
- func (q *Query) WhereBetweenFields(firstField string, condition int, secondField string) *Query
- func (q *Query) WhereBool(index string, condition int, keys ...bool) *Query
- func (q *Query) WhereComposite(index string, condition int, keys ...interface{}) *Query
- func (q *Query) WhereDouble(index string, condition int, keys ...float64) *Query
- func (q *Query) WhereInt(index string, condition int, keys ...int) *Query
- func (q *Query) WhereInt32(index string, condition int, keys ...int32) *Query
- func (q *Query) WhereInt64(index string, condition int, keys ...int64) *Query
- func (q *Query) WhereString(index string, condition int, keys ...string) *Query
- func (q *Query) WithRank() *Query
- type QueryPerfStat
- type QueryStrictMode
- type ReconnectStrategy
- type Reindexer
- func (db *Reindexer) AddIndex(namespace string, indexDef ...IndexDef) error
- func (db *Reindexer) BeginTx(namespace string) (*Tx, error)
- func (db *Reindexer) Close()
- func (db *Reindexer) CloseNamespace(namespace string) error
- func (db *Reindexer) ConfigureIndex(namespace, index string, config interface{}) error
- func (db *Reindexer) Delete(namespace string, item interface{}, precepts ...string) error
- func (db *Reindexer) DescribeNamespace(namespace string) (*NamespaceDescription, error)
- func (db *Reindexer) DescribeNamespaces() ([]*NamespaceDescription, error)
- func (db *Reindexer) DropIndex(namespace, index string) error
- func (db *Reindexer) DropNamespace(namespace string) error
- func (db *Reindexer) EnableStorage(storagePath string) error
- func (db *Reindexer) ExecSQL(query string) *Iterator
- func (db *Reindexer) ExecSQLToJSON(query string) *JSONIterator
- func (db *Reindexer) GetMeta(namespace, key string) ([]byte, error)
- func (db *Reindexer) GetNamespaceMemStat(namespace string) (*NamespaceMemStat, error)
- func (db *Reindexer) GetNamespacesMemStat() ([]*NamespaceMemStat, error)
- func (db *Reindexer) GetStats() bindings.Stats
- func (db *Reindexer) Insert(namespace string, item interface{}, precepts ...string) (int, error)
- func (db *Reindexer) MustBeginTx(namespace string) *Tx
- func (db *Reindexer) OpenNamespace(namespace string, opts *NamespaceOptions, s interface{}) (err error)
- func (db *Reindexer) Ping() error
- func (db *Reindexer) PutMeta(namespace, key string, data []byte) error
- func (db *Reindexer) Query(namespace string) *Query
- func (db *Reindexer) QueryFrom(d dsl.DSL) (*Query, error)
- func (db *Reindexer) RegisterNamespace(namespace string, opts *NamespaceOptions, s interface{}) (err error)
- func (db *Reindexer) RenameNamespace(srcNsName string, dstNsName string) error
- func (db *Reindexer) RenameNs(srcNsName string, dstNsName string)
- func (db *Reindexer) ReopenLogFiles() error
- func (db *Reindexer) ResetCaches()
- func (db *Reindexer) ResetStats()
- func (db *Reindexer) SetDefaultQueryDebug(namespace string, level int) error
- func (db *Reindexer) SetLogger(log Logger)
- func (db *Reindexer) Status() bindings.Status
- func (db *Reindexer) TruncateNamespace(namespace string) error
- func (db *Reindexer) Update(namespace string, item interface{}, precepts ...string) (int, error)
- func (db *Reindexer) UpdateIndex(namespace string, indexDef IndexDef) error
- func (db *Reindexer) Upsert(namespace string, item interface{}, precepts ...string) error
- func (db *Reindexer) WithContext(ctx context.Context) *Reindexer
- type ReplicationStat
- type ReplicationSyncStat
- type Tx
- func (tx *Tx) AwaitResults() *Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) CommitWithCount() (count int, err error)
- func (tx *Tx) Delete(item interface{}, precepts ...string) error
- func (tx *Tx) DeleteAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
- func (tx *Tx) DeleteJSON(json []byte, precepts ...string) error
- func (tx *Tx) DeleteJSONAsync(json []byte, cmpl bindings.Completion, precepts ...string) error
- func (tx *Tx) Insert(item interface{}, precepts ...string) error
- func (tx *Tx) InsertAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
- func (tx *Tx) MustCommit() int
- func (tx *Tx) Query() *Query
- func (tx *Tx) Rollback() error
- func (tx *Tx) Update(item interface{}, precepts ...string) error
- func (tx *Tx) UpdateAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
- func (tx *Tx) Upsert(item interface{}, precepts ...string) error
- func (tx *Tx) UpsertAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
- func (tx *Tx) UpsertJSON(json []byte, precepts ...string) error
- func (tx *Tx) UpsertJSONAsync(json []byte, cmpl bindings.Completion, precepts ...string) error
- type TxPerfStat
Constants ¶
const ( ConfigNamespaceName = "#config" MemstatsNamespaceName = "#memstats" NamespacesNamespaceName = "#namespaces" PerfstatsNamespaceName = "#perfstats" QueriesperfstatsNamespaceName = "#queriesperfstats" ClientsStatsNamespaceName = "#clientsstats" ReplicationStatsNamespaceName = "#replicationstats" )
const ( // Reconnect to the next node in the list ReconnectStrategyNext = ReconnectStrategy("next") // Reconnect to the random node in the list ReconnectStrategyRandom = ReconnectStrategy("random") // Reconnect to the synchnized node (which was the part of the last consensus in synchronous cluster) ReconnectStrategySynchronized = ReconnectStrategy("synchronized") // Always choose cluster's leader ReconnectStrategyPrefferWrite = ReconnectStrategy("preffer_write") // Always choose cluster's follower ReconnectStrategyReadOnly = ReconnectStrategy("read_only") // Choose follower, when it's possible. Otherwise reconnect to leader ReconnectStrategyPrefferRead = ReconnectStrategy("preffer_read") )
const ( QueryStrictModeNone = bindings.QueryStrictModeNone // Allows any fields in coditions, but doesn't check actual values for non-existing names QueryStrictModeNames = bindings.QueryStrictModeNames // Allows only valid fields and indexes in conditions. Otherwise query will return error QueryStrictModeIndexes = bindings.QueryStrictModeIndexes // Allows only indexes in conditions. Otherwise query will return error )
const ( CollateNone = bindings.CollateNone CollateASCII = bindings.CollateASCII CollateUTF8 = bindings.CollateUTF8 CollateNumeric = bindings.CollateNumeric CollateCustom = bindings.CollateCustom )
const ( // Equal '=' EQ = bindings.EQ // Greater '>' GT = bindings.GT // Lower '<' LT = bindings.LT // Greater or equal '>=' (GT|EQ) GE = bindings.GE // Lower or equal '<' LE = bindings.LE // One of set 'IN []' SET = bindings.SET // All of set ALLSET = bindings.ALLSET // In range RANGE = bindings.RANGE // Any value ANY = bindings.ANY // Empty value (usualy zero len array) EMPTY = bindings.EMPTY // String like pattern LIKE = bindings.LIKE // Geometry DWithin DWITHIN = bindings.DWITHIN )
Condition types
const ( // ERROR Log level ERROR = bindings.ERROR // WARNING Log level WARNING = bindings.WARNING // INFO Log level INFO = bindings.INFO // TRACE Log level TRACE = bindings.TRACE )
const ( AggAvg = bindings.AggAvg AggSum = bindings.AggSum AggFacet = bindings.AggFacet AggMin = bindings.AggMin AggMax = bindings.AggMax AggDistinct = bindings.AggDistinct )
Aggregation funcs
const ( ErrCodeOK = bindings.ErrOK ErrCodeParseSQL = bindings.ErrParseSQL ErrCodeQueryExec = bindings.ErrQueryExec ErrCodeParams = bindings.ErrParams ErrCodeLogic = bindings.ErrLogic ErrCodeParseJson = bindings.ErrParseJson ErrCodeParseDSL = bindings.ErrParseDSL ErrCodeConflict = bindings.ErrConflict ErrCodeParseBin = bindings.ErrParseBin ErrCodeForbidden = bindings.ErrForbidden ErrCodeWasRelock = bindings.ErrWasRelock ErrCodeNotValid = bindings.ErrNotValid ErrCodeNetwork = bindings.ErrNetwork ErrCodeNotFound = bindings.ErrNotFound ErrCodeStateInvalidated = bindings.ErrStateInvalidated ErrCodeTimeout = bindings.ErrTimeout )
Reindexer error codes
Variables ¶
var ( ErrEmptyNamespace = bindings.NewError("rq: empty namespace name", ErrCodeParams) ErrEmptyFieldName = bindings.NewError("rq: empty field name in filter", ErrCodeParams) ErrEmptyAggFieldName = bindings.NewError("rq: empty field name in aggregation", ErrCodeParams) ErrCondType = bindings.NewError("rq: cond type not found", ErrCodeParams) ErrOpInvalid = bindings.NewError("rq: op is invalid", ErrCodeParams) ErrAggInvalid = bindings.NewError("rq: agg is invalid", ErrCodeParams) ErrNoPK = bindings.NewError("rq: No pk field in struct", ErrCodeParams) ErrWrongType = bindings.NewError("rq: Wrong type of item", ErrCodeParams) ErrMustBePointer = bindings.NewError("rq: Argument must be a pointer to element, not element", ErrCodeParams) ErrNotFound = bindings.NewError("rq: Not found", ErrCodeNotFound) ErrDeepCopyType = bindings.NewError("rq: DeepCopy() returns wrong type", ErrCodeParams) )
Functions ¶
func CreateInt64FromLSN ¶
func GetCondType ¶
func WithAppName ¶
func WithAppName(appName string) interface{}
func WithCgoLimit ¶ added in v1.9.3
func WithCgoLimit(cgoLimit int) interface{}
func WithConnPoolSize ¶ added in v1.9.3
func WithConnPoolSize(connPoolSize int) interface{}
func WithCreateDBIfMissing ¶
func WithCreateDBIfMissing() interface{}
func WithDedicatedServerThreads ¶
func WithDedicatedServerThreads() interface{}
func WithNetCompression ¶
func WithNetCompression() interface{}
func WithReconnectionStrategy ¶
func WithReconnectionStrategy(strategy ReconnectStrategy, allowUnknownNodes bool) interface{}
WithReconnectionStrategy allows to configure the behavior during reconnect after error. Strategy used for reconnect to server on connection error AllowUnknownNodes allows to add dsn from cluster node, that was not set in client dsn list Warning: you should not mix async and sync nodes' DSNs in initial DSNs' list, unless you really know what you are doing
func WithRetryAttempts ¶ added in v1.9.5
func WithServerConfig ¶ added in v1.9.6
func WithServerConfig(startupTimeout time.Duration, serverConfig *config.ServerConfig) interface{}
Types ¶
type AggregateFacetRequest ¶
type AggregateFacetRequest struct {
// contains filtered or unexported fields
}
func (*AggregateFacetRequest) Limit ¶
func (r *AggregateFacetRequest) Limit(limit int) *AggregateFacetRequest
func (*AggregateFacetRequest) Offset ¶
func (r *AggregateFacetRequest) Offset(offset int) *AggregateFacetRequest
func (*AggregateFacetRequest) Sort ¶
func (r *AggregateFacetRequest) Sort(field string, desc bool) *AggregateFacetRequest
Use field 'count' to sort by facet's count value.
type AggregationResult ¶ added in v1.10.0
type CacheMemStat ¶
type CacheMemStat struct {
// Total memory consumption by this cache
TotalSize int64 `json:"total_size"`
// Count of used elements stored in this cache
ItemsCount int64 `json:"items_count"`
// Count of empty elements slots in this cache
EmptyCount int64 `json:"empty_count"`
// Number of hits of queries, to store results in cache
HitCountLimit int64 `json:"hit_count_limit"`
}
CacheMemStat information about reindexer's cache memory consumption
type ClientConnectionStat ¶
type ClientConnectionStat struct {
// Connection identifier
ConnectionId int64 `json:"connection_id"`
// client ip address
Ip string `json:"ip"`
// User name
UserName string `json:"user_name"`
// User right
UserRights string `json:"user_rights"`
// Database name
DbName string `json:"db_name"`
// Current activity
CurrentActivity string `json:"current_activity"`
// Server start time in unix timestamp
StartTime int64 `json:"start_time"`
// Receive bytes
RecvBytes int64 `json:"recv_bytes"`
// Sent bytes
SentBytes int64 `json:"sent_bytes"`
// Client version string
ClientVersion string `json:"client_version"`
// Send buffer size
SendBufBytes int64 `json:"send_buf_bytes"`
// Timestamp of last send operation (ms)
LastSendTs int64 `json:"last_send_ts"`
// Timestamp of last recv operation (ms)
LastRecvTs int64 `json:"last_recv_ts"`
// Current send rate (bytes/s)
SendRate int `json:"send_rate"`
// Current recv rate (bytes/s)
RecvRate int `json:"recv_rate"`
// Active transactions count
TxCount int `json:"tx_count"`
}
ClientConnectionStat is information about client connection
type DBAsyncReplicationConfig ¶
type DBAsyncReplicationConfig struct {
// Replication role. One of: none, leader, follower
Role string `json:"role"`
// Replication mode for mixed 'sync cluster + async replication' configs. One of: default, from_sync_leader
ReplicationMode string `json:"replication_mode"`
// force resync on logic error conditions
ForceSyncOnLogicError bool `json:"force_sync_on_logic_error"`
// force resync on wrong data hash conditions
ForceSyncOnWrongDataHash bool `json:"force_sync_on_wrong_data_hash"`
// Network timeout for online updates (s)
UpdatesTimeout int `json:"online_updates_timeout_sec"`
// Network timeout for wal/force syncs (s)
SyncTimeout int `json:"sync_timeout_sec"`
// Number of parallel replication threads
SyncThreads int `json:"sync_threads"`
// Max number of concurrent force/wal syncs per replication thread
ConcurrentSyncsPerThread int `json:"syncs_per_thread"`
// Number of coroutines for online-updates batching (per each namespace of each node)
BatchingReoutines int `json:"batching_routines_count"`
// Enable compression for replication network operations
EnableCompression bool `json:"enable_compression"`
// List of namespaces for replication. If emply, all namespaces. All replicated namespaces will become read only for slave
Namespaces []string `json:"namespaces"`
// Reconnect interval after replication error (ms)
RetrySyncInterval int `json:"retry_sync_interval_msec"`
// List of follower-nodes for async replication
Nodes []DBAsyncReplicationNode `json:"nodes"`
}
DBAsyncReplicationConfig is part of reindexer configuration contains async replication options
type DBAsyncReplicationNode ¶
type DBAsyncReplicationNode struct {
// Node's DSN. It must to have cproto format (e.g. 'cproto://<ip>:<port>/<db>')
DSN string `json:"dsn"`
// List of namespaces to replicate on this specific node. If nil, list from main replication config will be used
Namespaces []string `json:"namespaces"`
}
DBAsyncReplicationNode
type DBConfigItem ¶ added in v1.9.3
type DBConfigItem struct {
Type string `json:"type"`
Profiling *DBProfilingConfig `json:"profiling,omitempty"`
Namespaces *[]DBNamespacesConfig `json:"namespaces,omitempty"`
Replication *DBReplicationConfig `json:"replication,omitempty"`
AsyncReplication *DBAsyncReplicationConfig `json:"async_replication,omitempty"`
}
DBConfigItem is structure stored in system '#config` namespace
type DBNamespacesConfig ¶
type DBNamespacesConfig struct {
// Name of namespace, or `*` for setting to all namespaces
Namespace string `json:"namespace"`
// Log level of queries core logger
LogLevel string `json:"log_level"`
// Join cache mode. Can be one of on, off, aggressive
JoinCacheMode string `json:"join_cache_mode"`
// Enable namespace lazy load (namespace shoud be loaded from disk on first call, not at reindexer startup)
Lazyload bool `json:"lazyload"`
// Unload namespace data from RAM after this idle timeout in seconds. If 0, then data should not be unloaded
UnloadIdleThreshold int `json:"unload_idle_threshold"`
// Enable namespace copying for transaction with steps count greater than this value (if copy_politics_multiplier also allows this)
StartCopyPolicyTxSize int `json:"start_copy_policy_tx_size"`
// Disables copy policy if namespace size is greater than copy_policy_multiplier * start_copy_policy_tx_size
CopyPolicyMultiplier int `json:"copy_policy_multiplier"`
// Force namespace copying for transaction with steps count greater than this value
TxSizeToAlwaysCopy int `json:"tx_size_to_always_copy"`
// Timeout before background indexes optimization start after last update. 0 - disable optimizations
OptimizationTimeout int `json:"optimization_timeout_ms"`
// Maximum number of background threads of sort indexes optimization. 0 - disable sort optimizations
OptimizationSortWorkers int `json:"optimization_sort_workers"`
// Maximum WAL size for this namespace (maximum count of WAL records)
WALSize int64 `json:"wal_size"`
// Minimum preselect size for optimization of inner join by injection of filters. It is using if (MaxPreselectPart * ns.size) is less than this value
MinPreselectSize int64 `json:"min_preselect_size"`
// Maximum preselect size for optimization of inner join by injection of filters
MaxPreselectSize int64 `json:"max_preselect_size"`
// Maximum preselect part of namespace's items for optimization of inner join by injection of filters
MaxPreselectPart float64 `json:"max_preselect_part"`
// Enables 'simple counting mode' for index updates tracker. This will increase index optimization time, however may reduce insertion time
IndexUpdatesCountingMode bool `json:"index_updates_counting_mode"`
// Enables synchronous storage flush inside write-calls, if async updates count is more than SyncStorageFlushLimit
// 0 - disables synchronous storage flush (default). In this case storage will be flushed in background thread only
SyncStorageFlushLimit int `json:"sync_storage_flush_limit"`
}
DBNamespacesConfig is part of reindexer configuration contains namespaces options
type DBProfilingConfig ¶ added in v1.9.3
type DBProfilingConfig struct {
// Minimum query execution time to be recoreded in #queriesperfstats namespace
QueriesThresholdUS int `json:"queries_threshold_us"`
// Enables tracking memory statistics
MemStats bool `json:"memstats"`
// Enables tracking overal perofrmance statistics
PerfStats bool `json:"perfstats"`
// Enables recording of queries perofrmance statistics
QueriesPerfStats bool `json:"queriesperfstats"`
// Enables recording of activity statistics into #activitystats namespace
ActivityStats bool `json:"activitystats"`
}
DBProfilingConfig is part of reindexer configuration contains profiling options
type DBReplicationConfig ¶
type DBReplicationConfig struct {
// Server ID - must be unique for each node (available values: 0-999)
ServerID int `json:"server_id"`
// Cluster ID - must be same for client and for master
ClusterID int `json:"cluster_id"`
}
DBReplicationConfig is part of reindexer configuration contains general node settings for replication
type ExplainResults ¶ added in v1.10.0
type ExplainResults struct {
// Total query execution time
TotalUs int `json:"total_us"`
// Query prepare and optimize time
PrepareUs int `json:"prepare_us"`
// Indexes keys selection time
IndexesUs int `json:"indexes_us"`
// Query post process time
PostprocessUS int `json:"postprocess_us"`
// Intersection loop time
LoopUs int `json:"loop_us"`
// Index, which used for sort results
SortIndex string `json:"sort_index"`
// General sort time
GeneralSortUs int `json:"general_sort_us"`
// Optimization of sort by uncompleted index has been performed
SortByUncommittedIndex bool `json:"sort_by_uncommitted_index"`
// Filter selectors, used to proccess query conditions
Selectors []ExplainSelector `json:"selectors"`
}
ExplainResults presents query plan
type ExplainSelector ¶
type ExplainSelector struct {
// Field or index name
Field string `json:"field"`
// Method, used to process condition
Method string `json:"method"`
// Number of uniq keys, processed by this selector (may be incorrect, in case of internal query optimization/caching
Keys int `json:"keys"`
// Count of comparators used, for this selector
Comparators int `json:"comparators"`
// Cost expectation of this selector
Cost float64 `json:"cost"`
// Count of processed documents, matched this selector
Matched int `json:"matched"`
// Count of scanned documents by this selector
Items int `json:"items"`
// Preselect in joined namespace execution explainings
ExplainPreselect *ExplainResults `json:"explain_preselect,omitempty"`
// One of selects in joined namespace execution explainings
ExplainSelect *ExplainResults `json:"explain_select,omitempty"`
Selectors []ExplainSelector `json:"selectors,omitempty"`
}
type FtFastConfig ¶
type FtFastConfig struct {
// boost of bm25 ranking. default value 1.
Bm25Boost float64 `json:"bm25_boost"`
// weight of bm25 rank in final rank.
// 0: bm25 will not change final rank.
// 1: bm25 will affect to final rank in 0 - 100% range
Bm25Weight float64 `json:"bm25_weight"`
// boost of search query term distance in found document. default vaule 1
DistanceBoost float64 `json:"distance_boost"`
// weight of search query terms distance in found document in final rank.
// 0: distance will not change final rank.
// 1: distance will affect to final rank in 0 - 100% range
DistanceWeight float64 `json:"distance_weight"`
// boost of search query term length. default value 1
TermLenBoost float64 `json:"term_len_boost"`
// weight of search query term length in final rank.
// 0: term length will not change final rank.
// 1: term length will affect to final rank in 0 - 100% range
TermLenWeight float64 `json:"term_len_weight"`
// boost of search query term position. default value 1
PositionBoost float64 `json:"position_boost"`
// weight of search query term position in final rank.
// 0: term position will not change final rank.
// 1: term position will affect to final rank in 0 - 100% range
PositionWeight float64 `json:"position_weight"`
// Boost of full match of search phrase with doc
FullMatchBoost float64 `json:"full_match_boost"`
// Relevancy step of partial match: relevancy = kFullMatchProc - partialMatchDecrease * (non matched symbols) / (matched symbols)
// For example: partialMatchDecrease: 15, word in index 'terminator', pattern 'termin'. matched: 6 symbols, unmatched: 4. relevancy = 100 - (15*4)/6 = 80
PartialMatchDecrease int `json:"partial_match_decrease"`
// Minimum rank of found documents
MinRelevancy float64 `json:"min_relevancy"`
// Maximum possible typos in word.
// 0: typos is disabled, words with typos will not match
// N: words with N possible typos will match
// It is not recommended to set more than 2 possible typo: It will serously increase RAM usage, and decrease search speed
MaxTypos int `json:"max_typos"`
// Maximum word length for building and matching variants with typos. Default value is 15
MaxTypoLen int `json:"max_typo_len"`
// Maximum commit steps - set it 1 for always full rebuild - it can be from 1 to 500
MaxRebuildSteps int `json:"max_rebuild_steps"`
// Maximum words in one commit - it can be from 5 to DOUBLE_MAX
MaxStepSize int `json:"max_step_size"`
// Maximum documents which will be processed in merge query results
// Default value is 20000. Increasing this value may refine ranking
// of queries with high frequency words
MergeLimit int `json:"merge_limit"`
// List of used stemmers
Stemmers []string `json:"stemmers"`
// Enable translit variants processing
EnableTranslit bool `json:"enable_translit"`
// Enable wrong keyboard layout variants processing
EnableKbLayout bool `json:"enable_kb_layout"`
// List of stop words. Words from this list will be ignored in documents and queries
StopWords []string `json:"stop_words"`
// List of synonyms for replacement
Synonyms []struct {
// List source tokens in query, which will be replaced with alternatives
Tokens []string `json:"tokens"`
// List of alternatives, which will be used for search documents
Alternatives []string `json:"alternatives"`
} `json:"synonyms"`
// Log level of full text search engine
LogLevel int `json:"log_level"`
// Enable search by numbers as words and backwards
EnableNumbersSearch bool `json:"enable_numbers_search"`
// Enable auto index warmup after atomic namespace copy on transaction
EnableWarmupOnNsCopy bool `json:"enable_warmup_on_ns_copy"`
// Extra symbols, which will be threated as parts of word to addition to letters and digits
ExtraWordSymbols string `json:"extra_word_symbols"`
// Ratio of summation of ranks of match one term in several fields
SumRanksByFieldsRatio float64 `json:"sum_ranks_by_fields_ratio"`
// Max number of highlighted areas for each field in each document (for snippet() and highlight()). '-1' means unlimited
MaxAreasInDoc int `json:"max_areas_in_doc"`
// Max total number of highlighted areas in ft result, when result still remains cacheable. '-1' means unlimited
MaxTotalAreasToCache int `json:"max_total_areas_to_cache"`
// Configuration for certain field
FieldsCfg []FtFastFieldConfig `json:"fields,omitempty"`
// Optimize the index by memory or by cpu
Optimization string `json:"optimization,omitempty"`
// Enable to execute others queries before the ft query
EnablePreselectBeforeFt bool `json:"enable_preselect_before_ft"`
}
FtFastConfig configurarion of FullText search index
func DefaultFtFastConfig ¶
func DefaultFtFastConfig() FtFastConfig
type FtFastFieldConfig ¶
type FtFastFieldConfig struct {
FieldName string `json:"field_name"`
// boost of bm25 ranking. default value 1.
Bm25Boost float64 `json:"bm25_boost"`
// weight of bm25 rank in final rank.
// 0: bm25 will not change final rank.
// 1: bm25 will affect to final rank in 0 - 100% range
Bm25Weight float64 `json:"bm25_weight"`
// boost of search query term length. default value 1
TermLenBoost float64 `json:"term_len_boost"`
// weight of search query term length in final rank.
// 0: term length will not change final rank.
// 1: term length will affect to final rank in 0 - 100% range
TermLenWeight float64 `json:"term_len_weight"`
// boost of search query term position. default value 1
PositionBoost float64 `json:"position_boost"`
// weight of search query term position in final rank.
// 0: term position will not change final rank.
// 1: term position will affect to final rank in 0 - 100% range
PositionWeight float64 `json:"position_weight"`
}
func DefaultFtFastFieldConfig ¶
func DefaultFtFastFieldConfig(fieldName string) FtFastFieldConfig
type FtFuzzyConfig ¶
type FtFuzzyConfig struct {
// max proc geting from src reqest
MaxSrcProc float64 `json:"max_src_proc"`
// max proc geting from dst reqest
//usualy maxDstProc = 100 -MaxSrcProc but it's not nessary
MaxDstProc float64 `json:"max_dst_proc"`
// increse proc when found pos that are near between source and dst string (0.0001-2)
PosSourceBoost float64 `json:"pos_source_boost"`
// Minim coof for pos that are neaer in src and dst (0.0001-2)
PosSourceDistMin float64 `json:"pos_source_dist_min"`
// increse proc when found pos that are near in source string (0.0001-2)
PosSourceDistBoost float64 `json:"pos_source_dist_boost"`
// increse proc when found pos that are near in dst string (0.0001-2)
PosDstBoost float64 `json:"pos_dst_boost"`
// decrese proc when found not full thregramm - only start and end (0.0001-2)
StartDecreeseBoost float64 `json:"start_decreese_boost"`
// base decrese proc when found not full thregramm - only start and end (0.0001-2)
StartDefaultDecreese float64 `json:"start_default_decreese"`
// Min relevance to show reqest
MinOkProc float64 `json:"min_ok_proc"`
// size of gramm (1-10)- for example
//terminator BufferSize=3 __t _te ter erm rmi ...
//terminator BufferSize=4 __te _ter term ermi rmin
BufferSize int `json:"buffer_size"`
// size of space in start and end of gramm (0-9) - for example
//terminator SpaceSize=2 __t _te ter ... tor or_ r__
//terminator SpaceSize=1 _te ter ... tor or_
SpaceSize int `json:"space_size"`
// Maximum documents which will be processed in merge query results
// Default value is 20000. Increasing this value may refine ranking
// of queries with high frequency words
MergeLimit int `json:"merge_limit"`
// List of used stemmers
Stemmers []string `json:"stemmers"`
// Enable translit variants processing
EnableTranslit bool `json:"enable_translit"`
// Enable wrong keyboard layout variants processing
EnableKbLayout bool `json:"enable_kb_layout"`
// List of stop words. Words from this list will be ignored in documents and queries
StopWords []string `json:"stop_words"`
// Log level of full text search engine
LogLevel int `json:"log_level"`
// Extra symbols, which will be threated as parts of word to addition to letters and digits
ExtraWordSymbols string `json:"extra_word_symbols"`
}
FtFuzzyConfig configurarion of FuzzyFullText search index
func DefaultFtFuzzyConfig ¶
func DefaultFtFuzzyConfig() FtFuzzyConfig
type IndexDescription ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator presents query results
func (*Iterator) AggResults ¶
func (it *Iterator) AggResults() (v []AggregationResult)
AggResults returns aggregation results (if present)
func (*Iterator) AllowUnsafe ¶
AllowUnsafe takes bool, that enable or disable unsafe behavior.
When AllowUnsafe is true and object cache is enabled resulting objects will not be copied for each query. That means possible race conditions. But it's good speedup, without overhead for copying.
By default reindexer guarantees that every object its safe to use in multithread.
func (*Iterator) Close ¶
func (it *Iterator) Close()
Close closes the iterator and freed CGO resources
func (*Iterator) FetchAll ¶
FetchAll returns all query results as slice []interface{} and closes the iterator.
func (*Iterator) FetchAllWithRank ¶
FetchAllWithRank returns resulting slice of objects and slice of objects ranks. Closes iterator after use.
func (*Iterator) FetchOne ¶
FetchOne returns first element and closes the iterator. When it's impossible (count is 0) err will be ErrNotFound.
func (*Iterator) GetAggreatedValue ¶
GetAggreatedValue - Return aggregation sum of field
func (*Iterator) GetExplainResults ¶ added in v1.10.0
func (it *Iterator) GetExplainResults() (*ExplainResults, error)
GetExplainResults returns JSON bytes with explain results
func (*Iterator) GetTagsMatcherInfo ¶
Get namespace's tagsmatcher info
func (*Iterator) JoinedObjects ¶
JoinedObjects returns objects slice, that result of join for the given field
func (*Iterator) NextObj ¶
Next moves iterator pointer to the next element. Returns bool, that indicates the availability of the next elements. Decode result to given struct
func (*Iterator) Object ¶
func (it *Iterator) Object() interface{}
Object returns current object. Will panic when pointer was not moved, Next() must be called before.
func (*Iterator) Rank ¶
Rank returns current object search rank. Will panic when pointer was not moved, Next() must be called before.
func (*Iterator) TotalCount ¶
TotalCount returns total count of objects (ignoring conditions of limit and offset)
type JSONIterator ¶
type JSONIterator struct {
// contains filtered or unexported fields
}
JSONIterator its iterator, but results presents as json documents
func (*JSONIterator) Count ¶
func (it *JSONIterator) Count() int
Count returns count if query results
func (*JSONIterator) Error ¶
func (it *JSONIterator) Error() error
Error returns query error if it's present.
func (*JSONIterator) FetchAll ¶
func (it *JSONIterator) FetchAll() (json []byte, err error)
FetchAll returns bytes slice it's JSON array with results
func (*JSONIterator) GetExplainResults ¶ added in v1.10.0
func (it *JSONIterator) GetExplainResults() (*ExplainResults, error)
GetExplainResults returns JSON bytes with explain results
func (*JSONIterator) JSON ¶
func (it *JSONIterator) JSON() (json []byte)
JSON returns JSON bytes with current document
func (*JSONIterator) Next ¶
func (it *JSONIterator) Next() bool
Next moves iterator pointer to the next element. Returns bool, that indicates the availability of the next elements.
type JoinHandler ¶
type JoinHandler func(field string, item interface{}, subitems []interface{}) (useAutomaticJoinStrategy bool)
JoinHandler it's function for handle join results. Returns bool, that indicates whether automatic join strategy still needs to be applied. If `useAutomaticJoinStrategy` is false - it means that JoinHandler takes full responsibility of performing join. If `useAutomaticJoinStrategy` is true - it means JoinHandler will perform only part of the work, required during join, the rest will be done using automatic join strategy. Automatic join strategy is defined as: - use Join method to perform join (in case item implements Joinable interface) - use reflection to perform join otherwise
type Joinable ¶
type Joinable interface {
Join(field string, subitems []interface{}, context interface{})
}
Joinable is an interface for append joined items
type LsnT ¶
type LsnT struct {
// Operation counter
Counter int64 `json:"counter"`
// Node identifyer
ServerId int `json:"server_id"`
}
Operation counter and server id
func CreateLSNFromInt64 ¶
func (*LsnT) IsCompatibleWith ¶
func (*LsnT) IsNewerThen ¶
type NamespaceDescription ¶
type NamespaceDescription struct {
Name string `json:"name"`
Indexes []IndexDescription `json:"indexes"`
StorageEnabled bool `json:"storage_enabled"`
}
type NamespaceMemStat ¶ added in v1.9.3
type NamespaceMemStat struct {
// Name of namespace
Name string `json:"name"`
// [[deperecated]]. do not use
StorageError string `json:"storage_error"`
// Filesystem path to namespace storage
StoragePath string `json:"storage_path"`
// Status of disk storage
StorageOK bool `json:"storage_ok"`
// Background indexes optimization has been completed
OptimizationCompleted bool `json:"optimization_completed"`
// Total count of documents in namespace
ItemsCount int64 `json:"items_count,omitempty"`
// Count of emopy(unused) slots in namespace
EmptyItemsCount int64 `json:"empty_items_count"`
// Size of strings deleted from namespace, but still used in queryResults
StringsWaitingToBeDeletedSize int64 `json:"strings_waiting_to_be_deleted_size"`
// Summary of total namespace memory consumption
Total struct {
// Total memory size of stored documents, including system structures
DataSize int64 `json:"data_size"`
// Total memory consumption of namespace's indexes
IndexesSize int64 `json:"indexes_size"`
// Total memory consumption of namespace's caches. e.g. idset and join caches
CacheSize int64 `json:"cache_size"`
// Total memory size, occupated by index optimizer (in bytes)
IndexOptimizerMemory int64 `json:"index_optimizer_memory"`
} `json:"total"`
// Replication status of namespace
Replication struct {
// Last Log Sequence Number (LSN) of applied namespace modification
LastLSN LsnT `json:"last_lsn_v2"`
// Namespace version counter
NSVersion LsnT `json:"ns_version"`
// Temporary namespace flag
Temporary bool `json:"temporary"`
// Number of storage's master <-> slave switches
IncarnationCounter int64 `json:"incarnation_counter"`
// Hashsum of all records in namespace
DataHash uint64 `json:"data_hash"`
// Data count
DataCount int `json:"data_count"`
// Write Ahead Log (WAL) records count
WalCount int64 `json:"wal_count"`
// Total memory consumption of Write Ahead Log (WAL)
WalSize int64 `json:"wal_size"`
// Data updated timestamp
UpdatedUnixNano int64 `json:"updated_unix_nano"`
// Cluster info
ClusterizationStatus struct {
// Current leader server ID (for RAFT-cluster only)
LeadeID int `json:"leader_id"`
// Current role in cluster: cluster_replica, simple_replica or none
Role string `json:"role"`
} `json:"clusterization_status"`
} `json:"replication"`
// Indexes memory statistic
Indexes []struct {
// Name of index. There are special index with name `-tuple`. It's stores original document's json structure with non indexe fields
Name string `json:"name"`
// Count of unique keys values stored in index
UniqKeysCount int64 `json:"unique_keys_count"`
// Total memory consumption of documents's data, holded by index
DataSize int64 `json:"data_size"`
// Total memory consumption of SORT statement and `GT`, `LT` conditions optimized structures. Applicabe only to `tree` indexes
SortOrdresSize int64 `json:"sort_orders_size"`
// Total memory consumption of reverse index vectors. For `store` ndexes always 0
IDSetPlainSize int64 `json:"idset_plain_size"`
// Total memory consumption of reverse index b-tree structures. For `dense` and `store` indexes always 0
IDSetBTreeSize int64 `json:"idset_btree_size"`
// Total memory consumption of fulltext search structures
FulltextSize int64 `json:"fulltext_size"`
// Idset cache stats. Stores merged reverse index results of SELECT field IN(...) by IN(...) keys
IDSetCache CacheMemStat `json:"idset_cache"`
// Updates count, pending in index updates tracker
TrackedUpdatesCount int64 `json:"tracked_updates_count"`
// Buckets count in index updates tracker map
TrackedUpdatesBuckets int64 `json:"tracked_updates_buckets"`
// Updates tracker map size in bytes
TrackedUpdatesSize int64 `json:"tracked_updates_size"`
} `json:"indexes"`
// Join cache stats. Stores results of selects to right table by ON condition
JoinCache CacheMemStat `json:"join_cache"`
// Query cache stats. Stores results of SELECT COUNT(*) by Where conditions
QueryCache CacheMemStat `json:"query_cache"`
}
NamespaceMemStat information about reindexer's namespace memory statisctics and located in '#memstats' system namespace
type NamespaceOptions ¶
type NamespaceOptions struct {
// contains filtered or unexported fields
}
NamespaceOptions is options for namespace
func DefaultNamespaceOptions ¶
func DefaultNamespaceOptions() *NamespaceOptions
DefaultNamespaceOptions return default namespace options
func (*NamespaceOptions) DisableObjCache ¶
func (opts *NamespaceOptions) DisableObjCache() *NamespaceOptions
func (*NamespaceOptions) DropOnFileFormatError ¶
func (opts *NamespaceOptions) DropOnFileFormatError() *NamespaceOptions
func (*NamespaceOptions) DropOnIndexesConflict ¶
func (opts *NamespaceOptions) DropOnIndexesConflict() *NamespaceOptions
func (*NamespaceOptions) NoStorage ¶
func (opts *NamespaceOptions) NoStorage() *NamespaceOptions
func (*NamespaceOptions) ObjCacheSize ¶
func (opts *NamespaceOptions) ObjCacheSize(count int) *NamespaceOptions
Set maximum items count in Object Cache. Default is 256000
type NamespacePerfStat ¶ added in v1.9.3
type NamespacePerfStat struct {
// Name of namespace
Name string `json:"name"`
// Performance statistics for update operations
Updates PerfStat `json:"updates"`
// Performance statistics for select operations
Selects PerfStat `json:"selects"`
// Performance statistics for transactions
Transactions TxPerfStat `json:"transactions"`
}
NamespacePerfStat is information about namespace's performance statistics and located in '#perfstats' system namespace
type PerfStat ¶ added in v1.9.3
type PerfStat struct {
// Total count of queries to this object
TotalQueriesCount int64 `json:"total_queries_count"`
// Average latency (execution time) for queries to this object
TotalAvgLatencyUs int64 `json:"total_avg_latency_us"`
// Average waiting time for acquiring lock to this object
TotalAvgLockTimeUs int64 `json:"total_avg_lock_time_us"`
// Count of queries to this object, requested at last second
LastSecQPS int64 `json:"last_sec_qps"`
// Average latency (execution time) for queries to this object at last second
LastSecAvgLatencyUs int64 `json:"last_sec_avg_latency_us"`
// Average waiting time for acquiring lock to this object at last second
LastSecAvgLockTimeUs int64 `json:"last_sec_avg_lock_time_us"`
// Minimal latency value
MinLatencyUs int64 `json:"min_latency_us"`
// Maximum latency value
MaxLatencyUs int64 `json:"max_latency_us"`
// Standard deviation of latency values
LatencyStddev int64 `json:"latency_stddev"`
}
PerfStat is information about different reinexer's objects performance statistics
type Query ¶
type Query struct {
Namespace string
// contains filtered or unexported fields
}
Query to DB object
func (*Query) AggregateAvg ¶
func (*Query) AggregateFacet ¶
func (q *Query) AggregateFacet(fields ...string) *AggregateFacetRequest
fields should not be empty.
func (*Query) AggregateMax ¶
func (*Query) AggregateMin ¶
func (*Query) AggregateSum ¶
func (*Query) CachedTotal ¶
CachedTotal Request cached total items calculation
func (*Query) CloseBracket ¶
CloseBracket - Close bracket for where condition to DB query
func (*Query) Delete ¶
Delete will execute query, and delete items, matches query On sucess return number of deleted elements
func (*Query) DeleteCtx ¶
DeleteCtx will execute query, and delete items, matches query On sucess return number of deleted elements
func (*Query) EqualPosition ¶ added in v1.10.0
Adds equal position fields to arrays
func (*Query) ExecToJson ¶
func (q *Query) ExecToJson(jsonRoots ...string) *JSONIterator
ExecToJson will execute query, and return iterator
func (*Query) ExecToJsonCtx ¶
func (q *Query) ExecToJsonCtx(ctx context.Context, jsonRoots ...string) *JSONIterator
ExecToJsonCtx will execute query, and return iterator
func (*Query) FetchCount ¶ added in v1.5.0
FetchCount sets the number of items that will be fetched by one operation When n <= 0 query will fetch all results in one operation
func (*Query) Functions ¶ added in v1.9.2
Functions add optional select functions (e.g highlight or snippet ) to fields of result's objects
func (*Query) GetJsonCtx ¶
GetJsonCtx will execute query, and return 1 st item, panic on error
func (*Query) InnerJoin ¶
InnerJoin joins 2 queries Items from the 1-st query are filtered by and expanded with the data from the 2-nd query
`field` parameter serves as unique identifier for the join between `q` and `q2` One of the conditions below must hold for `field` parameter in order for InnerJoin to work: - namespace of `q2` contains `field` as one of its fields marked as `joined` - `q` has a join handler (registered via `q.JoinHandler(...)` call) with the same `field` value
func (*Query) JoinHandler ¶
func (q *Query) JoinHandler(field string, handler JoinHandler) *Query
JoinHandler registers join handler that will be called when join, registered on `field` value, finds a match
func (*Query) LeftJoin ¶
LeftJoin joins 2 queries Items from the 1-st query are expanded with the data from the 2-nd query
`field` parameter serves as unique identifier for the join between `q` and `q2` One of the conditions below must hold for `field` parameter in order for LeftJoin to work: - namespace of `q2` contains `field` as one of its fields marked as `joined` - `q` has a join handler (registered via `q.JoinHandler(...)` call) with the same `field` value
func (*Query) MustExecCtx ¶
MustExecCtx will execute query, and return iterator, panic on error
func (*Query) Not ¶
Not - next condition will added with NOT AND Implements short-circuiting: if the previous condition is failed the next will not be evaluated
func (*Query) On ¶
On specifies join condition
`index` parameter specifies which field from `q` namespace should be used during join `condition` parameter specifies how `q` will be joined with the latest join query issued on `q` (e.g. `EQ`/`GT`/`SET`/...) `joinIndex` parameter specifies which field from namespace for the latest join query issued on `q` should be used during join
func (*Query) OpenBracket ¶
OpenBracket - Open bracket for where condition to DB query
func (*Query) Or ¶
OR - next condition will added with OR Implements short-circuiting: if the previous condition is successful the next will not be evaluated, but except Join conditions
func (*Query) SetContext ¶
SetContext set interface, which will be passed to Joined interface
func (*Query) SetExpression ¶
SetExpression updates indexed field by arithmetical expression
func (*Query) Sort ¶
Sort - Apply sort order to returned from query items If values argument specified, then items equal to values, if found will be placed in the top positions For composite indexes values must be []interface{}, with value of each subindex Forced sort is support for the first sorting field only
func (*Query) Strict ¶
func (q *Query) Strict(mode QueryStrictMode) *Query
Strict - Set query strict mode
func (*Query) Update ¶
Update will execute query, and update fields in items, which matches query On sucess return number of update elements
func (*Query) UpdateCtx ¶
UpdateCtx will execute query, and update fields in items, which matches query On sucess return number of update elements
func (*Query) Where ¶
Where - Add where condition to DB query For composite indexes keys must be []interface{}, with value of each subindex
func (*Query) WhereBetweenFields ¶
Where - Add comparing two fields where condition to DB query For composite indexes keys must be []interface{}, with value of each subindex
func (*Query) WhereComposite ¶ added in v1.9.2
WhereComposite - Add where condition to DB query with interface args for composite indexes
func (*Query) WhereDouble ¶
WhereDouble - Add where condition to DB query with float args
func (*Query) WhereInt32 ¶ added in v1.10.0
WhereInt - Add where condition to DB query with int args
func (*Query) WhereInt64 ¶
WhereInt64 - Add where condition to DB query with int64 args
func (*Query) WhereString ¶
WhereString - Add where condition to DB query with string args
type QueryPerfStat ¶ added in v1.9.3
QueryPerfStat is information about query's performance statistics and located in '#queriesperfstats' system namespace
type ReconnectStrategy ¶
type ReconnectStrategy string
type Reindexer ¶
type Reindexer struct {
// contains filtered or unexported fields
}
Reindexer The reindxer state struct
func NewReindex ¶
func NewReindex(dsn interface{}, options ...interface{}) *Reindexer
NewReindex Create new instanse of Reindexer DB Returns pointer to created instance
func (*Reindexer) CloseNamespace ¶
CloseNamespace - close namespace, but keep storage
func (*Reindexer) ConfigureIndex ¶
ConfigureIndex - congigure index. config argument must be struct with index configuration Deprecated: Use UpdateIndex instead.
func (*Reindexer) Delete ¶
Delete - remove single item from namespace by PK Item must be the same type as item passed to OpenNamespace, or []byte with json data If the precepts are provided and the item is a pointer, the value pointed by item will be updated
func (*Reindexer) DescribeNamespace ¶
func (db *Reindexer) DescribeNamespace(namespace string) (*NamespaceDescription, error)
DescribeNamespace makes a 'SELECT * FROM #namespaces' query to database. Return NamespaceDescription results, error
func (*Reindexer) DescribeNamespaces ¶
func (db *Reindexer) DescribeNamespaces() ([]*NamespaceDescription, error)
DescribeNamespaces makes a 'SELECT * FROM #namespaces' query to database. Return NamespaceDescription results, error
func (*Reindexer) DropNamespace ¶
DropNamespace - drop whole namespace from DB
func (*Reindexer) EnableStorage ¶
EnableStorage enables persistent storage of data Deprecated: storage path should be passed as DSN part to reindexer.NewReindex (""), e.g. reindexer.NewReindexer ("builtin:///tmp/reindex").
func (*Reindexer) ExecSQL ¶
ExecSQL make query to database. Query is a SQL statement. Return Iterator.
func (*Reindexer) ExecSQLToJSON ¶
func (db *Reindexer) ExecSQLToJSON(query string) *JSONIterator
ExecSQLToJSON make query to database. Query is a SQL statement. Return JSONIterator.
func (*Reindexer) GetNamespaceMemStat ¶ added in v1.9.3
func (db *Reindexer) GetNamespaceMemStat(namespace string) (*NamespaceMemStat, error)
GetNamespaceMemStat makes a 'SELECT * FROM #memstat' query to database. Return NamespaceMemStat results, error
func (*Reindexer) GetNamespacesMemStat ¶ added in v1.9.3
func (db *Reindexer) GetNamespacesMemStat() ([]*NamespaceMemStat, error)
GetNamespacesMemStat makes a 'SELECT * FROM #memstats' query to database. Return NamespaceMemStat results, error
func (*Reindexer) GetStats ¶
GetStats Get local thread reindexer usage stats Deprecated: Use SELECT * FROM '#perfstats' to get performance statistics.
func (*Reindexer) Insert ¶
Insert item to namespace by PK Item must be the same type as item passed to OpenNamespace, or []byte with json data Return 0, if no item was inserted, 1 if item was inserted If the precepts are provided and the item is a pointer, the value pointed by item will be updated
func (*Reindexer) MustBeginTx ¶
MustBeginTx - start update transaction, panic on error
func (*Reindexer) OpenNamespace ¶
func (db *Reindexer) OpenNamespace(namespace string, opts *NamespaceOptions, s interface{}) (err error)
OpenNamespace Open or create new namespace and indexes based on passed struct. IndexDef fields of struct are marked by `reindex:` tag
func (*Reindexer) RegisterNamespace ¶
func (db *Reindexer) RegisterNamespace(namespace string, opts *NamespaceOptions, s interface{}) (err error)
RegisterNamespace Register go type against namespace. There are no data and indexes changes will be performed
func (*Reindexer) RenameNamespace ¶
RenameNamespace - Rename namespace. If namespace with dstNsName exists, then it is replaced.
func (*Reindexer) ReopenLogFiles ¶
ReopenLogFiles reopens log files
func (*Reindexer) ResetCaches ¶
func (db *Reindexer) ResetCaches()
func (*Reindexer) ResetStats ¶
func (db *Reindexer) ResetStats()
ResetStats Reset local thread reindexer usage stats Deprecated: no longer used.
func (*Reindexer) SetDefaultQueryDebug ¶
SetDefaultQueryDebug sets default debug level for queries to namespaces
func (*Reindexer) TruncateNamespace ¶
TruncateNamespace - delete all items from namespace
func (*Reindexer) Update ¶
Update item to namespace by PK Item must be the same type as item passed to OpenNamespace, or []byte with json data Return 0, if no item was updated, 1 if item was updated If the precepts are provided and the item is a pointer, the value pointed by item will be updated
func (*Reindexer) UpdateIndex ¶ added in v1.9.7
UpdateIndex - update index.
type ReplicationStat ¶
type ReplicationStat struct {
// Replication type: either "async" or "cluster"
Type string `json:"type"`
// Global WAL-syncs' stats
WALSync ReplicationSyncStat `json:"wal_sync"`
// Global force-syncs' stats
ForceSync ReplicationSyncStat `json:"force_sync"`
// Leader's initial sync statistic (for "cluster" type only)
InitialSyncStat struct {
// WAL-syncs' stats
WALSync ReplicationSyncStat `json:"wal_sync"`
// Force-syncs' stats
ForceSync ReplicationSyncStat `json:"force_sync"`
// Total initial sync time
TotalTimeUs int64 `json:"total_time_us"`
} `json:"initial_sync"`
// Count of online updates, awaiting rpelication
PendingUpdatesCount int64 `json:"pending_updates_count"`
// Total allocated online updates count (including those, which already were replicated, but was not deallocated yet)
AllocatedUpdatesCount int64 `json:"allocated_updates_count"`
// Total allocated online updates size in bytes
AllocatedUpdatesSize int64 `json:"allocated_updates_size"`
// Info about each node
ReplicationNodeStat []struct {
// Node's DSN
DSN string `json:"dsn"`
// Node's server ID
ServerID int `json:"server_id"`
// Online updates, awaiting replication to this node
PendingUpdatesCount int64 `json:"pending_updates_count"`
// Network status: "none", "online", "offline", "raft_error"
Status string `json:"status"`
// Replication role: "none", "follower", "leader", "candidate"
Role string `json:"role"`
// Node's sync state: "none", "syncing", "awaiting_resync", "online_replication", "initial_leader_sync"
SyncState string `json:"sync_state"`
// Shows synchroniztion state for raft-cluster node (false if node is outdated)
IsSynchronized bool `json:"is_synchronized"`
} `json:"nodes"`
}
ReplicationStat replication statistic
type ReplicationSyncStat ¶
type ReplicationSyncStat struct {
// Syncs count
Count int64 `json:"count"`
// Average sync time
AvgTimeUs int64 `json:"avg_time_us"`
// Max sync time
MaxTimeUs int64 `json:"max_time_us"`
}
ReplicationSyncStat WAL/force sync statistic
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is transaction object. Transaction are performs atomic namespace update. There are synchronous and async transaction available. To start transaction method `db.BeginTx()` is used. This method creates transaction object
func (*Tx) AwaitResults ¶
AwaitResults awaits async requests completion
func (*Tx) Commit ¶
Commit - apply changes. Commit also waits for all async operations done, and then apply changes. if any error occurred during prepare process, then tx.Commit should return an error. So it is enough, to check error returned by Commit - to be sure that all data has been successfully committed or not.
func (*Tx) CommitWithCount ¶
CommitWithCount apply changes, and return count of changed items
func (*Tx) DeleteAsync ¶
func (tx *Tx) DeleteAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
DeleteAsync - remove item by id from namespace. Calls completion on result
func (*Tx) DeleteJSON ¶
DeleteJSON - remove item by id from namespace
func (*Tx) DeleteJSONAsync ¶
DeleteJSONAsync - remove item by id from namespace. Calls completion on result
func (*Tx) InsertAsync ¶
func (tx *Tx) InsertAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
InsertAsync Insert item to namespace. Calls completion on result
func (*Tx) MustCommit ¶
MustCommit apply changes and starts panic on errors
func (*Tx) UpdateAsync ¶
func (tx *Tx) UpdateAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
UpdateAsync Update item to namespace. Calls completion on result
func (*Tx) UpsertAsync ¶
func (tx *Tx) UpsertAsync(item interface{}, cmpl bindings.Completion, precepts ...string) error
UpsertAsync (Insert or Update) item to namespace. Calls completion on result
func (*Tx) UpsertJSON ¶
UpsertJSON (Insert or Update) item to namespace
func (*Tx) UpsertJSONAsync ¶
UpsertJSONAsync (Insert or Update) item to index. Calls completion on result
type TxPerfStat ¶
type TxPerfStat struct {
// Total transactions count for namespace
TotalCount int64 `json:"total_count"`
// Total namespace copy operations
TotalCopyCount int64 `json:"total_copy_count"`
// Average steps count in transactions for this namespace
AvgStepsCount int64 `json:"avg_steps_count"`
// Minimum steps count in transactions for this namespace
MinStepsCount int64 `json:"min_steps_count"`
// Maximum steps count in transactions for this namespace
MaxStepsCount int64 `json:"max_steps_count"`
// Average transaction preparation time usec
AvgPrepareTimeUs int64 `json:"avg_prepare_time_us"`
// Minimum transaction preparation time usec
MinPrepareTimeUs int64 `json:"min_prepare_time_us"`
// Maximum transaction preparation time usec
MaxPrepareTimeUs int64 `json:"max_prepare_time_us"`
// Average transaction commit time usec
AvgCommitTimeUs int64 `json:"avg_commit_time_us"`
// Minimum transaction commit time usec
MinCommitTimeUs int64 `json:"min_commit_time_us"`
// Maximum transaction commit time usec
MaxCommitTimeUs int64 `json:"max_commit_time_us"`
// Average namespace copy time usec
AvgCopyTimeUs int64 `json:"avg_copy_time_us"`
// Maximum namespace copy time usec
MinCopyTimeUs int64 `json:"min_copy_time_us"`
// Minimum namespace copy time usec
MaxCopyTimeUs int64 `json:"max_copy_time_us"`
}
TxPerfStat is information about transactions performance statistics