Documentation ¶
Index ¶
- func Distancer2Vec(d mathx.Distancer) []float64
- type AddDataArgs
- type CInfo
- func (ci *CInfo) KNNLatency(args KNNLatencyArgs) *ClientResult[KNNLatencyResp]
- func (ci *CInfo) KNNMonitor(args KNNMonArgs) *ClientResult[rman.KNNMonItemAvg]
- func (ci *CInfo) SSpaceCap(key string) *ClientResult[SSpaceCapResp]
- func (ci *CInfo) SSpaceDim(key string) *ClientResult[SSpaceDimResp]
- func (ci *CInfo) SSpaceLen(key string) *ClientResult[SSpaceLenResp]
- func (ci *CInfo) SSpaceNamespace(key string) *ClientResult[bool]
- func (ci *CInfo) SSpaceNamespaces() *ClientResult[[]string]
- type CSInfo
- func (csi *CSInfo) KNNLatency(args KNNLatencyArgs) ClientResults[KNNLatencyResp]
- func (csi *CSInfo) KNNMonitor(args KNNMonArgs) ClientResults[rman.KNNMonItemAvg]
- func (csi *CSInfo) SSpaceCap(key string) ClientResults[SSpaceCapResp]
- func (csi *CSInfo) SSpaceDim(key string) ClientResults[SSpaceDimResp]
- func (csi *CSInfo) SSpaceLen(key string) ClientResults[SSpaceLenResp]
- func (csi *CSInfo) SSpaceNamespace(key string) ClientResults[bool]
- func (csi *CSInfo) SSpaceNamespaces() ClientResults[[]string]
- type Client
- type ClientResult
- type ClientResults
- type Clients
- type KNNLatencyArgs
- type KNNLatencyResp
- type KNNMonArgs
- type KNNResp
- type KNNRespItem
- type SArgs
- type SInfo
- func (i *SInfo) KNNLatency(args SArgs[KNNLatencyArgs], resp *SResp[KNNLatencyResp]) error
- func (i *SInfo) KNNMonitor(args SArgs[KNNMonArgs], resp *SResp[rman.KNNMonItemAvg]) error
- func (i *SInfo) SSpaceCap(args SArgs[string], resp *SResp[SSpaceCapResp]) error
- func (i *SInfo) SSpaceDim(args SArgs[string], resp *SResp[SSpaceDimResp]) error
- func (i *SInfo) SSpaceLen(args SArgs[string], resp *SResp[SSpaceLenResp]) error
- func (i *SInfo) SSpaceNamespace(args SArgs[string], resp *SResp[bool]) error
- func (i *SInfo) SSpaceNamespaces(args SArgs[bool], resp *SResp[[]string]) error
- type SResp
- type SSpaceCapResp
- type SSpaceDimResp
- type SSpaceLenResp
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Distancer2Vec ¶
Distancer2Vec simply converts a mathx.Distancer (collection of float64) into a []float64. The reason this is needed is that Go rpc doesn't seem to work with interfaces.
Types ¶
type AddDataArgs ¶
AddDataArgs is intended as args for Client.AddData.
type CInfo ¶
type CInfo Client
CInfo is a namespace on top of Client, which contains methods related to metadata, similar to requestman.Handle.Info().
func (*CInfo) KNNLatency ¶
func (ci *CInfo) KNNLatency(args KNNLatencyArgs) *ClientResult[KNNLatencyResp]
KNNLatency tries to get some metadata related to KNN latency on the remote server, specifically queue and query durations.
The remote server forwards the call to these methods: - requestman.Handle.Info().KNNQueueLatency(...) - requestman.Handle.Info().KNNQueryLatency(...) See docs for those methods for more details about args, returns, etc.
func (*CInfo) KNNMonitor ¶
func (ci *CInfo) KNNMonitor(args KNNMonArgs) *ClientResult[rman.KNNMonItemAvg]
KNNMonitor tries to get monitoring data related to KNN queries from the remote server.
The remote server forwards the call to the method with the same name on top of its internal requestmanager.Handle.Info(). See the docs for that path for more details about args, returns, etc.
func (*CInfo) SSpaceCap ¶
func (ci *CInfo) SSpaceCap(key string) *ClientResult[SSpaceCapResp]
SSpaceCap tries to get the search space (not total vector) capacity for a given key/namespace from the remote server.
The remote server forwards the call to the method with the same name on top of its internal requestmanager.Handle.Info(). See the docs for that path for more details about args, returns, etc.
func (*CInfo) SSpaceDim ¶
func (ci *CInfo) SSpaceDim(key string) *ClientResult[SSpaceDimResp]
SSpaceDim tries to get the uniform dimension for vectors on the search space with the given key/namespace from the remote server.
The remote server forwards the call to the method with the same name on top of its internal requestmanager.Handle.Info(). See the docs for that path for more details about args, returns, etc.
func (*CInfo) SSpaceLen ¶
func (ci *CInfo) SSpaceLen(key string) *ClientResult[SSpaceLenResp]
SSpaceLen tries to get the amount of search spaces (and the sum of all their vectors) for a given key/namespace from the remote server.
The remote server forwards the call to the method with the same name on top of its internal requestmanager.Handle.Info(). See the docs for that path for more details about args, returns, etc.
func (*CInfo) SSpaceNamespace ¶
func (ci *CInfo) SSpaceNamespace(key string) *ClientResult[bool]
SSpaceNamespace checks if the given namespace/key exists on the remote server.
The remote server forwards the call to the method with the same name on top of its internal requestmanager.Handle.Info(). See the docs for that path for more details about args, returns, etc.
func (*CInfo) SSpaceNamespaces ¶
func (ci *CInfo) SSpaceNamespaces() *ClientResult[[]string]
SSpaceNamespaces tries to get namespaces from the remote server.
The remote server forwards the call to the method with the same name on top of its internal requestmanager.Handle.Info(). See the docs for that path for more details about args, returns, etc.
type CSInfo ¶
type CSInfo Clients
CSInfo is for namespacing info methods of type Clients.
func (*CSInfo) KNNLatency ¶
func (csi *CSInfo) KNNLatency(args KNNLatencyArgs) ClientResults[KNNLatencyResp]
KNNLatency does a composite call to Client.Info().KNNLatency(), using all internal addrs. See docs for that method for more details.
func (*CSInfo) KNNMonitor ¶
func (csi *CSInfo) KNNMonitor(args KNNMonArgs) ClientResults[rman.KNNMonItemAvg]
KNNMonitor does a composite call to Client.Info().KNNMonitor(), using all internal addrs. See docs for that method for more details.
func (*CSInfo) SSpaceCap ¶
func (csi *CSInfo) SSpaceCap(key string) ClientResults[SSpaceCapResp]
SSpaceCap does a composite call to Client.Info().SSpaceCap(), using all internal addrs. See docs for that method for more details.
func (*CSInfo) SSpaceDim ¶
func (csi *CSInfo) SSpaceDim(key string) ClientResults[SSpaceDimResp]
SSpaceDim does a composite call to Client.Info().SSpaceDim(), using all internal addrs. See docs for that method for more details.
func (*CSInfo) SSpaceLen ¶
func (csi *CSInfo) SSpaceLen(key string) ClientResults[SSpaceLenResp]
SSpaceLen does a composite call to Client.Info().SSpaceLen(), using all internal addrs. See docs for that method for more details.
func (*CSInfo) SSpaceNamespace ¶
func (csi *CSInfo) SSpaceNamespace(key string) ClientResults[bool]
SSpaceNamespace does a composite call to Client.Info().SSpaceNamespace(), using all internal addrs. See docs for that method for more details.
func (*CSInfo) SSpaceNamespaces ¶
func (csi *CSInfo) SSpaceNamespaces() ClientResults[[]string]
SSpaceNamespaces does a composite call to Client.Info().SSpaceNamespaces(), using all internal addrs. See docs for that method for more details.
type Client ¶
type Client struct { RemoteAddr string // Timeout specifies connection timeout. Timeout time.Duration }
Client is a client for the rpc network server defined in this pkg. It is used to interface remote requestman.Handle.
func NewClient ¶
NewClient sets up a new client. If a timeout isn't specified, or has a time.Duration <= 0, then the timeout will be set to 3 seconds as default.
func (*Client) AddData ¶
func (c *Client) AddData(args []AddDataArgs) *ClientResult[[]bool]
AddData tries to add data to the remote server. The remote server uses requestmanager.Handle.AddData(...), see the docs for more details about args, returns, etc.
func (*Client) KNNEager ¶
func (c *Client) KNNEager(args rman.KNNArgs) *ClientResult[KNNResp]
KNNEager tries to (eagerly) do a KNN lookup on a remote server. The remote server uses requestmanager.Handle.KNN(...), see the docs for more details about args, returns, etc.
Note; network latency is factored in with args.TTL.
Note; eagers means that it calls the server, which waits for the entire knn request before returning any results.
func (*Client) Ping ¶
func (c *Client) Ping() *ClientResult[bool]
Ping pings the remote server. The returned ClientResult.Payload will be true if the server is alive.
type ClientResult ¶
type ClientResult[T any] struct { RemoteAddr string NetErr error Payload T NetworkLatency time.Duration }
ClientResult is a wrapper around any result returned from a client -> server call. It contains additional meta info, specifically the address used, err, as well as network latency.
type ClientResults ¶
type ClientResults[T any] <-chan *ClientResult[T]
ClientResults is the general return from T Clients methods.
type Clients ¶
type Clients struct { RemoteAddrs []string Timeout time.Duration // This is passed to each individual Client. }
Clients T is used for composite Client calls.
func NewClients ¶
NewClients sets up a new composite client. If a timeout isn't specified, or has time.Duration <= 0, then the timeout will be set to 3 seconds as default.
func (*Clients) AddData ¶
func (cs *Clients) AddData(args []AddDataArgs) ClientResults[[]bool]
AddData does a composite call to Client.AddData(), using all internal addrs. Do note that the data to add (i.e "args") is added to a single remote node, picked at random, as a way of avoiding data duplication. See docs for that method for more details.
func (*Clients) KNNEager ¶
func (cs *Clients) KNNEager(args rman.KNNArgs) ClientResults[KNNResp]
KNNEager does a composite call to Client.KNNEager(), using all internal addrs. See docs for that method for more details. Also see Clients.KNNEagerx for merging and ordering the results.
func (*Clients) KNNEagerx ¶
func (cs *Clients) KNNEagerx(args rman.KNNArgs) []*ClientResult[KNNRespItem]
KNNEagerx is a convenience on top of Clients.KNNEager. It calls the latter method, then orders KNN results into max args.K. The return is a flat slice of ClientResult containing a single KNNRespItem, where lower indexes are better KNN. It can look something like the following (simplified, using cosine similarity where higher scores are better): [
addr: ":3000", score: 0.99, Vec: ..., addr: ":3000", score: 0.98, Vec: ..., addr: ":3001", score: 0.97, Vec: ...,
] This is to include network information in addition to actual KNN results.
func (*Clients) Ping ¶
func (cs *Clients) Ping() ClientResults[bool]
Ping does a composite call to Client.Ping(), using all internal addrs. See docs for that method for more details.
type KNNLatencyArgs ¶
type KNNLatencyArgs struct { Key string // Key specifies the namespace to use. Period time.Duration // Period specifies what period (since now) to check. }
KNNLatencyArgs is intended for CInfo.KNNLatency.
type KNNLatencyResp ¶
type KNNMonArgs ¶
KNNMonArgs is intended for CInfo.KNNMonitor
type KNNResp ¶
type KNNResp struct { KNN []KNNRespItem // Ok is generally matched with the bool returned from // requestman.Handle.KNN. But it is also false if the // requestman.KNNArgs.TTL is less than network latency. Ok bool }
KNNResp is intended as the response of Client.KNNEager.
type KNNRespItem ¶
KNNRespItem is intended as a single item in KNNResp.
func KNNRespItemFromScoreItem ¶
func KNNRespItemFromScoreItem(scoreItem knnc.ScoreItem) KNNRespItem
KNNRespItemFromScoreItem converts KNN results (pkg knnc and requestman) into a KNNRespItem. See docs for Distancer2Vec for why this is needed.
func KNNRespItemsFromScoreItems ¶
func KNNRespItemsFromScoreItems(scoreItems knnc.ScoreItems) []KNNRespItem
KNNRespItemsFromScoreItems converts KNN results (pkg knnc and requestman) into a KNNResp. See docs for Distancer2Vec for why this is needed.
type SArgs ¶
SArgs is used as a Server argument wrapper with metadata. Go rpc methods are required to have the following signature format:
x.Method(args any, resp *any) error
This is used as the 'args'.
type SInfo ¶
type SInfo Server
Info namespace of server (same as CInfo for Client). Registered with rpc in the Server.StartListen method.
func (*SInfo) KNNLatency ¶
func (i *SInfo) KNNLatency(args SArgs[KNNLatencyArgs], resp *SResp[KNNLatencyResp]) error
KNNLatency forwards the call to the following methods of the internal requestman.Handle: - requestman.Handle.Info().KNNQueueLatency(...) - requestman.Handle.Info().KNNQueryLatency(...) See docs for those methods for more details about args, returns, etc.
func (*SInfo) KNNMonitor ¶
func (i *SInfo) KNNMonitor(args SArgs[KNNMonArgs], resp *SResp[rman.KNNMonItemAvg]) error
KNNMonitor forwards the call to the method with the same name on top of the internal requestman.Handle.Info(). See docs for that for more details.
func (*SInfo) SSpaceCap ¶
SSpaceCap forwards the call to the method with the same name on top of the internal requestman.Handle.Info(). See docs for that for more details.
func (*SInfo) SSpaceDim ¶
SSpaceDim forwards the call to the method with the same name on top of the internal requestman.Handle.Info(). See docs for that for more details.
func (*SInfo) SSpaceLen ¶
SSpaceLen forwards the call to the method with the same name on top of the internal requestman.Handle.Info(). See docs for that for more details.
func (*SInfo) SSpaceNamespace ¶
SSpaceNamespace forwards the call to the method with the same name on top of the internal requestman.Handle.Info(). See docs for that for more details.
type SResp ¶
SResp is used as a Server argument wrapper with metadata. Go rpc methods are required to have the following signature format:
x.Method(args any, resp *any) error
This is used as the 'resp'.
type SSpaceCapResp ¶
type SSpaceCapResp struct { LookupOk bool // LookupOk indicates if the namespace/key was valid. Cap int // Cap specifies how many search spaces can exist. }
SSpaceCapresp is intended as a response from CInfo.SSpaceCap.
type SSpaceDimResp ¶
type SSpaceDimResp struct { LookupOk bool // LookupOk indicates if the namespace/key was valid. Dim int // Uniform vector dimension. }
SSpaceDimResp is intended as a response from CInfo.SSpaceDim.
type SSpaceLenResp ¶
type SSpaceLenResp struct { LookupOk bool // LookupOk indicates if the namespace/key was valid. NSSpaces int // NSSpaces specifies a number of search spaces. NVecs int // NVecs specifies the total number of vectors. }
SSPaceLenResp is intended as a response from CInfo.SSpaceLen.
type Server ¶
type Server struct { LocalAddr string // contains filtered or unexported fields }
Server is an rpc server on top of requestman.Handle.
func NewServer ¶
func NewServer(localAddr string, rManHandleArgs rman.NewHandleArgs) (*Server, bool)
NewServer is a factory function. Will return (nil, false) is a new requestman.Handle could not be created with the given rManHandleArgs.
func (*Server) AddData ¶
AddData attempts to add the given data to the internal requestman.Handle with the AddData() method. The returns of those AddData() calls are stored index for index in the response.
func (*Server) KNNEager ¶
KNNEager attempts to do a KNN request using the KNN method of the internal requestmanager.Handle. It does so eagerly, so will wait until the KNN request is complete.
Note that network latency is factored in with args.Payload.TTL
func (*Server) StartListen ¶
StartListen spins up the server and makes it active. The returned func is used for stopping (this also stops the internal requestman.Handle), while the error indicates the following (These are for the setup): - rpc.NewServer().Register(this) returns an err. - net.Listen("tcp", this.LocalAddr) returns an err.
Note, while accepting requests with net.Listener.Accept(), if an err is returned, then the listening event-loop simply fails.