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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/datastore/index.go ('k') | service/datastore/serialize/invertible.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/properties.go
diff --git a/service/datastore/properties.go b/service/datastore/properties.go
index 63156fe68da97b5f7ddf9f4c4600aa2c53861d49..bfdf6ef20ed05b820830df14cbbaf36f0084d0b8 100644
--- a/service/datastore/properties.go
+++ b/service/datastore/properties.go
@@ -111,8 +111,14 @@ type PropertyType byte
// These constants are in the order described by
// https://cloud.google.com/appengine/docs/go/datastore/entities#Go_Value_type_ordering
// with a slight divergence for the Int/Time split.
+//
// NOTE: this enum can only occupy 7 bits, because we use the high bit to encode
-// indexed/non-indexed. See typData.WriteBinary.
+// indexed/non-indexed, and we additionally require that all valid values and
+// all INVERTED valid values must never equal 0xFF or 0x00. The reason for this
+// constraint is that we must always be able to create a byte that sorts before
+// and after it.
+//
+// See "./serialize".WriteProperty and "impl/memory".increment for more info.
const (
PTNull PropertyType = iota
PTInt
@@ -146,9 +152,20 @@ const (
PTKey
PTBlobKey
+ // NOTE: THIS MUST BE LAST VALUE FOR THE init() ASSERTION BELOW TO WORK.
PTUnknown
)
+func init() {
+ if PTUnknown > 0x7e {
+ panic(
+ "PTUnknown (and therefore PropertyType) exceeds 0x7e. This conflicts " +
+ "with serialize.WriteProperty's use of the high bit to indicate " +
+ "NoIndex and/or \"impl/memory\".increment's ability to guarantee " +
+ "incrementability.")
+ }
+}
+
func (t PropertyType) String() string {
switch t {
case PTNull:
« 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