コード例 #1
0
ファイル: BasicSearch.go プロジェクト: botvs/HyperDex
func main() {
	var attrs client.Attributes
	var objs chan client.Attributes
	var errs chan client.Error
	_ = attrs
	_ = objs
	_ = errs
	var c *client.Client
	var err client.Error
	port, _ := strconv.Atoi(os.Args[2])
	c, er, _ := client.NewClient(os.Args[1], port)
	if er != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	objs, errs = c.Search("kv", []client.Predicate{{"v", "v1", client.EQUALS}})
	err = c.Put("kv", "k1", client.Attributes{"v": "v1"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	objs, errs = c.Search("kv", []client.Predicate{{"v", "v1", client.EQUALS}})
	err = c.Put("kv", "k2", client.Attributes{"v": "v1"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	objs, errs = c.Search("kv", []client.Predicate{{"v", "v1", client.EQUALS}})
	os.Exit(0)
}
コード例 #2
0
ファイル: CondPut.go プロジェクト: botvs/HyperDex
func main() {
	var attrs client.Attributes
	var objs chan client.Attributes
	var errs chan client.Error
	_ = attrs
	_ = objs
	_ = errs
	var c *client.Client
	var err client.Error
	port, _ := strconv.Atoi(os.Args[2])
	c, er, _ := client.NewClient(os.Args[1], port)
	if er != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.NOTFOUND {
		fmt.Printf("bad status: %d (should be NOTFOUND)\n", err)
	}
	err = c.Put("kv", "k", client.Attributes{"v": "v1"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v": "v1"}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v": "v1"})
		panic("objects not equal")
	}
	err = c.CondPut("kv", "k", []client.Predicate{{"v", "v2", client.EQUALS}}, client.Attributes{"v": "v3"})
	if err.Status != client.CMPFAIL {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v": "v1"}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v": "v1"})
		panic("objects not equal")
	}
	err = c.CondPut("kv", "k", []client.Predicate{{"v", "v1", client.EQUALS}}, client.Attributes{"v": "v3"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v": "v3"}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v": "v3"})
		panic("objects not equal")
	}
	os.Exit(0)
}
コード例 #3
0
ファイル: DataTypeListString.go プロジェクト: botvs/HyperDex
func main() {
	var attrs client.Attributes
	var objs chan client.Attributes
	var errs chan client.Error
	_ = attrs
	_ = objs
	_ = errs
	var c *client.Client
	var err client.Error
	port, _ := strconv.Atoi(os.Args[2])
	c, er, _ := client.NewClient(os.Args[1], port)
	if er != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	err = c.Put("kv", "k", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v": client.List{}}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v": client.List{}})
		panic("objects not equal")
	}
	err = c.Put("kv", "k", client.Attributes{"v": client.List{"A", "B", "C"}})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v": client.List{"A", "B", "C"}}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v": client.List{"A", "B", "C"}})
		panic("objects not equal")
	}
	err = c.Put("kv", "k", client.Attributes{"v": client.List{}})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	attrs, err = c.Get("kv", "k")
	if err.Status != client.SUCCESS {
		fmt.Printf("bad status: %d (should be SUCCESS)\n", err.Status)
	}
	if !sloppyEqualAttributes(attrs, client.Attributes{"v": client.List{}}) {
		fmt.Printf("%s %s\n", attrs, client.Map{"v": client.List{}})
		panic("objects not equal")
	}
	os.Exit(0)
}
コード例 #4
0
ファイル: RangeSearchString.go プロジェクト: botvs/HyperDex
func main() {
	var attrs client.Attributes
	var objs chan client.Attributes
	var errs chan client.Error
	_ = attrs
	_ = objs
	_ = errs
	var c *client.Client
	var err client.Error
	port, _ := strconv.Atoi(os.Args[2])
	c, er, _ := client.NewClient(os.Args[1], port)
	if er != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	err = c.Put("kv", "A", client.Attributes{"v": "A"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "B", client.Attributes{"v": "B"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "C", client.Attributes{"v": "C"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "D", client.Attributes{"v": "D"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "E", client.Attributes{"v": "E"})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.LESS_EQUAL}})
	objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.LESS_EQUAL}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.GREATER_EQUAL}})
	objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.GREATER_EQUAL}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.LESS_THAN}})
	objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.LESS_THAN}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", "C", client.GREATER_THAN}})
	objs, errs = c.Search("kv", []client.Predicate{{"v", "C", client.GREATER_THAN}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", "B", client.GREATER_EQUAL}, {"k", "D", client.LESS_EQUAL}})
	objs, errs = c.Search("kv", []client.Predicate{{"v", "B", client.GREATER_EQUAL}, {"v", "D", client.LESS_EQUAL}})
	os.Exit(0)
}
コード例 #5
0
ファイル: LengthString.go プロジェクト: botvs/HyperDex
func main() {
	var attrs client.Attributes
	var objs chan client.Attributes
	var errs chan client.Error
	_ = attrs
	_ = objs
	_ = errs
	var c *client.Client
	var err client.Error
	port, _ := strconv.Atoi(os.Args[2])
	c, er, _ := client.NewClient(os.Args[1], port)
	if er != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	err = c.Put("kv", "A", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "AB", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "ABC", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "ABCD", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "ABCDE", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	objs, errs = c.Search("kv", []client.Predicate{{"k", int64(1), client.LENGTH_EQUALS}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", int64(2), client.LENGTH_EQUALS}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", int64(3), client.LENGTH_EQUALS}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", int64(4), client.LENGTH_EQUALS}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", int64(5), client.LENGTH_EQUALS}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", int64(3), client.LENGTH_LESS_EQUAL}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", int64(3), client.LENGTH_GREATER_EQUAL}})
	os.Exit(0)
}
コード例 #6
0
ファイル: RegexSearch.go プロジェクト: botvs/HyperDex
func main() {
	var attrs client.Attributes
	var objs chan client.Attributes
	var errs chan client.Error
	_ = attrs
	_ = objs
	_ = errs
	var c *client.Client
	var err client.Error
	port, _ := strconv.Atoi(os.Args[2])
	c, er, _ := client.NewClient(os.Args[1], port)
	if er != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	err = c.Put("kv", "foo/foo/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/foo/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/foo/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/bar/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/bar/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/bar/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/baz/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/baz/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "foo/baz/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/foo/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/foo/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/foo/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/bar/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/bar/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/bar/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/baz/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/baz/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "bar/baz/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/foo/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/foo/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/foo/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/bar/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/bar/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/bar/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/baz/foo", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/baz/bar", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	err = c.Put("kv", "baz/baz/baz", client.Attributes{})
	if err.Status != client.SUCCESS {
		os.Exit(1)
	}
	objs, errs = c.Search("kv", []client.Predicate{{"k", "^foo", client.REGEX}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", "foo$", client.REGEX}})
	objs, errs = c.Search("kv", []client.Predicate{{"k", "^b.*/foo/.*$", client.REGEX}})
	os.Exit(0)
}