Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: service/datastore/properties.go

Issue 1302813003: impl/memory: Implement Queries (Closed) Base URL: https://github.com/luci/gae.git@add_multi_iterator
Patch Set: inequalities work now Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 package datastore 5 package datastore
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 "math" 10 "math"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // PropertyType is a single-byte representation of the type of data contained 105 // PropertyType is a single-byte representation of the type of data contained
106 // in a Property. The specific values of this type information are chosen so 106 // in a Property. The specific values of this type information are chosen so
107 // that the types sort according to the order of types as sorted by the 107 // that the types sort according to the order of types as sorted by the
108 // datastore. 108 // datastore.
109 type PropertyType byte 109 type PropertyType byte
110 110
111 // These constants are in the order described by 111 // These constants are in the order described by
112 // https://cloud.google.com/appengine/docs/go/datastore/entities#Go_Value_type _ordering 112 // https://cloud.google.com/appengine/docs/go/datastore/entities#Go_Value_type _ordering
113 // with a slight divergence for the Int/Time split. 113 // with a slight divergence for the Int/Time split.
114 // NOTE: this enum can only occupy 7 bits, because we use the high bit to encode 114 // NOTE: this enum can only occupy 7 bits, because we use the high bit to encode
115 // indexed/non-indexed. See typData.WriteBinary. 115 // indexed/non-indexed. See serialize.WriteProperty.
116 const ( 116 const (
117 PTNull PropertyType = iota 117 PTNull PropertyType = iota
118 PTInt 118 PTInt
119 119
120 // PTTime is a slight divergence from the way that datastore natively st ores 120 // PTTime is a slight divergence from the way that datastore natively st ores
121 // time. In datastore, times and integers actually sort together 121 // time. In datastore, times and integers actually sort together
122 // (apparently?). This is probably insane, and I don't want to add the 122 // (apparently?). This is probably insane, and I don't want to add the
123 // complexity of field 'meaning' as a sparate concept from the field's ' type' 123 // complexity of field 'meaning' as a sparate concept from the field's ' type'
124 // (which is what datastore seems to do, judging from the protobufs). So if 124 // (which is what datastore seems to do, judging from the protobufs). So if
125 // you're here because you implemented an app which relies on time.Time and 125 // you're here because you implemented an app which relies on time.Time and
(...skipping 13 matching lines...) Expand all
139 PTBoolFalse 139 PTBoolFalse
140 PTBoolTrue 140 PTBoolTrue
141 141
142 PTBytes // []byte or datastore.ByteString 142 PTBytes // []byte or datastore.ByteString
143 PTString // string or string noindex 143 PTString // string or string noindex
144 PTFloat 144 PTFloat
145 PTGeoPoint 145 PTGeoPoint
146 PTKey 146 PTKey
147 PTBlobKey 147 PTBlobKey
148 148
149 // NOTE: THIS MUST BE LAST VALUE FOR THE init() ASSERTION BELOW TO WORK.
149 PTUnknown 150 PTUnknown
150 ) 151 )
151 152
153 func init() {
154 if PTUnknown > 0x7f {
dnj (Google) 2015/08/23 06:50:07 IMO put this check in "serialize", as it owns the
iannucci 2015/08/23 18:19:43 It's better here. There are actually 2 modules tha
155 panic(
156 "PTUnknown (and therefore PropertyType) exceeds 0x7f. Th is conflicts " +
157 "with serialize.WriteProperty's use of the high bit to indicate " +
158 "NoIndex.")
159 }
160 }
161
152 func (t PropertyType) String() string { 162 func (t PropertyType) String() string {
153 switch t { 163 switch t {
154 case PTNull: 164 case PTNull:
155 return "PTNull" 165 return "PTNull"
156 case PTInt: 166 case PTInt:
157 return "PTInt" 167 return "PTInt"
158 case PTTime: 168 case PTTime:
159 return "PTTime" 169 return "PTTime"
160 case PTBoolFalse: 170 case PTBoolFalse:
161 return "PTBoolFalse" 171 return "PTBoolFalse"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 dflt = UpconvertUnderlyingType(dflt) 508 dflt = UpconvertUnderlyingType(dflt)
499 cur, err := gm(key) 509 cur, err := gm(key)
500 if err != nil { 510 if err != nil {
501 return dflt 511 return dflt
502 } 512 }
503 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) { 513 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) {
504 return dflt 514 return dflt
505 } 515 }
506 return cur 516 return cur
507 } 517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698