| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // HEAVILY adapted from github.com/golang/appengine/datastore | 5 // HEAVILY adapted from github.com/golang/appengine/datastore |
| 6 | 6 |
| 7 package rawdatastore | 7 package rawdatastore |
| 8 | 8 |
| 9 import ( | 9 import ( |
| 10 "errors" | |
| 11 "fmt" | 10 "fmt" |
| 12 "reflect" | 11 "reflect" |
| 13 "strconv" | 12 "strconv" |
| 14 "strings" | 13 "strings" |
| 15 "sync" | 14 "sync" |
| 16 "time" | 15 "time" |
| 17 "unicode" | 16 "unicode" |
| 18 | 17 |
| 19 "github.com/luci/gae" | |
| 20 "github.com/luci/gae/service/blobstore" | 18 "github.com/luci/gae/service/blobstore" |
| 19 "github.com/luci/luci-go/common/errors" |
| 21 ) | 20 ) |
| 22 | 21 |
| 23 // Entities with more than this many indexed properties will not be saved. | 22 // Entities with more than this many indexed properties will not be saved. |
| 24 const maxIndexedProperties = 20000 | 23 const maxIndexedProperties = 20000 |
| 25 | 24 |
| 26 type structTag struct { | 25 type structTag struct { |
| 27 name string | 26 name string |
| 28 idxSetting IndexSetting | 27 idxSetting IndexSetting |
| 29 isSlice bool | 28 isSlice bool |
| 30 substructCodec *structCodec | 29 substructCodec *structCodec |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 func typeMismatchReason(val interface{}, v reflect.Value) string { | 52 func typeMismatchReason(val interface{}, v reflect.Value) string { |
| 54 entityType := reflect.TypeOf(val) | 53 entityType := reflect.TypeOf(val) |
| 55 return fmt.Sprintf("type mismatch: %s versus %v", entityType, v.Type()) | 54 return fmt.Sprintf("type mismatch: %s versus %v", entityType, v.Type()) |
| 56 } | 55 } |
| 57 | 56 |
| 58 func (p *structPLS) Load(propMap PropertyMap) error { | 57 func (p *structPLS) Load(propMap PropertyMap) error { |
| 59 if err := p.Problem(); err != nil { | 58 if err := p.Problem(); err != nil { |
| 60 return err | 59 return err |
| 61 } | 60 } |
| 62 | 61 |
| 63 » convFailures := gae.MultiError(nil) | 62 » convFailures := errors.MultiError(nil) |
| 64 | 63 |
| 65 t := reflect.Type(nil) | 64 t := reflect.Type(nil) |
| 66 for name, props := range propMap { | 65 for name, props := range propMap { |
| 67 multiple := len(props) > 1 | 66 multiple := len(props) > 1 |
| 68 for i, prop := range props { | 67 for i, prop := range props { |
| 69 if reason := loadInner(p.c, p.o, i, name, prop, multiple
); reason != "" { | 68 if reason := loadInner(p.c, p.o, i, name, prop, multiple
); reason != "" { |
| 70 if t == nil { | 69 if t == nil { |
| 71 t = p.o.Type() | 70 t = p.o.Type() |
| 72 } | 71 } |
| 73 convFailures = append(convFailures, &ErrFieldMis
match{ | 72 convFailures = append(convFailures, &ErrFieldMis
match{ |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 case typeOfString: | 553 case typeOfString: |
| 555 return val, nil | 554 return val, nil |
| 556 case typeOfInt64: | 555 case typeOfInt64: |
| 557 if val == "" { | 556 if val == "" { |
| 558 return int64(0), nil | 557 return int64(0), nil |
| 559 } | 558 } |
| 560 return strconv.ParseInt(val, 10, 64) | 559 return strconv.ParseInt(val, 10, 64) |
| 561 } | 560 } |
| 562 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%s", t
, val) | 561 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%s", t
, val) |
| 563 } | 562 } |
| OLD | NEW |