Exemple #1
0
func benchMGet(cliPool *table.Pool, zop bool) {
	var colKeys = make([][]byte, *rangeNum)
	for i := 0; i < *rangeNum; i++ {
		colKeys[i] = []byte(fmt.Sprintf("%03d", i))
	}

	var op = func(v int, p *OpParam) {
		var rowKey = strconv.AppendInt(p.keyBuf, int64(v), 10)

		var ma table.MGetArgs
		for i := 0; i < len(colKeys); i++ {
			ma.Add(0, rowKey, colKeys[i], 0)
		}

		mGet(p.c, p.done, zop, ma)
	}

	if zop {
		benchmark(cliPool, fmt.Sprintf("ZMGET %d", *rangeNum), op)
	} else {
		benchmark(cliPool, fmt.Sprintf("MGET %d", *rangeNum), op)
	}
}
Exemple #2
0
func testMGet(tc *table.Context) {
	// MSET
	var ma table.MSetArgs
	ma.Add(1, []byte("row1"), []byte("col0"), []byte("v00"), 10, 0)
	ma.Add(1, []byte("row1"), []byte("col1"), []byte("v01"), 9, 0)
	ma.Add(1, []byte("row1"), []byte("col2"), []byte("v02"), 8, 0)
	ma.Add(1, []byte("row1"), []byte("col3"), []byte("v03"), 7, 0)
	ma.Add(1, []byte("row8"), []byte("col4"), []byte("v04"), 6, 0)
	_, err := tc.MSet(ma)
	if err != nil {
		fmt.Printf("Mset failed: %s\n", err)
		return
	}

	// MGET
	var mb table.MGetArgs
	mb.Add(1, []byte("row8"), []byte("col4"), 0)
	mb.Add(1, []byte("row1"), []byte("col2"), 0)
	mb.Add(1, []byte("row1"), []byte("col1"), 0)
	mb.Add(1, []byte("row1"), []byte("col3"), 0)
	mb.Add(1, []byte("row8"), []byte("not"), 0)
	r, err := tc.MGet(mb)
	if err != nil {
		fmt.Printf("Mget failed: %s\n", err)
		return
	}

	fmt.Println("MGET result:")
	for i := 0; i < len(r); i++ {
		if r[i].ErrCode < 0 {
			fmt.Printf("[%q\t%q]\tget failed with error %d!\n",
				r[i].RowKey, r[i].ColKey, r[i].ErrCode)
		} else if r[i].ErrCode > 0 {
			fmt.Printf("[%q\t%q]\tkey not exist!\n",
				r[i].RowKey, r[i].ColKey)
		} else {
			fmt.Printf("[%q\t%q]\t[%d\t%q]\n",
				r[i].RowKey, r[i].ColKey,
				r[i].Score, r[i].Value)
		}
	}
}