Пример #1
0
func (this *Summary) Get(stringID string) (*Summary, error) {
	var summary Summary

	key := this.key.StringKey(stringID)
	dsKey := key.GetKey()

	if dsKey == nil {
		return nil, ErrInvalidKey
	}

	err := datastore.Get(this.ctx, dsKey, &summary)

	if err != nil {
		return nil, err
	}

	summary.id = dsKey
	summary.key = key
	summary.ctx = this.ctx
	summary.trailk = this.trailk
	summary.root = this.root

	return &summary, nil
}
Пример #2
0
func (this *Distribution) Get(n float64) (*Distribution, error) {
	var distribution Distribution

	rateInt := this.reduceRate(n)
	key := this.key.IntKey(rateInt + 1)
	dsKey := key.GetKey()

	if dsKey == nil {
		return nil, ErrInvalidKey
	}

	err := datastore.Get(this.ctx, dsKey, &distribution)

	if err != nil {
		return nil, err
	}

	distribution.id = dsKey
	distribution.key = key
	distribution.ctx = this.ctx
	distribution.trailk = this.trailk

	return &distribution, nil
}