App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | List of all members
google.appengine.ext.ndb.model._NestedCounter Class Reference
Inheritance diagram for google.appengine.ext.ndb.model._NestedCounter:

Public Member Functions

def __init__
 
def get
 
def increment
 

Detailed Description

A recursive counter for StructuredProperty deserialization.

Deserialization has some complicated rules to handle StructuredPropertys
that may or may not be empty. The simplest case is a leaf counter, where
the counter will return the index of the repeated value that last had this
leaf property written. When a non-leaf counter requested, this will return
the max of all its leaf values. This is due to the fact that the next index
that a full non-leaf property may be written to comes after all indices that
have part of that property written (otherwise, a partial entity would be
overwritten.

Consider an evaluation of the following structure:
-A
  -B
    -D
    -E
  -C
With the properties being deserialized in the order:

1) a.b.d = z
2) a.c = y
3) a.b = None
4) a = None
5) a.b.e = x
6) a.b.d = w

The counter state should be the following:
   a | a.b | a.b.d | a.b.e | a.c
0) 0    0      0       0      0
1) 1    1      1       0      0
2)@1   @1      1       0      1
3)@1*  @1*     1       0      1
4)@1*  @1*     1       0      1
5)@1*  @1*     1       1      1
6)@3   @3      3       1      1

Here, @ indicates that this counter value is actually a calculated value.
It is equal to the MAX of its sub-counters.

Note that in the * cases, our counters actually fall behind. We cannot
increase the counters when this happens because child properties have
not yet been fully populated. In theses cases, we'll have to do a series
of increments to catch up the counters following None deserializations.

The documentation for this class was generated from the following file: