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

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: stringSet everywhere Created 5 years, 3 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
« no previous file with comments | « service/datastore/index.go ('k') | service/datastore/serialize/invertible.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
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 //
114 // NOTE: this enum can only occupy 7 bits, because we use the high bit to encode 115 // NOTE: this enum can only occupy 7 bits, because we use the high bit to encode
115 // indexed/non-indexed. See typData.WriteBinary. 116 // indexed/non-indexed, and we additionally require that all valid values and
117 // all INVERTED valid values must never equal 0xFF or 0x00. The reason for this
118 // constraint is that we must always be able to create a byte that sorts before
119 // and after it.
120 //
121 // See "./serialize".WriteProperty and "impl/memory".increment for more info.
116 const ( 122 const (
117 PTNull PropertyType = iota 123 PTNull PropertyType = iota
118 PTInt 124 PTInt
119 125
120 // PTTime is a slight divergence from the way that datastore natively st ores 126 // PTTime is a slight divergence from the way that datastore natively st ores
121 // time. In datastore, times and integers actually sort together 127 // time. In datastore, times and integers actually sort together
122 // (apparently?). This is probably insane, and I don't want to add the 128 // (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' 129 // 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 130 // (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 131 // you're here because you implemented an app which relies on time.Time and
(...skipping 13 matching lines...) Expand all
139 PTBoolFalse 145 PTBoolFalse
140 PTBoolTrue 146 PTBoolTrue
141 147
142 PTBytes // []byte or datastore.ByteString 148 PTBytes // []byte or datastore.ByteString
143 PTString // string or string noindex 149 PTString // string or string noindex
144 PTFloat 150 PTFloat
145 PTGeoPoint 151 PTGeoPoint
146 PTKey 152 PTKey
147 PTBlobKey 153 PTBlobKey
148 154
155 // NOTE: THIS MUST BE LAST VALUE FOR THE init() ASSERTION BELOW TO WORK.
149 PTUnknown 156 PTUnknown
150 ) 157 )
151 158
159 func init() {
160 if PTUnknown > 0x7e {
161 panic(
162 "PTUnknown (and therefore PropertyType) exceeds 0x7e. Th is conflicts " +
163 "with serialize.WriteProperty's use of the high bit to indicate " +
164 "NoIndex and/or \"impl/memory\".increment's abil ity to guarantee " +
165 "incrementability.")
166 }
167 }
168
152 func (t PropertyType) String() string { 169 func (t PropertyType) String() string {
153 switch t { 170 switch t {
154 case PTNull: 171 case PTNull:
155 return "PTNull" 172 return "PTNull"
156 case PTInt: 173 case PTInt:
157 return "PTInt" 174 return "PTInt"
158 case PTTime: 175 case PTTime:
159 return "PTTime" 176 return "PTTime"
160 case PTBoolFalse: 177 case PTBoolFalse:
161 return "PTBoolFalse" 178 return "PTBoolFalse"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 dflt = UpconvertUnderlyingType(dflt) 515 dflt = UpconvertUnderlyingType(dflt)
499 cur, err := gm(key) 516 cur, err := gm(key)
500 if err != nil { 517 if err != nil {
501 return dflt 518 return dflt
502 } 519 }
503 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) { 520 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) {
504 return dflt 521 return dflt
505 } 522 }
506 return cur 523 return cur
507 } 524 }
OLDNEW
« no previous file with comments | « service/datastore/index.go ('k') | service/datastore/serialize/invertible.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698