mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
Added /internal/translate/keys endpoint
This commit is contained in:
parent
e472ed3984
commit
9c05155db4
7 changed files with 781 additions and 74 deletions
30
api.go
30
api.go
|
|
@ -1071,6 +1071,36 @@ func (api *API) Info() serverInfo {
|
|||
}
|
||||
}
|
||||
|
||||
func (api *API) TranslateKeys(body io.Reader) ([]byte, error) {
|
||||
reqBytes, err := ioutil.ReadAll(body)
|
||||
if err != nil {
|
||||
return nil, NewBadRequestError(errors.Wrap(err, "read body error"))
|
||||
}
|
||||
var req TranslateKeysRequest
|
||||
if err := api.Serializer.Unmarshal(reqBytes, &req); err != nil {
|
||||
return nil, NewBadRequestError(errors.Wrap(err, "unmarshal body error"))
|
||||
}
|
||||
var ids []uint64
|
||||
if req.Field == "" {
|
||||
ids, err = api.holder.translateFile.TranslateColumnsToUint64(req.Index, req.Keys)
|
||||
} else {
|
||||
ids, err = api.holder.translateFile.TranslateRowsToUint64(req.Index, req.Field, req.Keys)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := TranslateKeysResponse{
|
||||
IDs: ids,
|
||||
}
|
||||
// Encode response.
|
||||
buf, err := api.Serializer.Marshal(&resp)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "translate keys response encoding error")
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
type serverInfo struct {
|
||||
ShardWidth uint64 `json:"shardWidth"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,6 +241,22 @@ func (Serializer) Unmarshal(buf []byte, m pilosa.Message) error {
|
|||
}
|
||||
decodeBlockDataResponse(msg, mt)
|
||||
return nil
|
||||
case *pilosa.TranslateKeysRequest:
|
||||
msg := &internal.TranslateKeysRequest{}
|
||||
err := proto.Unmarshal(buf, msg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unmarshaling TranslateKeysRequest")
|
||||
}
|
||||
decodeTranslateKeysRequest(msg, mt)
|
||||
return nil
|
||||
case *pilosa.TranslateKeysResponse:
|
||||
msg := &internal.TranslateKeysResponse{}
|
||||
err := proto.Unmarshal(buf, msg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unmarshaling TranslateKeysResponse")
|
||||
}
|
||||
decodeTranslateKeysResponse(msg, mt)
|
||||
return nil
|
||||
default:
|
||||
panic(fmt.Sprintf("unhandled pilosa.Message of type %T: %#v", mt, m))
|
||||
}
|
||||
|
|
@ -298,6 +314,10 @@ func encodeToProto(m pilosa.Message) proto.Message {
|
|||
return encodeBlockDataRequest(mt)
|
||||
case *pilosa.BlockDataResponse:
|
||||
return encodeBlockDataResponse(mt)
|
||||
case *pilosa.TranslateKeysRequest:
|
||||
return encodeTranslateKeysRequest(mt)
|
||||
case *pilosa.TranslateKeysResponse:
|
||||
return encodeTranslateKeysResponse(mt)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -669,6 +689,20 @@ func encodeRecalculateCaches(*pilosa.RecalculateCaches) *internal.RecalculateCac
|
|||
return &internal.RecalculateCaches{}
|
||||
}
|
||||
|
||||
func encodeTranslateKeysResponse(response *pilosa.TranslateKeysResponse) *internal.TranslateKeysResponse {
|
||||
return &internal.TranslateKeysResponse{
|
||||
IDs: response.IDs,
|
||||
}
|
||||
}
|
||||
|
||||
func encodeTranslateKeysRequest(request *pilosa.TranslateKeysRequest) *internal.TranslateKeysRequest {
|
||||
return &internal.TranslateKeysRequest{
|
||||
Index: request.Index,
|
||||
Field: request.Field,
|
||||
Keys: request.Keys,
|
||||
}
|
||||
}
|
||||
|
||||
func decodeResizeInstruction(ri *internal.ResizeInstruction, m *pilosa.ResizeInstruction) {
|
||||
m.JobID = ri.JobID
|
||||
m.Node = &pilosa.Node{}
|
||||
|
|
@ -964,6 +998,16 @@ func decodeQueryResults(pb []*internal.QueryResult, m []interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
func decodeTranslateKeysRequest(pb *internal.TranslateKeysRequest, m *pilosa.TranslateKeysRequest) {
|
||||
m.Index = pb.Index
|
||||
m.Field = pb.Field
|
||||
m.Keys = pb.Keys
|
||||
}
|
||||
|
||||
func decodeTranslateKeysResponse(pb *internal.TranslateKeysResponse, m *pilosa.TranslateKeysResponse) {
|
||||
m.IDs = pb.IDs
|
||||
}
|
||||
|
||||
// QueryResult types.
|
||||
const (
|
||||
queryResultTypeNil uint32 = iota
|
||||
|
|
|
|||
10
handler.go
10
handler.go
|
|
@ -112,3 +112,13 @@ type BlockDataResponse struct {
|
|||
RowIDs []uint64
|
||||
ColumnIDs []uint64
|
||||
}
|
||||
|
||||
type TranslateKeysRequest struct {
|
||||
Index string
|
||||
Field string
|
||||
Keys []string
|
||||
}
|
||||
|
||||
type TranslateKeysResponse struct {
|
||||
IDs []uint64
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@ import (
|
|||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
// Imported for its side-effect of registering pprof endpoints with the server.
|
||||
_ "net/http/pprof"
|
||||
"net/url" // Imported for its side-effect of registering pprof endpoints with the server.
|
||||
"reflect"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
|
|
@ -37,7 +36,6 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
"github.com/pilosa/pilosa"
|
||||
"github.com/pilosa/pilosa/logger"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
@ -199,6 +197,7 @@ func (h *Handler) populateValidators() {
|
|||
h.validators["GetNodes"] = queryValidationSpecRequired()
|
||||
h.validators["GetShardMax"] = queryValidationSpecRequired()
|
||||
h.validators["GetTranslateData"] = queryValidationSpecRequired("offset")
|
||||
h.validators["PostTranslateKeys"] = queryValidationSpecRequired()
|
||||
}
|
||||
|
||||
func (h *Handler) queryArgValidator(next http.Handler) http.Handler {
|
||||
|
|
@ -260,6 +259,7 @@ func newRouter(handler *Handler) *mux.Router {
|
|||
router.HandleFunc("/internal/nodes", handler.handleGetNodes).Methods("GET").Name("GetNodes")
|
||||
router.HandleFunc("/internal/shards/max", handler.handleGetShardsMax).Methods("GET").Name("GetShardsMax") // TODO: deprecate, but it's being used by the client
|
||||
router.HandleFunc("/internal/translate/data", handler.handleGetTranslateData).Methods("GET").Name("GetTranslateData")
|
||||
router.HandleFunc("/internal/translate/keys", handler.handlePostTranslateKeys).Methods("POST").Name("PostTranslateKeys")
|
||||
|
||||
router.Use(handler.queryArgValidator)
|
||||
return router
|
||||
|
|
@ -1549,3 +1549,25 @@ func (h *Handler) handlePostImportRoaring(w http.ResponseWriter, r *http.Request
|
|||
h.logger.Printf("writing import-roaring response: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) handlePostTranslateKeys(w http.ResponseWriter, r *http.Request) {
|
||||
// Verify that request is only communicating over protobufs.
|
||||
if r.Header.Get("Content-Type") != "application/x-protobuf" {
|
||||
http.Error(w, "Unsupported media type", http.StatusUnsupportedMediaType)
|
||||
return
|
||||
} else if r.Header.Get("Accept") != "application/x-protobuf" {
|
||||
http.Error(w, "Not acceptable", http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
|
||||
buf, err := h.api.TranslateKeys(r.Body)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("translate keys: %v", err), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// Write response.
|
||||
_, err = w.Write(buf)
|
||||
if err != nil {
|
||||
h.logger.Printf("writing translate keys response: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func (m *Row) Reset() { *m = Row{} }
|
|||
func (m *Row) String() string { return proto.CompactTextString(m) }
|
||||
func (*Row) ProtoMessage() {}
|
||||
func (*Row) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{0}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{0}
|
||||
}
|
||||
func (m *Row) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -97,7 +97,7 @@ func (m *RowIdentifiers) Reset() { *m = RowIdentifiers{} }
|
|||
func (m *RowIdentifiers) String() string { return proto.CompactTextString(m) }
|
||||
func (*RowIdentifiers) ProtoMessage() {}
|
||||
func (*RowIdentifiers) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{1}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{1}
|
||||
}
|
||||
func (m *RowIdentifiers) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -153,7 +153,7 @@ func (m *Pair) Reset() { *m = Pair{} }
|
|||
func (m *Pair) String() string { return proto.CompactTextString(m) }
|
||||
func (*Pair) ProtoMessage() {}
|
||||
func (*Pair) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{2}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{2}
|
||||
}
|
||||
func (m *Pair) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -215,7 +215,7 @@ func (m *FieldRow) Reset() { *m = FieldRow{} }
|
|||
func (m *FieldRow) String() string { return proto.CompactTextString(m) }
|
||||
func (*FieldRow) ProtoMessage() {}
|
||||
func (*FieldRow) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{3}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{3}
|
||||
}
|
||||
func (m *FieldRow) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -270,7 +270,7 @@ func (m *GroupCount) Reset() { *m = GroupCount{} }
|
|||
func (m *GroupCount) String() string { return proto.CompactTextString(m) }
|
||||
func (*GroupCount) ProtoMessage() {}
|
||||
func (*GroupCount) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{4}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{4}
|
||||
}
|
||||
func (m *GroupCount) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -325,7 +325,7 @@ func (m *ValCount) Reset() { *m = ValCount{} }
|
|||
func (m *ValCount) String() string { return proto.CompactTextString(m) }
|
||||
func (*ValCount) ProtoMessage() {}
|
||||
func (*ValCount) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{5}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{5}
|
||||
}
|
||||
func (m *ValCount) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -381,7 +381,7 @@ func (m *Bit) Reset() { *m = Bit{} }
|
|||
func (m *Bit) String() string { return proto.CompactTextString(m) }
|
||||
func (*Bit) ProtoMessage() {}
|
||||
func (*Bit) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{6}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{6}
|
||||
}
|
||||
func (m *Bit) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -444,7 +444,7 @@ func (m *ColumnAttrSet) Reset() { *m = ColumnAttrSet{} }
|
|||
func (m *ColumnAttrSet) String() string { return proto.CompactTextString(m) }
|
||||
func (*ColumnAttrSet) ProtoMessage() {}
|
||||
func (*ColumnAttrSet) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{7}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{7}
|
||||
}
|
||||
func (m *ColumnAttrSet) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -510,7 +510,7 @@ func (m *Attr) Reset() { *m = Attr{} }
|
|||
func (m *Attr) String() string { return proto.CompactTextString(m) }
|
||||
func (*Attr) ProtoMessage() {}
|
||||
func (*Attr) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{8}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{8}
|
||||
}
|
||||
func (m *Attr) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -592,7 +592,7 @@ func (m *AttrMap) Reset() { *m = AttrMap{} }
|
|||
func (m *AttrMap) String() string { return proto.CompactTextString(m) }
|
||||
func (*AttrMap) ProtoMessage() {}
|
||||
func (*AttrMap) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{9}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{9}
|
||||
}
|
||||
func (m *AttrMap) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -644,7 +644,7 @@ func (m *QueryRequest) Reset() { *m = QueryRequest{} }
|
|||
func (m *QueryRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryRequest) ProtoMessage() {}
|
||||
func (*QueryRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{10}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{10}
|
||||
}
|
||||
func (m *QueryRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -728,7 +728,7 @@ func (m *QueryResponse) Reset() { *m = QueryResponse{} }
|
|||
func (m *QueryResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryResponse) ProtoMessage() {}
|
||||
func (*QueryResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{11}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{11}
|
||||
}
|
||||
func (m *QueryResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -797,7 +797,7 @@ func (m *QueryResult) Reset() { *m = QueryResult{} }
|
|||
func (m *QueryResult) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryResult) ProtoMessage() {}
|
||||
func (*QueryResult) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{12}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{12}
|
||||
}
|
||||
func (m *QueryResult) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -907,7 +907,7 @@ func (m *ImportRequest) Reset() { *m = ImportRequest{} }
|
|||
func (m *ImportRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ImportRequest) ProtoMessage() {}
|
||||
func (*ImportRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{13}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{13}
|
||||
}
|
||||
func (m *ImportRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -1008,7 +1008,7 @@ func (m *ImportValueRequest) Reset() { *m = ImportValueRequest{} }
|
|||
func (m *ImportValueRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ImportValueRequest) ProtoMessage() {}
|
||||
func (*ImportValueRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_fc5da89825239896, []int{14}
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{14}
|
||||
}
|
||||
func (m *ImportValueRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
|
@ -1079,6 +1079,116 @@ func (m *ImportValueRequest) GetValues() []int64 {
|
|||
return nil
|
||||
}
|
||||
|
||||
type TranslateKeysRequest struct {
|
||||
Index string `protobuf:"bytes,1,opt,name=Index,proto3" json:"Index,omitempty"`
|
||||
Field string `protobuf:"bytes,2,opt,name=Field,proto3" json:"Field,omitempty"`
|
||||
Keys []string `protobuf:"bytes,3,rep,name=Keys" json:"Keys,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TranslateKeysRequest) Reset() { *m = TranslateKeysRequest{} }
|
||||
func (m *TranslateKeysRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*TranslateKeysRequest) ProtoMessage() {}
|
||||
func (*TranslateKeysRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{15}
|
||||
}
|
||||
func (m *TranslateKeysRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *TranslateKeysRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_TranslateKeysRequest.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalTo(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (dst *TranslateKeysRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TranslateKeysRequest.Merge(dst, src)
|
||||
}
|
||||
func (m *TranslateKeysRequest) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *TranslateKeysRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TranslateKeysRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TranslateKeysRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *TranslateKeysRequest) GetIndex() string {
|
||||
if m != nil {
|
||||
return m.Index
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *TranslateKeysRequest) GetField() string {
|
||||
if m != nil {
|
||||
return m.Field
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *TranslateKeysRequest) GetKeys() []string {
|
||||
if m != nil {
|
||||
return m.Keys
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type TranslateKeysResponse struct {
|
||||
IDs []uint64 `protobuf:"varint,3,rep,packed,name=IDs" json:"IDs,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TranslateKeysResponse) Reset() { *m = TranslateKeysResponse{} }
|
||||
func (m *TranslateKeysResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*TranslateKeysResponse) ProtoMessage() {}
|
||||
func (*TranslateKeysResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_public_4fd446cb72375657, []int{16}
|
||||
}
|
||||
func (m *TranslateKeysResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *TranslateKeysResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_TranslateKeysResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalTo(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (dst *TranslateKeysResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TranslateKeysResponse.Merge(dst, src)
|
||||
}
|
||||
func (m *TranslateKeysResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *TranslateKeysResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TranslateKeysResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TranslateKeysResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *TranslateKeysResponse) GetIDs() []uint64 {
|
||||
if m != nil {
|
||||
return m.IDs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Row)(nil), "internal.Row")
|
||||
proto.RegisterType((*RowIdentifiers)(nil), "internal.RowIdentifiers")
|
||||
|
|
@ -1095,6 +1205,8 @@ func init() {
|
|||
proto.RegisterType((*QueryResult)(nil), "internal.QueryResult")
|
||||
proto.RegisterType((*ImportRequest)(nil), "internal.ImportRequest")
|
||||
proto.RegisterType((*ImportValueRequest)(nil), "internal.ImportValueRequest")
|
||||
proto.RegisterType((*TranslateKeysRequest)(nil), "internal.TranslateKeysRequest")
|
||||
proto.RegisterType((*TranslateKeysResponse)(nil), "internal.TranslateKeysResponse")
|
||||
}
|
||||
func (m *Row) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
|
|
@ -1979,6 +2091,92 @@ func (m *ImportValueRequest) MarshalTo(dAtA []byte) (int, error) {
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *TranslateKeysRequest) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalTo(dAtA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *TranslateKeysRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
var i int
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Index) > 0 {
|
||||
dAtA[i] = 0xa
|
||||
i++
|
||||
i = encodeVarintPublic(dAtA, i, uint64(len(m.Index)))
|
||||
i += copy(dAtA[i:], m.Index)
|
||||
}
|
||||
if len(m.Field) > 0 {
|
||||
dAtA[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintPublic(dAtA, i, uint64(len(m.Field)))
|
||||
i += copy(dAtA[i:], m.Field)
|
||||
}
|
||||
if len(m.Keys) > 0 {
|
||||
for _, s := range m.Keys {
|
||||
dAtA[i] = 0x1a
|
||||
i++
|
||||
l = len(s)
|
||||
for l >= 1<<7 {
|
||||
dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
|
||||
l >>= 7
|
||||
i++
|
||||
}
|
||||
dAtA[i] = uint8(l)
|
||||
i++
|
||||
i += copy(dAtA[i:], s)
|
||||
}
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (m *TranslateKeysResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalTo(dAtA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *TranslateKeysResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
var i int
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.IDs) > 0 {
|
||||
dAtA23 := make([]byte, len(m.IDs)*10)
|
||||
var j22 int
|
||||
for _, num := range m.IDs {
|
||||
for num >= 1<<7 {
|
||||
dAtA23[j22] = uint8(uint64(num)&0x7f | 0x80)
|
||||
num >>= 7
|
||||
j22++
|
||||
}
|
||||
dAtA23[j22] = uint8(num)
|
||||
j22++
|
||||
}
|
||||
dAtA[i] = 0x1a
|
||||
i++
|
||||
i = encodeVarintPublic(dAtA, i, uint64(j22))
|
||||
i += copy(dAtA[i:], dAtA23[:j22])
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func encodeVarintPublic(dAtA []byte, offset int, v uint64) int {
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
|
|
@ -2434,6 +2632,51 @@ func (m *ImportValueRequest) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *TranslateKeysRequest) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Index)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovPublic(uint64(l))
|
||||
}
|
||||
l = len(m.Field)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovPublic(uint64(l))
|
||||
}
|
||||
if len(m.Keys) > 0 {
|
||||
for _, s := range m.Keys {
|
||||
l = len(s)
|
||||
n += 1 + l + sovPublic(uint64(l))
|
||||
}
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *TranslateKeysResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.IDs) > 0 {
|
||||
l = 0
|
||||
for _, e := range m.IDs {
|
||||
l += sovPublic(uint64(e))
|
||||
}
|
||||
n += 1 + sovPublic(uint64(l)) + l
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovPublic(x uint64) (n int) {
|
||||
for {
|
||||
n++
|
||||
|
|
@ -5115,6 +5358,268 @@ func (m *ImportValueRequest) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *TranslateKeysRequest) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: TranslateKeysRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: TranslateKeysRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthPublic
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Index = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthPublic
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Field = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthPublic
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Keys = append(m.Keys, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipPublic(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthPublic
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *TranslateKeysResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: TranslateKeysResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: TranslateKeysResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 3:
|
||||
if wireType == 0 {
|
||||
var v uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
v |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.IDs = append(m.IDs, v)
|
||||
} else if wireType == 2 {
|
||||
var packedLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
packedLen |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if packedLen < 0 {
|
||||
return ErrInvalidLengthPublic
|
||||
}
|
||||
postIndex := iNdEx + packedLen
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
var elementCount int
|
||||
var count int
|
||||
for _, integer := range dAtA {
|
||||
if integer < 128 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
elementCount = count
|
||||
if elementCount != 0 && len(m.IDs) == 0 {
|
||||
m.IDs = make([]uint64, 0, elementCount)
|
||||
}
|
||||
for iNdEx < postIndex {
|
||||
var v uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPublic
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
v |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.IDs = append(m.IDs, v)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field IDs", wireType)
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipPublic(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthPublic
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipPublic(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
|
@ -5220,59 +5725,61 @@ var (
|
|||
ErrIntOverflowPublic = fmt.Errorf("proto: integer overflow")
|
||||
)
|
||||
|
||||
func init() { proto.RegisterFile("public.proto", fileDescriptor_public_fc5da89825239896) }
|
||||
func init() { proto.RegisterFile("public.proto", fileDescriptor_public_4fd446cb72375657) }
|
||||
|
||||
var fileDescriptor_public_fc5da89825239896 = []byte{
|
||||
// 804 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcb, 0x6e, 0xdb, 0x46,
|
||||
0x14, 0xed, 0x88, 0x94, 0x44, 0x5d, 0x59, 0xaa, 0x31, 0x70, 0x5d, 0xa2, 0x30, 0x54, 0x82, 0x28,
|
||||
0x0a, 0xae, 0x64, 0x40, 0x05, 0x8c, 0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c, 0xf7, 0x85, 0x88, 0x95, 0xb2, 0xed, 0x91, 0xc0, 0x61, 0x46, 0x40, 0x47,
|
||||
0x00, 0xc7, 0xb1, 0x08, 0x2b, 0xdf, 0x8e, 0x47, 0x02, 0xc2, 0x6a, 0x12, 0x7f, 0x17, 0xba, 0x32,
|
||||
0xd3, 0xff, 0xc2, 0xd4, 0xb0, 0x25, 0x8f, 0xb0, 0xf5, 0xef, 0x08, 0x6c, 0x3c, 0x29, 0x79, 0xb6,
|
||||
0x64, 0xfc, 0x65, 0xc9, 0x73, 0xec, 0x0a, 0x62, 0x3d, 0x4a, 0x08, 0xe8, 0x36, 0x74, 0xce, 0x6e,
|
||||
0xc2, 0x6c, 0xa6, 0x6a, 0x67, 0xb3, 0x0a, 0x49, 0xae, 0xa6, 0xe6, 0x39, 0x72, 0x75, 0x58, 0x5d,
|
||||
0x24, 0x3d, 0x19, 0x9f, 0x8b, 0x42, 0x93, 0xa9, 0x10, 0x0d, 0xe0, 0xfb, 0xa3, 0xdb, 0xab, 0xb8,
|
||||
0x9c, 0x71, 0x26, 0x16, 0xca, 0xbb, 0x83, 0x06, 0x4d, 0x31, 0xfd, 0x15, 0x86, 0x95, 0x48, 0x6f,
|
||||
0x6f, 0x17, 0x0d, 0x1b, 0x52, 0xff, 0x15, 0x81, 0x41, 0x45, 0x25, 0x4f, 0x45, 0x92, 0x73, 0xd9,
|
||||
0xaf, 0xa3, 0x2c, 0xd3, 0xfd, 0x3a, 0xca, 0x32, 0xba, 0x0b, 0x5d, 0xc6, 0xf3, 0x32, 0x2e, 0xf4,
|
||||
0x10, 0xfc, 0x60, 0xca, 0xa2, 0x7d, 0xcb, 0xb8, 0x60, 0xda, 0x8a, 0xfe, 0x09, 0xc3, 0xb5, 0xa1,
|
||||
0x52, 0xdb, 0xdf, 0x9f, 0xfc, 0x68, 0xfc, 0xd6, 0xf4, 0xac, 0x61, 0xee, 0xbf, 0x6f, 0x41, 0xbf,
|
||||
0x16, 0x99, 0xfe, 0x8c, 0xb7, 0x08, 0x73, 0xea, 0x4f, 0x06, 0x26, 0x8a, 0xdc, 0x34, 0xbc, 0x52,
|
||||
0x1b, 0x40, 0x4e, 0xab, 0x79, 0x22, 0xa7, 0xb2, 0x8b, 0xf2, 0x4a, 0xe8, 0xcf, 0xd6, 0xba, 0x28,
|
||||
0xc5, 0x4c, 0x29, 0xf1, 0xb2, 0xdd, 0x84, 0xc9, 0x35, 0x9f, 0xe1, 0x3c, 0x39, 0x4c, 0x43, 0x3a,
|
||||
0x36, 0xfb, 0x89, 0x0d, 0x58, 0x5b, 0x71, 0xad, 0x61, 0x66, 0x87, 0xf5, 0x40, 0xcb, 0x5e, 0x0c,
|
||||
0xaa, 0x81, 0x96, 0x2d, 0x94, 0xbb, 0x29, 0x0b, 0x8f, 0xcd, 0x57, 0x88, 0xee, 0x41, 0xdf, 0x5c,
|
||||
0x92, 0xdc, 0x75, 0x30, 0xc3, 0x2d, 0x13, 0xde, 0x28, 0x59, 0xdd, 0x90, 0xfe, 0xd5, 0xbc, 0x99,
|
||||
0x6e, 0x0f, 0x33, 0x73, 0xd7, 0xaa, 0x51, 0xd3, 0xb3, 0x86, 0xbd, 0xff, 0x91, 0xc0, 0x60, 0x3a,
|
||||
0x4f, 0x45, 0x56, 0xd4, 0xc6, 0x76, 0x9a, 0xcc, 0xf8, 0xad, 0x1e, 0x5b, 0x04, 0xe6, 0x2e, 0xb6,
|
||||
0x1a, 0x77, 0x11, 0xc7, 0x17, 0xc7, 0xd5, 0x66, 0x0a, 0xd4, 0x58, 0xda, 0x6b, 0x2c, 0x77, 0xa0,
|
||||
0xa7, 0x0f, 0x50, 0xee, 0xb6, 0x51, 0x65, 0x04, 0x72, 0x21, 0x57, 0x17, 0x48, 0x4e, 0xb0, 0x15,
|
||||
0x58, 0xac, 0x26, 0x91, 0x9d, 0x61, 0x62, 0x81, 0xc7, 0xbf, 0x8b, 0xc7, 0x5f, 0x43, 0xe9, 0xa9,
|
||||
0xc2, 0xa0, 0xd2, 0x41, 0x65, 0x4d, 0xe2, 0xbf, 0x25, 0x40, 0x15, 0x47, 0x5c, 0xed, 0x6f, 0x47,
|
||||
0xf4, 0x71, 0x42, 0xdb, 0xd0, 0xc1, 0xef, 0x69, 0x32, 0x15, 0x6a, 0xa4, 0xdb, 0x6d, 0xa6, 0xbb,
|
||||
0xbf, 0x79, 0x77, 0x3f, 0x22, 0xef, 0xee, 0x47, 0xe4, 0xc3, 0xfd, 0x88, 0xbc, 0xfe, 0x34, 0xfa,
|
||||
0xee, 0xb2, 0x83, 0xbf, 0xe1, 0xdf, 0x3e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x62, 0xa8, 0x25,
|
||||
0x96, 0x07, 0x00, 0x00,
|
||||
var fileDescriptor_public_4fd446cb72375657 = []byte{
|
||||
// 835 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xdd, 0x6e, 0xe3, 0x44,
|
||||
0x14, 0x66, 0x62, 0x27, 0x71, 0x4e, 0x9a, 0xb0, 0x1a, 0x65, 0x17, 0x0b, 0xad, 0x82, 0x65, 0x21,
|
||||
0x64, 0x6e, 0xb2, 0x52, 0x90, 0x56, 0x5c, 0xf1, 0xd3, 0x6d, 0x8b, 0xa2, 0x42, 0x05, 0xd3, 0x12,
|
||||
0xc4, 0xa5, 0xdb, 0x0c, 0xad, 0x25, 0xc7, 0x63, 0xec, 0xb1, 0xd2, 0x3c, 0x07, 0x37, 0x3c, 0x02,
|
||||
0x17, 0x3c, 0x48, 0x2f, 0x11, 0x4f, 0x00, 0xe5, 0x45, 0xd0, 0x9c, 0xf1, 0x64, 0x1c, 0xb7, 0xaa,
|
||||
0x10, 0xda, 0xbb, 0xf9, 0xce, 0x9f, 0xcf, 0x77, 0xfe, 0x12, 0x38, 0xc8, 0xab, 0xcb, 0x34, 0xb9,
|
||||
0x9a, 0xe5, 0x85, 0x90, 0x82, 0x7a, 0x49, 0x26, 0x79, 0x91, 0xc5, 0x69, 0xf8, 0x23, 0x38, 0x4c,
|
||||
0x6c, 0xa8, 0x0f, 0xfd, 0x37, 0x22, 0xad, 0xd6, 0x59, 0xe9, 0x93, 0xc0, 0x89, 0x5c, 0x66, 0x20,
|
||||
0xfd, 0x10, 0xba, 0x5f, 0x4a, 0x59, 0x94, 0x7e, 0x27, 0x70, 0xa2, 0xe1, 0x7c, 0x3c, 0x33, 0xae,
|
||||
0x33, 0x25, 0x66, 0x5a, 0x49, 0x29, 0xb8, 0xa7, 0x7c, 0x5b, 0xfa, 0x4e, 0xe0, 0x44, 0x03, 0x86,
|
||||
0xef, 0xf0, 0x53, 0x18, 0x33, 0xb1, 0x59, 0xac, 0x78, 0x26, 0x93, 0x9f, 0x12, 0xae, 0xad, 0x98,
|
||||
0xd8, 0x98, 0x4f, 0xe0, 0x7b, 0xe7, 0xd9, 0x69, 0x78, 0x7e, 0x06, 0xee, 0xb7, 0x71, 0x52, 0xd0,
|
||||
0x31, 0x74, 0x16, 0x47, 0x3e, 0x09, 0x48, 0xe4, 0xb2, 0xce, 0xe2, 0x88, 0x4e, 0xa0, 0xfb, 0x46,
|
||||
0x54, 0x99, 0xf4, 0x3b, 0x28, 0xd2, 0x80, 0x3e, 0x03, 0xe7, 0x94, 0x6f, 0x7d, 0x27, 0x20, 0xd1,
|
||||
0x80, 0xa9, 0x67, 0xf8, 0x1a, 0xbc, 0x93, 0x84, 0xa7, 0x2b, 0xc5, 0x6c, 0x02, 0x5d, 0x7c, 0x63,
|
||||
0x98, 0x01, 0xd3, 0x40, 0x49, 0x55, 0x6e, 0x47, 0x26, 0x12, 0x82, 0xf0, 0x6b, 0x80, 0xaf, 0x0a,
|
||||
0x51, 0xe5, 0x3a, 0x6e, 0x04, 0x5d, 0x44, 0x98, 0xee, 0x70, 0x4e, 0x2d, 0x73, 0x13, 0x9c, 0x69,
|
||||
0x83, 0xc7, 0xf3, 0x0a, 0xe7, 0xe0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 0xce, 0x65, 0x35, 0x52, 0x5c, 0x6d, 0xcd, 0x4b, 0xe4, 0xea, 0xb1, 0xa6,
|
||||
0x48, 0x79, 0x32, 0xbe, 0x16, 0xd2, 0x90, 0xa9, 0x11, 0x8d, 0xe0, 0xdd, 0xe3, 0xdb, 0xab, 0xb4,
|
||||
0x5a, 0x71, 0x26, 0x36, 0xda, 0xbb, 0x87, 0x06, 0x6d, 0x31, 0xfd, 0x08, 0xc6, 0xb5, 0xc8, 0x6c,
|
||||
0x6f, 0x1f, 0x0d, 0x5b, 0xd2, 0xf0, 0x17, 0x02, 0xa3, 0x9a, 0x4a, 0x99, 0x8b, 0xac, 0xe4, 0xaa,
|
||||
0x5f, 0xc7, 0x45, 0x61, 0xfa, 0x75, 0x5c, 0x14, 0xf4, 0x15, 0xf4, 0x19, 0x2f, 0xab, 0x54, 0x9a,
|
||||
0x21, 0x78, 0x6e, 0xcb, 0x62, 0x7c, 0xab, 0x54, 0x32, 0x63, 0x45, 0x3f, 0x87, 0xf1, 0xde, 0x50,
|
||||
0xe9, 0xed, 0x1f, 0xce, 0xdf, 0xb3, 0x7e, 0x7b, 0x7a, 0xd6, 0x32, 0x0f, 0xff, 0xec, 0xc0, 0xb0,
|
||||
0x11, 0x99, 0x7e, 0x80, 0xb7, 0x08, 0x73, 0x1a, 0xce, 0x47, 0x36, 0x8a, 0xda, 0x34, 0xbc, 0x52,
|
||||
0x07, 0x40, 0xce, 0xea, 0x79, 0x22, 0x67, 0xaa, 0x8b, 0xea, 0x4a, 0x98, 0xcf, 0x36, 0xba, 0xa8,
|
||||
0xc4, 0x4c, 0x2b, 0xf1, 0xb2, 0xdd, 0xc4, 0xd9, 0x35, 0x5f, 0xe1, 0x3c, 0x79, 0xcc, 0x40, 0x3a,
|
||||
0xb3, 0xfb, 0x89, 0x0d, 0xd8, 0x5b, 0x71, 0xa3, 0x61, 0x76, 0x87, 0xcd, 0x40, 0xab, 0x5e, 0x8c,
|
||||
0xea, 0x81, 0x56, 0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3f, 0x25, 0x7f, 0xdc, 0x4f, 0xc9, 0x5f, 0xf7, 0x53, 0xf2, 0xeb, 0x3f, 0xd3, 0x77, 0x2e,
|
||||
0x7b, 0xf8, 0x4f, 0xe0, 0x93, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x58, 0xdf, 0x75, 0xf7, 0x19,
|
||||
0x08, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,3 +105,13 @@ message ImportValueRequest {
|
|||
repeated string ColumnKeys = 7;
|
||||
repeated int64 Values = 6;
|
||||
}
|
||||
|
||||
message TranslateKeysRequest {
|
||||
string Index = 1;
|
||||
string Field = 2;
|
||||
repeated string Keys = 3;
|
||||
}
|
||||
|
||||
message TranslateKeysResponse {
|
||||
repeated uint64 IDs = 3;
|
||||
}
|
||||
|
|
@ -22,14 +22,13 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
gohttp "net/http"
|
||||
"net/http/httptest"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
gohttp "net/http"
|
||||
|
||||
"github.com/pilosa/pilosa"
|
||||
"github.com/pilosa/pilosa/http"
|
||||
"github.com/pilosa/pilosa/server"
|
||||
|
|
@ -689,6 +688,91 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
t.Fatalf("unexpected body: %q", w.Body.String())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("translate keys", func(t *testing.T) {
|
||||
// create index
|
||||
w := httptest.NewRecorder()
|
||||
r := test.MustNewHTTPRequest("POST", "/index/i1-tr", strings.NewReader(`{"options":{"keys":true}}`))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if w.Body.String() != `{"success":true}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", w.Body.String())
|
||||
}
|
||||
|
||||
// create field
|
||||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/index/i1-tr/field/f1", strings.NewReader(`{"options":{"keys":true}}`))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if w.Body.String() != `{"success":true}`+"\n" {
|
||||
t.Fatalf("unexpected body: %q", w.Body.String())
|
||||
}
|
||||
|
||||
// set some bits
|
||||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/index/i1-tr/query", strings.NewReader(`Set("col1", f1="row1")Set("col2", f1="row1")`))
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
|
||||
// Generate request body for translate column keys request
|
||||
reqBody, err := cmd.API.Serializer.Marshal(&pilosa.TranslateKeysRequest{
|
||||
Index: "i1-tr",
|
||||
Keys: []string{"col1", "col2"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Generate protobuf request.
|
||||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/internal/translate/keys", bytes.NewReader(reqBody))
|
||||
r.Header.Set("Content-Type", "application/x-protobuf")
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
target := []uint64{1, 2}
|
||||
resp := pilosa.TranslateKeysResponse{}
|
||||
err = cmd.API.Serializer.Unmarshal(w.Body.Bytes(), &resp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(target, resp.IDs) {
|
||||
t.Fatalf("%v != %v", target, resp.IDs)
|
||||
}
|
||||
|
||||
// Generate request body for translate row keys request
|
||||
reqBody, err = cmd.API.Serializer.Marshal(&pilosa.TranslateKeysRequest{
|
||||
Index: "i1-tr",
|
||||
Field: "f1",
|
||||
Keys: []string{"row1"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Generate protobuf request.
|
||||
w = httptest.NewRecorder()
|
||||
r = test.MustNewHTTPRequest("POST", "/internal/translate/keys", bytes.NewReader(reqBody))
|
||||
r.Header.Set("Content-Type", "application/x-protobuf")
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
}
|
||||
target = []uint64{1}
|
||||
resp = pilosa.TranslateKeysResponse{}
|
||||
err = cmd.API.Serializer.Unmarshal(w.Body.Bytes(), &resp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(target, resp.IDs) {
|
||||
t.Fatalf("%v != %v", target, resp.IDs)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestClusterTranslator(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue