示例#1
0
func (sm *StackMachine) testLocality() {
	tr, e := db.CreateTransaction()
	if e != nil {
		panic(e)
	}

	tr.Options().SetReadSystemKeys()
	boundaryKeys, e := db.LocalityGetBoundaryKeys(fdb.KeyRange{fdb.Key(""), fdb.Key("\xff\xff")}, 0, 0)
	if e != nil {
		panic(e)
	}

	for i := 0; i < len(boundaryKeys)-1; i++ {
		start := boundaryKeys[i]
		end := tr.GetKey(fdb.LastLessThan(boundaryKeys[i+1])).MustGet()

		startAddresses := tr.LocalityGetAddressesForKey(start).MustGet()
		endAddresses := tr.LocalityGetAddressesForKey(end).MustGet()

		for _, address1 := range startAddresses {
			found := false
			for _, address2 := range endAddresses {
				if address1 == address2 {
					found = true
					break
				}
			}
			if !found {
				panic("Locality not internally consistent.")
			}
		}
	}
}
示例#2
0
func GetLastKeyFuture(tr KeyReader, space subspace.Subspace) *LastKeyFuture {
	_, end := space.FDBRangeKeys()
	key := tr.GetKey(fdb.LastLessThan(end))

	return &LastKeyFuture{key, space}
}