Пример #1
0
func mSet(c *table.Context, done chan *table.Call, zop bool, ma table.MSetArgs) {
	var err error
	if zop {
		if done == nil {
			_, err = c.ZmSet(ma)
		} else {
			_, err = c.GoZmSet(ma, done)
		}
	} else {
		if done == nil {
			_, err = c.MSet(ma)
		} else {
			_, err = c.GoMSet(ma, done)
		}
	}
	if err != nil {
		fmt.Printf("MSet failed: %s\n", err)
		os.Exit(1)
	}

	if *verbose != 0 && done == nil {
		for i := 0; i < len(ma); i++ {
			var one = ma[i]
			fmt.Printf("%02d) [%q\t%q]\t[%d\t%q]\n", i,
				one.RowKey, one.ColKey, one.Score, one.Value)
		}
	}
}
Пример #2
0
func testZScan(tc *table.Context) {
	// ZSET
	err := tc.ZSet(1, []byte("row2"), []byte("000"), []byte("v00"), 10, 0)
	if err != nil {
		fmt.Printf("ZSet failed: %s\n", err)
		return
	}

	// ZMSET
	var ma table.MSetArgs
	ma.Add(1, []byte("row2"), []byte("001"), []byte("v01"), 9, 0)
	ma.Add(1, []byte("row2"), []byte("002"), []byte("v02"), 6, 0)
	ma.Add(1, []byte("row2"), []byte("003"), []byte("v03"), 7, 0)
	ma.Add(1, []byte("row2"), []byte("004"), []byte("v04"), 8, 0)
	ma.Add(1, []byte("row2"), []byte("005"), []byte("v05"), -5, 0)
	_, err = tc.ZmSet(ma)
	if err != nil {
		fmt.Printf("ZmSet failed: %s\n", err)
		return
	}

	// ZSCAN
	r, err := tc.ZScan(1, []byte("row2"), true, true, 4)
	if err != nil {
		fmt.Printf("ZScan failed: %s\n", err)
		return
	}

	fmt.Println("ZSCAN result:")
	for {
		printScanReply(r)

		if r.End {
			fmt.Println("ZSCAN finished!")
			break
		} else {
			fmt.Println("ZSCAN has more records:")
		}

		r, err = tc.ScanMore(r)
		if err != nil {
			fmt.Printf("ScanMore failed: %s\n", err)
			return
		}
	}
}