func (b *Buy) Validate(s *ddtxn.Store, nitr int) bool { good := true zero_cnt := 0 for j := 0; j < b.nproducts; j++ { var x int32 k := ddtxn.ProductKey(j) v, err := s.Get(k) if err != nil { if b.validate[j] != 0 { fmt.Printf("Validating key %v failed; store: none should have: %v\n", k, b.validate[j]) good = false } continue } x = v.Value().(int32) if x != b.validate[j] { fmt.Printf("Validating key %v failed; store: %v should have: %v\n", k, x, b.validate[j]) good = false } if x == 0 { zero_cnt++ } } if zero_cnt == b.nproducts && nitr > 10 { fmt.Printf("Bad: all zeroes!\n") dlog.Printf("Bad: all zeroes!\n") good = false } return good }
func (b *Big) Populate(s *ddtxn.Store, ex *ddtxn.ETransaction) { for i := 0; i < int(b.ni); i++ { k := ddtxn.BidKey(uint64(i)) s.CreateKey(k, int32(0), ddtxn.SUM) } for i := 0; i < b.np; i++ { k := ddtxn.ProductKey(i) s.CreateKey(k, int32(0), ddtxn.SUM) } }
func (b *Buy) Populate(s *ddtxn.Store, ex *ddtxn.ETransaction) { for i := 0; i < b.nbidders; i++ { k := ddtxn.ProductKey(i) s.CreateKey(k, int32(0), ddtxn.SUM) } dlog.Printf("Created %v products; np: %v\n", b.nbidders, b.nproducts) for i := 0; i < b.nbidders; i++ { k := ddtxn.UserKey(uint64(i)) s.CreateKey(k, "x", ddtxn.WRITE) } dlog.Printf("Created %v bidders\n", b.nbidders) dlog.Printf("Done with Populate") }
func (b *Rubis) Validate(s *ddtxn.Store, nitr int) bool { good := true zero_cnt := 0 for k, rat := range b.ratings { key := ddtxn.RatingKey(k) v, err := s.Get(key) if err != nil { fmt.Printf("Validating key %v failed; store: doesn't have rating for user %v: %v\n", key, k, err) good = false continue } r := v.Value().(int32) if r != rat { fmt.Printf("Validating key %v failed; store: has different rating for user %v (%v vs. %v): %v\n", key, k, rat, r, err) good = false continue } } for i := 0; i < b.nproducts; i++ { j := b.products[i] var x int32 k := ddtxn.MaxBidKey(j) v, err := s.Get(k) if err != nil { if b.maxes[i] != 0 { fmt.Printf("Validating key %v failed; store: none should have: %v\n", k, b.maxes[i]) good = false } continue } x = v.Value().(int32) if x != b.maxes[i] { fmt.Printf("Validating key %v failed; store: %v should have: %v\n", k, x, b.maxes[i]) good = false } if x == 0 { dlog.Printf("Saying x is zero %v %v\n", x, zero_cnt) zero_cnt++ } k = ddtxn.NumBidsKey(j) v, err = s.Get(k) if err != nil { if b.maxes[i] != 0 { fmt.Printf("Validating key %v failed for max bid; store: none should have: %v\n", k, b.num_bids[i]) good = false } continue } x = v.Value().(int32) if x != b.num_bids[i] { fmt.Printf("Validating key %v failed for number of bids; store: %v should have: %v\n", k, x, b.num_bids[i]) good = false } if x == 0 { dlog.Printf("Saying x is zero %v %v\n", x, zero_cnt) zero_cnt++ } } if zero_cnt == 2*b.nproducts && nitr > 10 { fmt.Printf("Bad: all zeroes!\n") dlog.Printf("Bad: all zeroes!\n") good = false } if good { dlog.Printf("Validate succeeded\n") } return good }