Add database key for FT foreign tables
This commit is contained in:
parent
8ffdaa6d77
commit
61015c8f7a
2 changed files with 62 additions and 0 deletions
57
util/keys/ft.go
Normal file
57
util/keys/ft.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Copyright © 2016 Abcum Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package keys
|
||||
|
||||
// FT ...
|
||||
type FT struct {
|
||||
KV string
|
||||
NS string
|
||||
DB string
|
||||
TB string
|
||||
FT string
|
||||
}
|
||||
|
||||
// init initialises the key
|
||||
func (k *FT) init() *FT {
|
||||
return k
|
||||
}
|
||||
|
||||
func (k *FT) Copy() *FT {
|
||||
return &FT{
|
||||
KV: k.KV,
|
||||
NS: k.NS,
|
||||
DB: k.DB,
|
||||
TB: k.TB,
|
||||
FT: k.FT,
|
||||
}
|
||||
}
|
||||
|
||||
// Encode encodes the key into binary
|
||||
func (k *FT) Encode() []byte {
|
||||
k.init()
|
||||
return encode(k.KV, k.NS, "*", k.DB, "*", k.TB, "!", "t", k.FT)
|
||||
}
|
||||
|
||||
// Decode decodes the key from binary
|
||||
func (k *FT) Decode(data []byte) {
|
||||
k.init()
|
||||
decode(data, &k.KV, &k.NS, &skip, &k.DB, &skip, &k.TB, &skip, &skip, &k.FT)
|
||||
}
|
||||
|
||||
// String returns a string representation of the key
|
||||
func (k *FT) String() string {
|
||||
k.init()
|
||||
return output(k.KV, k.NS, "*", k.DB, "*", k.TB, "!", "t", k.FT)
|
||||
}
|
|
@ -150,6 +150,11 @@ func TestMain(t *testing.T) {
|
|||
obj: &LV{KV: "surreal", NS: "abcum", DB: "database", TB: "person", LV: "realtime"},
|
||||
new: &LV{},
|
||||
},
|
||||
{
|
||||
str: "/surreal/abcum/*/database/*/person/!/t/foreign",
|
||||
obj: &FT{KV: "surreal", NS: "abcum", DB: "database", TB: "person", FT: "foreign"},
|
||||
new: &FT{},
|
||||
},
|
||||
{
|
||||
str: "/surreal/abcum/*/database/*/person/*",
|
||||
obj: &Table{KV: "surreal", NS: "abcum", DB: "database", TB: "person"},
|
||||
|
|
Loading…
Reference in a new issue