3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 from google
.net
.proto
import ProtocolBuffer
20 import dummy_thread
as thread
22 __pychecker__
= """maxreturns=0 maxbranches=0 no-callinit
23 unusednames=printElemNumber,debug_strs no-special"""
25 from google
.appengine
.api
.api_base_pb
import Integer64Proto
;
26 from google
.appengine
.api
.api_base_pb
import StringProto
;
27 from google
.appengine
.api
.api_base_pb
import VoidProto
;
28 from google
.appengine
.datastore
.entity_pb
import CompositeIndex
29 from google
.appengine
.datastore
.entity_pb
import EntityProto
30 from google
.appengine
.datastore
.entity_pb
import Index
31 from google
.appengine
.datastore
.entity_pb
import Property
32 from google
.appengine
.datastore
.entity_pb
import Reference
33 class Transaction(ProtocolBuffer
.ProtocolMessage
):
37 def __init__(self
, contents
=None):
38 if contents
is not None: self
.MergeFromString(contents
)
40 def handle(self
): return self
.handle_
42 def set_handle(self
, x
):
46 def clear_handle(self
):
51 def has_handle(self
): return self
.has_handle_
54 def MergeFrom(self
, x
):
56 if (x
.has_handle()): self
.set_handle(x
.handle())
59 if x
is self
: return 1
60 if self
.has_handle_
!= x
.has_handle_
: return 0
61 if self
.has_handle_
and self
.handle_
!= x
.handle_
: return 0
64 def IsInitialized(self
, debug_strs
=None):
66 if (not self
.has_handle_
):
68 if debug_strs
is not None:
69 debug_strs
.append('Required field: handle not set.')
79 def OutputUnchecked(self
, out
):
81 out
.put64(self
.handle_
)
83 def TryMerge(self
, d
):
87 self
.set_handle(d
.get64())
89 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
93 def __str__(self
, prefix
="", printElemNumber
=0):
95 if self
.has_handle_
: res
+=prefix
+("handle: %s\n" % self
.DebugFormatFixed64(self
.handle_
))
106 ProtocolBuffer
.Encoder
.NUMERIC
,
107 ProtocolBuffer
.Encoder
.DOUBLE
,
112 _STYLE_CONTENT_TYPE
= """"""
113 class Query_Filter(ProtocolBuffer
.ProtocolMessage
):
116 LESS_THAN_OR_EQUAL
= 2
118 GREATER_THAN_OR_EQUAL
= 4
125 2: "LESS_THAN_OR_EQUAL",
127 4: "GREATER_THAN_OR_EQUAL",
133 def Operator_Name(cls
, x
): return cls
._Operator
_NAMES
.get(x
, "")
134 Operator_Name
= classmethod(Operator_Name
)
139 def __init__(self
, contents
=None):
141 if contents
is not None: self
.MergeFromString(contents
)
143 def op(self
): return self
.op_
154 def has_op(self
): return self
.has_op_
156 def property_size(self
): return len(self
.property_
)
157 def property_list(self
): return self
.property_
159 def property(self
, i
):
160 return self
.property_
[i
]
162 def mutable_property(self
, i
):
163 return self
.property_
[i
]
165 def add_property(self
):
167 self
.property_
.append(x
)
170 def clear_property(self
):
173 def MergeFrom(self
, x
):
175 if (x
.has_op()): self
.set_op(x
.op())
176 for i
in xrange(x
.property_size()): self
.add_property().CopyFrom(x
.property(i
))
179 if x
is self
: return 1
180 if self
.has_op_
!= x
.has_op_
: return 0
181 if self
.has_op_
and self
.op_
!= x
.op_
: return 0
182 if len(self
.property_
) != len(x
.property_
): return 0
183 for e1
, e2
in zip(self
.property_
, x
.property_
):
184 if e1
!= e2
: return 0
187 def IsInitialized(self
, debug_strs
=None):
189 if (not self
.has_op_
):
191 if debug_strs
is not None:
192 debug_strs
.append('Required field: op not set.')
193 for p
in self
.property_
:
194 if not p
.IsInitialized(debug_strs
): initialized
=0
199 n
+= self
.lengthVarInt64(self
.op_
)
200 n
+= 1 * len(self
.property_
)
201 for i
in xrange(len(self
.property_
)): n
+= self
.lengthString(self
.property_
[i
].ByteSize())
206 self
.clear_property()
208 def OutputUnchecked(self
, out
):
210 out
.putVarInt32(self
.op_
)
211 for i
in xrange(len(self
.property_
)):
213 out
.putVarInt32(self
.property_
[i
].ByteSize())
214 self
.property_
[i
].OutputUnchecked(out
)
216 def TryMerge(self
, d
):
221 self
.set_op(d
.getVarInt32())
224 length
= d
.getVarInt32()
225 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
227 self
.add_property().TryMerge(tmp
)
229 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
233 def __str__(self
, prefix
="", printElemNumber
=0):
235 if self
.has_op_
: res
+=prefix
+("op: %s\n" % self
.DebugFormatInt32(self
.op_
))
237 for e
in self
.property_
:
239 if printElemNumber
: elm
="(%d)" % cnt
240 res
+=prefix
+("property%s <\n" % elm
)
241 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
246 class Query_Order(ProtocolBuffer
.ProtocolMessage
):
256 def Direction_Name(cls
, x
): return cls
._Direction
_NAMES
.get(x
, "")
257 Direction_Name
= classmethod(Direction_Name
)
264 def __init__(self
, contents
=None):
265 if contents
is not None: self
.MergeFromString(contents
)
267 def property(self
): return self
.property_
269 def set_property(self
, x
):
270 self
.has_property_
= 1
273 def clear_property(self
):
274 if self
.has_property_
:
275 self
.has_property_
= 0
278 def has_property(self
): return self
.has_property_
280 def direction(self
): return self
.direction_
282 def set_direction(self
, x
):
283 self
.has_direction_
= 1
286 def clear_direction(self
):
287 if self
.has_direction_
:
288 self
.has_direction_
= 0
291 def has_direction(self
): return self
.has_direction_
294 def MergeFrom(self
, x
):
296 if (x
.has_property()): self
.set_property(x
.property())
297 if (x
.has_direction()): self
.set_direction(x
.direction())
300 if x
is self
: return 1
301 if self
.has_property_
!= x
.has_property_
: return 0
302 if self
.has_property_
and self
.property_
!= x
.property_
: return 0
303 if self
.has_direction_
!= x
.has_direction_
: return 0
304 if self
.has_direction_
and self
.direction_
!= x
.direction_
: return 0
307 def IsInitialized(self
, debug_strs
=None):
309 if (not self
.has_property_
):
311 if debug_strs
is not None:
312 debug_strs
.append('Required field: property not set.')
317 n
+= self
.lengthString(len(self
.property_
))
318 if (self
.has_direction_
): n
+= 1 + self
.lengthVarInt64(self
.direction_
)
322 self
.clear_property()
323 self
.clear_direction()
325 def OutputUnchecked(self
, out
):
327 out
.putPrefixedString(self
.property_
)
328 if (self
.has_direction_
):
330 out
.putVarInt32(self
.direction_
)
332 def TryMerge(self
, d
):
337 self
.set_property(d
.getPrefixedString())
340 self
.set_direction(d
.getVarInt32())
342 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
346 def __str__(self
, prefix
="", printElemNumber
=0):
348 if self
.has_property_
: res
+=prefix
+("property: %s\n" % self
.DebugFormatString(self
.property_
))
349 if self
.has_direction_
: res
+=prefix
+("direction: %s\n" % self
.DebugFormatInt32(self
.direction_
))
352 class Query(ProtocolBuffer
.ProtocolMessage
):
364 def Hint_Name(cls
, x
): return cls
._Hint
_NAMES
.get(x
, "")
365 Hint_Name
= classmethod(Hint_Name
)
373 has_search_query_
= 0
381 has_require_perfect_plan_
= 0
382 require_perfect_plan_
= 0
386 def __init__(self
, contents
=None):
389 self
.composite_index_
= []
390 self
.lazy_init_lock_
= thread
.allocate_lock()
391 if contents
is not None: self
.MergeFromString(contents
)
393 def app(self
): return self
.app_
395 def set_app(self
, x
):
404 def has_app(self
): return self
.has_app_
406 def kind(self
): return self
.kind_
408 def set_kind(self
, x
):
412 def clear_kind(self
):
417 def has_kind(self
): return self
.has_kind_
420 if self
.ancestor_
is None:
421 self
.lazy_init_lock_
.acquire()
423 if self
.ancestor_
is None: self
.ancestor_
= Reference()
425 self
.lazy_init_lock_
.release()
426 return self
.ancestor_
428 def mutable_ancestor(self
): self
.has_ancestor_
= 1; return self
.ancestor()
430 def clear_ancestor(self
):
431 if self
.has_ancestor_
:
432 self
.has_ancestor_
= 0;
433 if self
.ancestor_
is not None: self
.ancestor_
.Clear()
435 def has_ancestor(self
): return self
.has_ancestor_
437 def filter_size(self
): return len(self
.filter_
)
438 def filter_list(self
): return self
.filter_
441 return self
.filter_
[i
]
443 def mutable_filter(self
, i
):
444 return self
.filter_
[i
]
446 def add_filter(self
):
448 self
.filter_
.append(x
)
451 def clear_filter(self
):
453 def search_query(self
): return self
.search_query_
455 def set_search_query(self
, x
):
456 self
.has_search_query_
= 1
457 self
.search_query_
= x
459 def clear_search_query(self
):
460 if self
.has_search_query_
:
461 self
.has_search_query_
= 0
462 self
.search_query_
= ""
464 def has_search_query(self
): return self
.has_search_query_
466 def order_size(self
): return len(self
.order_
)
467 def order_list(self
): return self
.order_
470 return self
.order_
[i
]
472 def mutable_order(self
, i
):
473 return self
.order_
[i
]
477 self
.order_
.append(x
)
480 def clear_order(self
):
482 def hint(self
): return self
.hint_
484 def set_hint(self
, x
):
488 def clear_hint(self
):
493 def has_hint(self
): return self
.has_hint_
495 def offset(self
): return self
.offset_
497 def set_offset(self
, x
):
501 def clear_offset(self
):
506 def has_offset(self
): return self
.has_offset_
508 def limit(self
): return self
.limit_
510 def set_limit(self
, x
):
514 def clear_limit(self
):
519 def has_limit(self
): return self
.has_limit_
521 def composite_index_size(self
): return len(self
.composite_index_
)
522 def composite_index_list(self
): return self
.composite_index_
524 def composite_index(self
, i
):
525 return self
.composite_index_
[i
]
527 def mutable_composite_index(self
, i
):
528 return self
.composite_index_
[i
]
530 def add_composite_index(self
):
532 self
.composite_index_
.append(x
)
535 def clear_composite_index(self
):
536 self
.composite_index_
= []
537 def require_perfect_plan(self
): return self
.require_perfect_plan_
539 def set_require_perfect_plan(self
, x
):
540 self
.has_require_perfect_plan_
= 1
541 self
.require_perfect_plan_
= x
543 def clear_require_perfect_plan(self
):
544 if self
.has_require_perfect_plan_
:
545 self
.has_require_perfect_plan_
= 0
546 self
.require_perfect_plan_
= 0
548 def has_require_perfect_plan(self
): return self
.has_require_perfect_plan_
550 def keys_only(self
): return self
.keys_only_
552 def set_keys_only(self
, x
):
553 self
.has_keys_only_
= 1
556 def clear_keys_only(self
):
557 if self
.has_keys_only_
:
558 self
.has_keys_only_
= 0
561 def has_keys_only(self
): return self
.has_keys_only_
564 def MergeFrom(self
, x
):
566 if (x
.has_app()): self
.set_app(x
.app())
567 if (x
.has_kind()): self
.set_kind(x
.kind())
568 if (x
.has_ancestor()): self
.mutable_ancestor().MergeFrom(x
.ancestor())
569 for i
in xrange(x
.filter_size()): self
.add_filter().CopyFrom(x
.filter(i
))
570 if (x
.has_search_query()): self
.set_search_query(x
.search_query())
571 for i
in xrange(x
.order_size()): self
.add_order().CopyFrom(x
.order(i
))
572 if (x
.has_hint()): self
.set_hint(x
.hint())
573 if (x
.has_offset()): self
.set_offset(x
.offset())
574 if (x
.has_limit()): self
.set_limit(x
.limit())
575 for i
in xrange(x
.composite_index_size()): self
.add_composite_index().CopyFrom(x
.composite_index(i
))
576 if (x
.has_require_perfect_plan()): self
.set_require_perfect_plan(x
.require_perfect_plan())
577 if (x
.has_keys_only()): self
.set_keys_only(x
.keys_only())
580 if x
is self
: return 1
581 if self
.has_app_
!= x
.has_app_
: return 0
582 if self
.has_app_
and self
.app_
!= x
.app_
: return 0
583 if self
.has_kind_
!= x
.has_kind_
: return 0
584 if self
.has_kind_
and self
.kind_
!= x
.kind_
: return 0
585 if self
.has_ancestor_
!= x
.has_ancestor_
: return 0
586 if self
.has_ancestor_
and self
.ancestor_
!= x
.ancestor_
: return 0
587 if len(self
.filter_
) != len(x
.filter_
): return 0
588 for e1
, e2
in zip(self
.filter_
, x
.filter_
):
589 if e1
!= e2
: return 0
590 if self
.has_search_query_
!= x
.has_search_query_
: return 0
591 if self
.has_search_query_
and self
.search_query_
!= x
.search_query_
: return 0
592 if len(self
.order_
) != len(x
.order_
): return 0
593 for e1
, e2
in zip(self
.order_
, x
.order_
):
594 if e1
!= e2
: return 0
595 if self
.has_hint_
!= x
.has_hint_
: return 0
596 if self
.has_hint_
and self
.hint_
!= x
.hint_
: return 0
597 if self
.has_offset_
!= x
.has_offset_
: return 0
598 if self
.has_offset_
and self
.offset_
!= x
.offset_
: return 0
599 if self
.has_limit_
!= x
.has_limit_
: return 0
600 if self
.has_limit_
and self
.limit_
!= x
.limit_
: return 0
601 if len(self
.composite_index_
) != len(x
.composite_index_
): return 0
602 for e1
, e2
in zip(self
.composite_index_
, x
.composite_index_
):
603 if e1
!= e2
: return 0
604 if self
.has_require_perfect_plan_
!= x
.has_require_perfect_plan_
: return 0
605 if self
.has_require_perfect_plan_
and self
.require_perfect_plan_
!= x
.require_perfect_plan_
: return 0
606 if self
.has_keys_only_
!= x
.has_keys_only_
: return 0
607 if self
.has_keys_only_
and self
.keys_only_
!= x
.keys_only_
: return 0
610 def IsInitialized(self
, debug_strs
=None):
612 if (not self
.has_app_
):
614 if debug_strs
is not None:
615 debug_strs
.append('Required field: app not set.')
616 if (self
.has_ancestor_
and not self
.ancestor_
.IsInitialized(debug_strs
)): initialized
= 0
617 for p
in self
.filter_
:
618 if not p
.IsInitialized(debug_strs
): initialized
=0
619 for p
in self
.order_
:
620 if not p
.IsInitialized(debug_strs
): initialized
=0
621 for p
in self
.composite_index_
:
622 if not p
.IsInitialized(debug_strs
): initialized
=0
627 n
+= self
.lengthString(len(self
.app_
))
628 if (self
.has_kind_
): n
+= 1 + self
.lengthString(len(self
.kind_
))
629 if (self
.has_ancestor_
): n
+= 2 + self
.lengthString(self
.ancestor_
.ByteSize())
630 n
+= 2 * len(self
.filter_
)
631 for i
in xrange(len(self
.filter_
)): n
+= self
.filter_
[i
].ByteSize()
632 if (self
.has_search_query_
): n
+= 1 + self
.lengthString(len(self
.search_query_
))
633 n
+= 2 * len(self
.order_
)
634 for i
in xrange(len(self
.order_
)): n
+= self
.order_
[i
].ByteSize()
635 if (self
.has_hint_
): n
+= 2 + self
.lengthVarInt64(self
.hint_
)
636 if (self
.has_offset_
): n
+= 1 + self
.lengthVarInt64(self
.offset_
)
637 if (self
.has_limit_
): n
+= 2 + self
.lengthVarInt64(self
.limit_
)
638 n
+= 2 * len(self
.composite_index_
)
639 for i
in xrange(len(self
.composite_index_
)): n
+= self
.lengthString(self
.composite_index_
[i
].ByteSize())
640 if (self
.has_require_perfect_plan_
): n
+= 3
641 if (self
.has_keys_only_
): n
+= 3
647 self
.clear_ancestor()
649 self
.clear_search_query()
654 self
.clear_composite_index()
655 self
.clear_require_perfect_plan()
656 self
.clear_keys_only()
658 def OutputUnchecked(self
, out
):
660 out
.putPrefixedString(self
.app_
)
663 out
.putPrefixedString(self
.kind_
)
664 for i
in xrange(len(self
.filter_
)):
666 self
.filter_
[i
].OutputUnchecked(out
)
668 if (self
.has_search_query_
):
670 out
.putPrefixedString(self
.search_query_
)
671 for i
in xrange(len(self
.order_
)):
673 self
.order_
[i
].OutputUnchecked(out
)
675 if (self
.has_offset_
):
677 out
.putVarInt32(self
.offset_
)
678 if (self
.has_limit_
):
680 out
.putVarInt32(self
.limit_
)
681 if (self
.has_ancestor_
):
683 out
.putVarInt32(self
.ancestor_
.ByteSize())
684 self
.ancestor_
.OutputUnchecked(out
)
687 out
.putVarInt32(self
.hint_
)
688 for i
in xrange(len(self
.composite_index_
)):
690 out
.putVarInt32(self
.composite_index_
[i
].ByteSize())
691 self
.composite_index_
[i
].OutputUnchecked(out
)
692 if (self
.has_require_perfect_plan_
):
694 out
.putBoolean(self
.require_perfect_plan_
)
695 if (self
.has_keys_only_
):
697 out
.putBoolean(self
.keys_only_
)
699 def TryMerge(self
, d
):
703 self
.set_app(d
.getPrefixedString())
706 self
.set_kind(d
.getPrefixedString())
709 self
.add_filter().TryMerge(d
)
712 self
.set_search_query(d
.getPrefixedString())
715 self
.add_order().TryMerge(d
)
718 self
.set_offset(d
.getVarInt32())
721 self
.set_limit(d
.getVarInt32())
724 length
= d
.getVarInt32()
725 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
727 self
.mutable_ancestor().TryMerge(tmp
)
730 self
.set_hint(d
.getVarInt32())
733 length
= d
.getVarInt32()
734 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
736 self
.add_composite_index().TryMerge(tmp
)
739 self
.set_require_perfect_plan(d
.getBoolean())
742 self
.set_keys_only(d
.getBoolean())
744 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
748 def __str__(self
, prefix
="", printElemNumber
=0):
750 if self
.has_app_
: res
+=prefix
+("app: %s\n" % self
.DebugFormatString(self
.app_
))
751 if self
.has_kind_
: res
+=prefix
+("kind: %s\n" % self
.DebugFormatString(self
.kind_
))
752 if self
.has_ancestor_
:
753 res
+=prefix
+"ancestor <\n"
754 res
+=self
.ancestor_
.__str
__(prefix
+ " ", printElemNumber
)
757 for e
in self
.filter_
:
759 if printElemNumber
: elm
="(%d)" % cnt
760 res
+=prefix
+("Filter%s {\n" % elm
)
761 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
764 if self
.has_search_query_
: res
+=prefix
+("search_query: %s\n" % self
.DebugFormatString(self
.search_query_
))
766 for e
in self
.order_
:
768 if printElemNumber
: elm
="(%d)" % cnt
769 res
+=prefix
+("Order%s {\n" % elm
)
770 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
773 if self
.has_hint_
: res
+=prefix
+("hint: %s\n" % self
.DebugFormatInt32(self
.hint_
))
774 if self
.has_offset_
: res
+=prefix
+("offset: %s\n" % self
.DebugFormatInt32(self
.offset_
))
775 if self
.has_limit_
: res
+=prefix
+("limit: %s\n" % self
.DebugFormatInt32(self
.limit_
))
777 for e
in self
.composite_index_
:
779 if printElemNumber
: elm
="(%d)" % cnt
780 res
+=prefix
+("composite_index%s <\n" % elm
)
781 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
784 if self
.has_require_perfect_plan_
: res
+=prefix
+("require_perfect_plan: %s\n" % self
.DebugFormatBool(self
.require_perfect_plan_
))
785 if self
.has_keys_only_
: res
+=prefix
+("keys_only: %s\n" % self
.DebugFormatBool(self
.keys_only_
))
801 kcomposite_index
= 19
802 krequire_perfect_plan
= 20
826 "require_perfect_plan",
831 ProtocolBuffer
.Encoder
.NUMERIC
,
832 ProtocolBuffer
.Encoder
.STRING
,
834 ProtocolBuffer
.Encoder
.MAX_TYPE
,
836 ProtocolBuffer
.Encoder
.STRING
,
838 ProtocolBuffer
.Encoder
.STARTGROUP
,
840 ProtocolBuffer
.Encoder
.MAX_TYPE
,
842 ProtocolBuffer
.Encoder
.NUMERIC
,
844 ProtocolBuffer
.Encoder
.MAX_TYPE
,
846 ProtocolBuffer
.Encoder
.STRING
,
848 ProtocolBuffer
.Encoder
.STARTGROUP
,
850 ProtocolBuffer
.Encoder
.STRING
,
852 ProtocolBuffer
.Encoder
.NUMERIC
,
854 ProtocolBuffer
.Encoder
.NUMERIC
,
856 ProtocolBuffer
.Encoder
.MAX_TYPE
,
858 ProtocolBuffer
.Encoder
.STRING
,
860 ProtocolBuffer
.Encoder
.MAX_TYPE
,
862 ProtocolBuffer
.Encoder
.NUMERIC
,
864 ProtocolBuffer
.Encoder
.STRING
,
866 ProtocolBuffer
.Encoder
.NUMERIC
,
868 ProtocolBuffer
.Encoder
.STRING
,
870 ProtocolBuffer
.Encoder
.NUMERIC
,
872 ProtocolBuffer
.Encoder
.NUMERIC
,
877 _STYLE_CONTENT_TYPE
= """"""
878 class QueryExplanation(ProtocolBuffer
.ProtocolMessage
):
879 has_native_ancestor_
= 0
881 has_native_offset_
= 0
883 has_native_limit_
= 0
886 def __init__(self
, contents
=None):
887 self
.native_index_
= []
888 if contents
is not None: self
.MergeFromString(contents
)
890 def native_ancestor(self
): return self
.native_ancestor_
892 def set_native_ancestor(self
, x
):
893 self
.has_native_ancestor_
= 1
894 self
.native_ancestor_
= x
896 def clear_native_ancestor(self
):
897 if self
.has_native_ancestor_
:
898 self
.has_native_ancestor_
= 0
899 self
.native_ancestor_
= 0
901 def has_native_ancestor(self
): return self
.has_native_ancestor_
903 def native_index_size(self
): return len(self
.native_index_
)
904 def native_index_list(self
): return self
.native_index_
906 def native_index(self
, i
):
907 return self
.native_index_
[i
]
909 def mutable_native_index(self
, i
):
910 return self
.native_index_
[i
]
912 def add_native_index(self
):
914 self
.native_index_
.append(x
)
917 def clear_native_index(self
):
918 self
.native_index_
= []
919 def native_offset(self
): return self
.native_offset_
921 def set_native_offset(self
, x
):
922 self
.has_native_offset_
= 1
923 self
.native_offset_
= x
925 def clear_native_offset(self
):
926 if self
.has_native_offset_
:
927 self
.has_native_offset_
= 0
928 self
.native_offset_
= 0
930 def has_native_offset(self
): return self
.has_native_offset_
932 def native_limit(self
): return self
.native_limit_
934 def set_native_limit(self
, x
):
935 self
.has_native_limit_
= 1
936 self
.native_limit_
= x
938 def clear_native_limit(self
):
939 if self
.has_native_limit_
:
940 self
.has_native_limit_
= 0
941 self
.native_limit_
= 0
943 def has_native_limit(self
): return self
.has_native_limit_
946 def MergeFrom(self
, x
):
948 if (x
.has_native_ancestor()): self
.set_native_ancestor(x
.native_ancestor())
949 for i
in xrange(x
.native_index_size()): self
.add_native_index().CopyFrom(x
.native_index(i
))
950 if (x
.has_native_offset()): self
.set_native_offset(x
.native_offset())
951 if (x
.has_native_limit()): self
.set_native_limit(x
.native_limit())
954 if x
is self
: return 1
955 if self
.has_native_ancestor_
!= x
.has_native_ancestor_
: return 0
956 if self
.has_native_ancestor_
and self
.native_ancestor_
!= x
.native_ancestor_
: return 0
957 if len(self
.native_index_
) != len(x
.native_index_
): return 0
958 for e1
, e2
in zip(self
.native_index_
, x
.native_index_
):
959 if e1
!= e2
: return 0
960 if self
.has_native_offset_
!= x
.has_native_offset_
: return 0
961 if self
.has_native_offset_
and self
.native_offset_
!= x
.native_offset_
: return 0
962 if self
.has_native_limit_
!= x
.has_native_limit_
: return 0
963 if self
.has_native_limit_
and self
.native_limit_
!= x
.native_limit_
: return 0
966 def IsInitialized(self
, debug_strs
=None):
968 for p
in self
.native_index_
:
969 if not p
.IsInitialized(debug_strs
): initialized
=0
974 if (self
.has_native_ancestor_
): n
+= 2
975 n
+= 1 * len(self
.native_index_
)
976 for i
in xrange(len(self
.native_index_
)): n
+= self
.lengthString(self
.native_index_
[i
].ByteSize())
977 if (self
.has_native_offset_
): n
+= 1 + self
.lengthVarInt64(self
.native_offset_
)
978 if (self
.has_native_limit_
): n
+= 1 + self
.lengthVarInt64(self
.native_limit_
)
982 self
.clear_native_ancestor()
983 self
.clear_native_index()
984 self
.clear_native_offset()
985 self
.clear_native_limit()
987 def OutputUnchecked(self
, out
):
988 if (self
.has_native_ancestor_
):
990 out
.putBoolean(self
.native_ancestor_
)
991 for i
in xrange(len(self
.native_index_
)):
993 out
.putVarInt32(self
.native_index_
[i
].ByteSize())
994 self
.native_index_
[i
].OutputUnchecked(out
)
995 if (self
.has_native_offset_
):
997 out
.putVarInt32(self
.native_offset_
)
998 if (self
.has_native_limit_
):
1000 out
.putVarInt32(self
.native_limit_
)
1002 def TryMerge(self
, d
):
1003 while d
.avail() > 0:
1004 tt
= d
.getVarInt32()
1006 self
.set_native_ancestor(d
.getBoolean())
1009 length
= d
.getVarInt32()
1010 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1012 self
.add_native_index().TryMerge(tmp
)
1015 self
.set_native_offset(d
.getVarInt32())
1018 self
.set_native_limit(d
.getVarInt32())
1020 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1024 def __str__(self
, prefix
="", printElemNumber
=0):
1026 if self
.has_native_ancestor_
: res
+=prefix
+("native_ancestor: %s\n" % self
.DebugFormatBool(self
.native_ancestor_
))
1028 for e
in self
.native_index_
:
1030 if printElemNumber
: elm
="(%d)" % cnt
1031 res
+=prefix
+("native_index%s <\n" % elm
)
1032 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1035 if self
.has_native_offset_
: res
+=prefix
+("native_offset: %s\n" % self
.DebugFormatInt32(self
.native_offset_
))
1036 if self
.has_native_limit_
: res
+=prefix
+("native_limit: %s\n" % self
.DebugFormatInt32(self
.native_limit_
))
1039 knative_ancestor
= 1
1053 ProtocolBuffer
.Encoder
.NUMERIC
,
1054 ProtocolBuffer
.Encoder
.NUMERIC
,
1056 ProtocolBuffer
.Encoder
.STRING
,
1058 ProtocolBuffer
.Encoder
.NUMERIC
,
1060 ProtocolBuffer
.Encoder
.NUMERIC
,
1065 _STYLE_CONTENT_TYPE
= """"""
1066 class Cursor(ProtocolBuffer
.ProtocolMessage
):
1070 def __init__(self
, contents
=None):
1071 if contents
is not None: self
.MergeFromString(contents
)
1073 def cursor(self
): return self
.cursor_
1075 def set_cursor(self
, x
):
1076 self
.has_cursor_
= 1
1079 def clear_cursor(self
):
1080 if self
.has_cursor_
:
1081 self
.has_cursor_
= 0
1084 def has_cursor(self
): return self
.has_cursor_
1087 def MergeFrom(self
, x
):
1088 assert x
is not self
1089 if (x
.has_cursor()): self
.set_cursor(x
.cursor())
1091 def Equals(self
, x
):
1092 if x
is self
: return 1
1093 if self
.has_cursor_
!= x
.has_cursor_
: return 0
1094 if self
.has_cursor_
and self
.cursor_
!= x
.cursor_
: return 0
1097 def IsInitialized(self
, debug_strs
=None):
1099 if (not self
.has_cursor_
):
1101 if debug_strs
is not None:
1102 debug_strs
.append('Required field: cursor not set.')
1112 def OutputUnchecked(self
, out
):
1114 out
.put64(self
.cursor_
)
1116 def TryMerge(self
, d
):
1117 while d
.avail() > 0:
1118 tt
= d
.getVarInt32()
1120 self
.set_cursor(d
.get64())
1122 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1126 def __str__(self
, prefix
="", printElemNumber
=0):
1128 if self
.has_cursor_
: res
+=prefix
+("cursor: %s\n" % self
.DebugFormatFixed64(self
.cursor_
))
1139 ProtocolBuffer
.Encoder
.NUMERIC
,
1140 ProtocolBuffer
.Encoder
.DOUBLE
,
1145 _STYLE_CONTENT_TYPE
= """"""
1146 class Error(ProtocolBuffer
.ProtocolMessage
):
1149 CONCURRENT_TRANSACTION
= 2
1154 _ErrorCode_NAMES
= {
1156 2: "CONCURRENT_TRANSACTION",
1157 3: "INTERNAL_ERROR",
1162 def ErrorCode_Name(cls
, x
): return cls
._ErrorCode
_NAMES
.get(x
, "")
1163 ErrorCode_Name
= classmethod(ErrorCode_Name
)
1166 def __init__(self
, contents
=None):
1168 if contents
is not None: self
.MergeFromString(contents
)
1171 def MergeFrom(self
, x
):
1172 assert x
is not self
1174 def Equals(self
, x
):
1175 if x
is self
: return 1
1178 def IsInitialized(self
, debug_strs
=None):
1189 def OutputUnchecked(self
, out
):
1192 def TryMerge(self
, d
):
1193 while d
.avail() > 0:
1194 tt
= d
.getVarInt32()
1195 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1199 def __str__(self
, prefix
="", printElemNumber
=0):
1209 ProtocolBuffer
.Encoder
.NUMERIC
,
1213 _STYLE_CONTENT_TYPE
= """"""
1214 class Cost(ProtocolBuffer
.ProtocolMessage
):
1215 has_index_writes_
= 0
1217 has_index_write_bytes_
= 0
1218 index_write_bytes_
= 0
1219 has_entity_writes_
= 0
1221 has_entity_write_bytes_
= 0
1222 entity_write_bytes_
= 0
1224 def __init__(self
, contents
=None):
1225 if contents
is not None: self
.MergeFromString(contents
)
1227 def index_writes(self
): return self
.index_writes_
1229 def set_index_writes(self
, x
):
1230 self
.has_index_writes_
= 1
1231 self
.index_writes_
= x
1233 def clear_index_writes(self
):
1234 if self
.has_index_writes_
:
1235 self
.has_index_writes_
= 0
1236 self
.index_writes_
= 0
1238 def has_index_writes(self
): return self
.has_index_writes_
1240 def index_write_bytes(self
): return self
.index_write_bytes_
1242 def set_index_write_bytes(self
, x
):
1243 self
.has_index_write_bytes_
= 1
1244 self
.index_write_bytes_
= x
1246 def clear_index_write_bytes(self
):
1247 if self
.has_index_write_bytes_
:
1248 self
.has_index_write_bytes_
= 0
1249 self
.index_write_bytes_
= 0
1251 def has_index_write_bytes(self
): return self
.has_index_write_bytes_
1253 def entity_writes(self
): return self
.entity_writes_
1255 def set_entity_writes(self
, x
):
1256 self
.has_entity_writes_
= 1
1257 self
.entity_writes_
= x
1259 def clear_entity_writes(self
):
1260 if self
.has_entity_writes_
:
1261 self
.has_entity_writes_
= 0
1262 self
.entity_writes_
= 0
1264 def has_entity_writes(self
): return self
.has_entity_writes_
1266 def entity_write_bytes(self
): return self
.entity_write_bytes_
1268 def set_entity_write_bytes(self
, x
):
1269 self
.has_entity_write_bytes_
= 1
1270 self
.entity_write_bytes_
= x
1272 def clear_entity_write_bytes(self
):
1273 if self
.has_entity_write_bytes_
:
1274 self
.has_entity_write_bytes_
= 0
1275 self
.entity_write_bytes_
= 0
1277 def has_entity_write_bytes(self
): return self
.has_entity_write_bytes_
1280 def MergeFrom(self
, x
):
1281 assert x
is not self
1282 if (x
.has_index_writes()): self
.set_index_writes(x
.index_writes())
1283 if (x
.has_index_write_bytes()): self
.set_index_write_bytes(x
.index_write_bytes())
1284 if (x
.has_entity_writes()): self
.set_entity_writes(x
.entity_writes())
1285 if (x
.has_entity_write_bytes()): self
.set_entity_write_bytes(x
.entity_write_bytes())
1287 def Equals(self
, x
):
1288 if x
is self
: return 1
1289 if self
.has_index_writes_
!= x
.has_index_writes_
: return 0
1290 if self
.has_index_writes_
and self
.index_writes_
!= x
.index_writes_
: return 0
1291 if self
.has_index_write_bytes_
!= x
.has_index_write_bytes_
: return 0
1292 if self
.has_index_write_bytes_
and self
.index_write_bytes_
!= x
.index_write_bytes_
: return 0
1293 if self
.has_entity_writes_
!= x
.has_entity_writes_
: return 0
1294 if self
.has_entity_writes_
and self
.entity_writes_
!= x
.entity_writes_
: return 0
1295 if self
.has_entity_write_bytes_
!= x
.has_entity_write_bytes_
: return 0
1296 if self
.has_entity_write_bytes_
and self
.entity_write_bytes_
!= x
.entity_write_bytes_
: return 0
1299 def IsInitialized(self
, debug_strs
=None):
1305 if (self
.has_index_writes_
): n
+= 1 + self
.lengthVarInt64(self
.index_writes_
)
1306 if (self
.has_index_write_bytes_
): n
+= 1 + self
.lengthVarInt64(self
.index_write_bytes_
)
1307 if (self
.has_entity_writes_
): n
+= 1 + self
.lengthVarInt64(self
.entity_writes_
)
1308 if (self
.has_entity_write_bytes_
): n
+= 1 + self
.lengthVarInt64(self
.entity_write_bytes_
)
1312 self
.clear_index_writes()
1313 self
.clear_index_write_bytes()
1314 self
.clear_entity_writes()
1315 self
.clear_entity_write_bytes()
1317 def OutputUnchecked(self
, out
):
1318 if (self
.has_index_writes_
):
1320 out
.putVarInt32(self
.index_writes_
)
1321 if (self
.has_index_write_bytes_
):
1323 out
.putVarInt32(self
.index_write_bytes_
)
1324 if (self
.has_entity_writes_
):
1326 out
.putVarInt32(self
.entity_writes_
)
1327 if (self
.has_entity_write_bytes_
):
1329 out
.putVarInt32(self
.entity_write_bytes_
)
1331 def TryMerge(self
, d
):
1332 while d
.avail() > 0:
1333 tt
= d
.getVarInt32()
1335 self
.set_index_writes(d
.getVarInt32())
1338 self
.set_index_write_bytes(d
.getVarInt32())
1341 self
.set_entity_writes(d
.getVarInt32())
1344 self
.set_entity_write_bytes(d
.getVarInt32())
1346 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1350 def __str__(self
, prefix
="", printElemNumber
=0):
1352 if self
.has_index_writes_
: res
+=prefix
+("index_writes: %s\n" % self
.DebugFormatInt32(self
.index_writes_
))
1353 if self
.has_index_write_bytes_
: res
+=prefix
+("index_write_bytes: %s\n" % self
.DebugFormatInt32(self
.index_write_bytes_
))
1354 if self
.has_entity_writes_
: res
+=prefix
+("entity_writes: %s\n" % self
.DebugFormatInt32(self
.entity_writes_
))
1355 if self
.has_entity_write_bytes_
: res
+=prefix
+("entity_write_bytes: %s\n" % self
.DebugFormatInt32(self
.entity_write_bytes_
))
1359 kindex_write_bytes
= 2
1361 kentity_write_bytes
= 4
1366 "index_write_bytes",
1368 "entity_write_bytes",
1372 ProtocolBuffer
.Encoder
.NUMERIC
,
1373 ProtocolBuffer
.Encoder
.NUMERIC
,
1375 ProtocolBuffer
.Encoder
.NUMERIC
,
1377 ProtocolBuffer
.Encoder
.NUMERIC
,
1379 ProtocolBuffer
.Encoder
.NUMERIC
,
1384 _STYLE_CONTENT_TYPE
= """"""
1385 class GetRequest(ProtocolBuffer
.ProtocolMessage
):
1386 has_transaction_
= 0
1389 def __init__(self
, contents
=None):
1391 self
.lazy_init_lock_
= thread
.allocate_lock()
1392 if contents
is not None: self
.MergeFromString(contents
)
1394 def key_size(self
): return len(self
.key_
)
1395 def key_list(self
): return self
.key_
1400 def mutable_key(self
, i
):
1408 def clear_key(self
):
1410 def transaction(self
):
1411 if self
.transaction_
is None:
1412 self
.lazy_init_lock_
.acquire()
1414 if self
.transaction_
is None: self
.transaction_
= Transaction()
1416 self
.lazy_init_lock_
.release()
1417 return self
.transaction_
1419 def mutable_transaction(self
): self
.has_transaction_
= 1; return self
.transaction()
1421 def clear_transaction(self
):
1422 if self
.has_transaction_
:
1423 self
.has_transaction_
= 0;
1424 if self
.transaction_
is not None: self
.transaction_
.Clear()
1426 def has_transaction(self
): return self
.has_transaction_
1429 def MergeFrom(self
, x
):
1430 assert x
is not self
1431 for i
in xrange(x
.key_size()): self
.add_key().CopyFrom(x
.key(i
))
1432 if (x
.has_transaction()): self
.mutable_transaction().MergeFrom(x
.transaction())
1434 def Equals(self
, x
):
1435 if x
is self
: return 1
1436 if len(self
.key_
) != len(x
.key_
): return 0
1437 for e1
, e2
in zip(self
.key_
, x
.key_
):
1438 if e1
!= e2
: return 0
1439 if self
.has_transaction_
!= x
.has_transaction_
: return 0
1440 if self
.has_transaction_
and self
.transaction_
!= x
.transaction_
: return 0
1443 def IsInitialized(self
, debug_strs
=None):
1446 if not p
.IsInitialized(debug_strs
): initialized
=0
1447 if (self
.has_transaction_
and not self
.transaction_
.IsInitialized(debug_strs
)): initialized
= 0
1452 n
+= 1 * len(self
.key_
)
1453 for i
in xrange(len(self
.key_
)): n
+= self
.lengthString(self
.key_
[i
].ByteSize())
1454 if (self
.has_transaction_
): n
+= 1 + self
.lengthString(self
.transaction_
.ByteSize())
1459 self
.clear_transaction()
1461 def OutputUnchecked(self
, out
):
1462 for i
in xrange(len(self
.key_
)):
1464 out
.putVarInt32(self
.key_
[i
].ByteSize())
1465 self
.key_
[i
].OutputUnchecked(out
)
1466 if (self
.has_transaction_
):
1468 out
.putVarInt32(self
.transaction_
.ByteSize())
1469 self
.transaction_
.OutputUnchecked(out
)
1471 def TryMerge(self
, d
):
1472 while d
.avail() > 0:
1473 tt
= d
.getVarInt32()
1475 length
= d
.getVarInt32()
1476 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1478 self
.add_key().TryMerge(tmp
)
1481 length
= d
.getVarInt32()
1482 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1484 self
.mutable_transaction().TryMerge(tmp
)
1486 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1490 def __str__(self
, prefix
="", printElemNumber
=0):
1495 if printElemNumber
: elm
="(%d)" % cnt
1496 res
+=prefix
+("key%s <\n" % elm
)
1497 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1500 if self
.has_transaction_
:
1501 res
+=prefix
+"transaction <\n"
1502 res
+=self
.transaction_
.__str
__(prefix
+ " ", printElemNumber
)
1516 ProtocolBuffer
.Encoder
.NUMERIC
,
1517 ProtocolBuffer
.Encoder
.STRING
,
1519 ProtocolBuffer
.Encoder
.STRING
,
1524 _STYLE_CONTENT_TYPE
= """"""
1525 class GetResponse_Entity(ProtocolBuffer
.ProtocolMessage
):
1529 def __init__(self
, contents
=None):
1530 self
.lazy_init_lock_
= thread
.allocate_lock()
1531 if contents
is not None: self
.MergeFromString(contents
)
1534 if self
.entity_
is None:
1535 self
.lazy_init_lock_
.acquire()
1537 if self
.entity_
is None: self
.entity_
= EntityProto()
1539 self
.lazy_init_lock_
.release()
1542 def mutable_entity(self
): self
.has_entity_
= 1; return self
.entity()
1544 def clear_entity(self
):
1545 if self
.has_entity_
:
1546 self
.has_entity_
= 0;
1547 if self
.entity_
is not None: self
.entity_
.Clear()
1549 def has_entity(self
): return self
.has_entity_
1552 def MergeFrom(self
, x
):
1553 assert x
is not self
1554 if (x
.has_entity()): self
.mutable_entity().MergeFrom(x
.entity())
1556 def Equals(self
, x
):
1557 if x
is self
: return 1
1558 if self
.has_entity_
!= x
.has_entity_
: return 0
1559 if self
.has_entity_
and self
.entity_
!= x
.entity_
: return 0
1562 def IsInitialized(self
, debug_strs
=None):
1564 if (self
.has_entity_
and not self
.entity_
.IsInitialized(debug_strs
)): initialized
= 0
1569 if (self
.has_entity_
): n
+= 1 + self
.lengthString(self
.entity_
.ByteSize())
1575 def OutputUnchecked(self
, out
):
1576 if (self
.has_entity_
):
1578 out
.putVarInt32(self
.entity_
.ByteSize())
1579 self
.entity_
.OutputUnchecked(out
)
1581 def TryMerge(self
, d
):
1583 tt
= d
.getVarInt32()
1586 length
= d
.getVarInt32()
1587 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1589 self
.mutable_entity().TryMerge(tmp
)
1591 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1595 def __str__(self
, prefix
="", printElemNumber
=0):
1597 if self
.has_entity_
:
1598 res
+=prefix
+"entity <\n"
1599 res
+=self
.entity_
.__str
__(prefix
+ " ", printElemNumber
)
1603 class GetResponse(ProtocolBuffer
.ProtocolMessage
):
1605 def __init__(self
, contents
=None):
1607 if contents
is not None: self
.MergeFromString(contents
)
1609 def entity_size(self
): return len(self
.entity_
)
1610 def entity_list(self
): return self
.entity_
1612 def entity(self
, i
):
1613 return self
.entity_
[i
]
1615 def mutable_entity(self
, i
):
1616 return self
.entity_
[i
]
1618 def add_entity(self
):
1619 x
= GetResponse_Entity()
1620 self
.entity_
.append(x
)
1623 def clear_entity(self
):
1626 def MergeFrom(self
, x
):
1627 assert x
is not self
1628 for i
in xrange(x
.entity_size()): self
.add_entity().CopyFrom(x
.entity(i
))
1630 def Equals(self
, x
):
1631 if x
is self
: return 1
1632 if len(self
.entity_
) != len(x
.entity_
): return 0
1633 for e1
, e2
in zip(self
.entity_
, x
.entity_
):
1634 if e1
!= e2
: return 0
1637 def IsInitialized(self
, debug_strs
=None):
1639 for p
in self
.entity_
:
1640 if not p
.IsInitialized(debug_strs
): initialized
=0
1645 n
+= 2 * len(self
.entity_
)
1646 for i
in xrange(len(self
.entity_
)): n
+= self
.entity_
[i
].ByteSize()
1652 def OutputUnchecked(self
, out
):
1653 for i
in xrange(len(self
.entity_
)):
1655 self
.entity_
[i
].OutputUnchecked(out
)
1658 def TryMerge(self
, d
):
1659 while d
.avail() > 0:
1660 tt
= d
.getVarInt32()
1662 self
.add_entity().TryMerge(d
)
1664 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1668 def __str__(self
, prefix
="", printElemNumber
=0):
1671 for e
in self
.entity_
:
1673 if printElemNumber
: elm
="(%d)" % cnt
1674 res
+=prefix
+("Entity%s {\n" % elm
)
1675 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1690 ProtocolBuffer
.Encoder
.NUMERIC
,
1691 ProtocolBuffer
.Encoder
.STARTGROUP
,
1693 ProtocolBuffer
.Encoder
.STRING
,
1698 _STYLE_CONTENT_TYPE
= """"""
1699 class PutRequest(ProtocolBuffer
.ProtocolMessage
):
1700 has_transaction_
= 0
1705 def __init__(self
, contents
=None):
1707 self
.composite_index_
= []
1708 self
.lazy_init_lock_
= thread
.allocate_lock()
1709 if contents
is not None: self
.MergeFromString(contents
)
1711 def entity_size(self
): return len(self
.entity_
)
1712 def entity_list(self
): return self
.entity_
1714 def entity(self
, i
):
1715 return self
.entity_
[i
]
1717 def mutable_entity(self
, i
):
1718 return self
.entity_
[i
]
1720 def add_entity(self
):
1722 self
.entity_
.append(x
)
1725 def clear_entity(self
):
1727 def transaction(self
):
1728 if self
.transaction_
is None:
1729 self
.lazy_init_lock_
.acquire()
1731 if self
.transaction_
is None: self
.transaction_
= Transaction()
1733 self
.lazy_init_lock_
.release()
1734 return self
.transaction_
1736 def mutable_transaction(self
): self
.has_transaction_
= 1; return self
.transaction()
1738 def clear_transaction(self
):
1739 if self
.has_transaction_
:
1740 self
.has_transaction_
= 0;
1741 if self
.transaction_
is not None: self
.transaction_
.Clear()
1743 def has_transaction(self
): return self
.has_transaction_
1745 def composite_index_size(self
): return len(self
.composite_index_
)
1746 def composite_index_list(self
): return self
.composite_index_
1748 def composite_index(self
, i
):
1749 return self
.composite_index_
[i
]
1751 def mutable_composite_index(self
, i
):
1752 return self
.composite_index_
[i
]
1754 def add_composite_index(self
):
1755 x
= CompositeIndex()
1756 self
.composite_index_
.append(x
)
1759 def clear_composite_index(self
):
1760 self
.composite_index_
= []
1761 def trusted(self
): return self
.trusted_
1763 def set_trusted(self
, x
):
1764 self
.has_trusted_
= 1
1767 def clear_trusted(self
):
1768 if self
.has_trusted_
:
1769 self
.has_trusted_
= 0
1772 def has_trusted(self
): return self
.has_trusted_
1775 def MergeFrom(self
, x
):
1776 assert x
is not self
1777 for i
in xrange(x
.entity_size()): self
.add_entity().CopyFrom(x
.entity(i
))
1778 if (x
.has_transaction()): self
.mutable_transaction().MergeFrom(x
.transaction())
1779 for i
in xrange(x
.composite_index_size()): self
.add_composite_index().CopyFrom(x
.composite_index(i
))
1780 if (x
.has_trusted()): self
.set_trusted(x
.trusted())
1782 def Equals(self
, x
):
1783 if x
is self
: return 1
1784 if len(self
.entity_
) != len(x
.entity_
): return 0
1785 for e1
, e2
in zip(self
.entity_
, x
.entity_
):
1786 if e1
!= e2
: return 0
1787 if self
.has_transaction_
!= x
.has_transaction_
: return 0
1788 if self
.has_transaction_
and self
.transaction_
!= x
.transaction_
: return 0
1789 if len(self
.composite_index_
) != len(x
.composite_index_
): return 0
1790 for e1
, e2
in zip(self
.composite_index_
, x
.composite_index_
):
1791 if e1
!= e2
: return 0
1792 if self
.has_trusted_
!= x
.has_trusted_
: return 0
1793 if self
.has_trusted_
and self
.trusted_
!= x
.trusted_
: return 0
1796 def IsInitialized(self
, debug_strs
=None):
1798 for p
in self
.entity_
:
1799 if not p
.IsInitialized(debug_strs
): initialized
=0
1800 if (self
.has_transaction_
and not self
.transaction_
.IsInitialized(debug_strs
)): initialized
= 0
1801 for p
in self
.composite_index_
:
1802 if not p
.IsInitialized(debug_strs
): initialized
=0
1807 n
+= 1 * len(self
.entity_
)
1808 for i
in xrange(len(self
.entity_
)): n
+= self
.lengthString(self
.entity_
[i
].ByteSize())
1809 if (self
.has_transaction_
): n
+= 1 + self
.lengthString(self
.transaction_
.ByteSize())
1810 n
+= 1 * len(self
.composite_index_
)
1811 for i
in xrange(len(self
.composite_index_
)): n
+= self
.lengthString(self
.composite_index_
[i
].ByteSize())
1812 if (self
.has_trusted_
): n
+= 2
1817 self
.clear_transaction()
1818 self
.clear_composite_index()
1819 self
.clear_trusted()
1821 def OutputUnchecked(self
, out
):
1822 for i
in xrange(len(self
.entity_
)):
1824 out
.putVarInt32(self
.entity_
[i
].ByteSize())
1825 self
.entity_
[i
].OutputUnchecked(out
)
1826 if (self
.has_transaction_
):
1828 out
.putVarInt32(self
.transaction_
.ByteSize())
1829 self
.transaction_
.OutputUnchecked(out
)
1830 for i
in xrange(len(self
.composite_index_
)):
1832 out
.putVarInt32(self
.composite_index_
[i
].ByteSize())
1833 self
.composite_index_
[i
].OutputUnchecked(out
)
1834 if (self
.has_trusted_
):
1836 out
.putBoolean(self
.trusted_
)
1838 def TryMerge(self
, d
):
1839 while d
.avail() > 0:
1840 tt
= d
.getVarInt32()
1842 length
= d
.getVarInt32()
1843 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1845 self
.add_entity().TryMerge(tmp
)
1848 length
= d
.getVarInt32()
1849 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1851 self
.mutable_transaction().TryMerge(tmp
)
1854 length
= d
.getVarInt32()
1855 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
1857 self
.add_composite_index().TryMerge(tmp
)
1860 self
.set_trusted(d
.getBoolean())
1862 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
1866 def __str__(self
, prefix
="", printElemNumber
=0):
1869 for e
in self
.entity_
:
1871 if printElemNumber
: elm
="(%d)" % cnt
1872 res
+=prefix
+("entity%s <\n" % elm
)
1873 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1876 if self
.has_transaction_
:
1877 res
+=prefix
+"transaction <\n"
1878 res
+=self
.transaction_
.__str
__(prefix
+ " ", printElemNumber
)
1881 for e
in self
.composite_index_
:
1883 if printElemNumber
: elm
="(%d)" % cnt
1884 res
+=prefix
+("composite_index%s <\n" % elm
)
1885 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
1888 if self
.has_trusted_
: res
+=prefix
+("trusted: %s\n" % self
.DebugFormatBool(self
.trusted_
))
1893 kcomposite_index
= 3
1905 ProtocolBuffer
.Encoder
.NUMERIC
,
1906 ProtocolBuffer
.Encoder
.STRING
,
1908 ProtocolBuffer
.Encoder
.STRING
,
1910 ProtocolBuffer
.Encoder
.STRING
,
1912 ProtocolBuffer
.Encoder
.NUMERIC
,
1917 _STYLE_CONTENT_TYPE
= """"""
1918 class PutResponse(ProtocolBuffer
.ProtocolMessage
):
1922 def __init__(self
, contents
=None):
1924 self
.lazy_init_lock_
= thread
.allocate_lock()
1925 if contents
is not None: self
.MergeFromString(contents
)
1927 def key_size(self
): return len(self
.key_
)
1928 def key_list(self
): return self
.key_
1933 def mutable_key(self
, i
):
1941 def clear_key(self
):
1944 if self
.cost_
is None:
1945 self
.lazy_init_lock_
.acquire()
1947 if self
.cost_
is None: self
.cost_
= Cost()
1949 self
.lazy_init_lock_
.release()
1952 def mutable_cost(self
): self
.has_cost_
= 1; return self
.cost()
1954 def clear_cost(self
):
1957 if self
.cost_
is not None: self
.cost_
.Clear()
1959 def has_cost(self
): return self
.has_cost_
1962 def MergeFrom(self
, x
):
1963 assert x
is not self
1964 for i
in xrange(x
.key_size()): self
.add_key().CopyFrom(x
.key(i
))
1965 if (x
.has_cost()): self
.mutable_cost().MergeFrom(x
.cost())
1967 def Equals(self
, x
):
1968 if x
is self
: return 1
1969 if len(self
.key_
) != len(x
.key_
): return 0
1970 for e1
, e2
in zip(self
.key_
, x
.key_
):
1971 if e1
!= e2
: return 0
1972 if self
.has_cost_
!= x
.has_cost_
: return 0
1973 if self
.has_cost_
and self
.cost_
!= x
.cost_
: return 0
1976 def IsInitialized(self
, debug_strs
=None):
1979 if not p
.IsInitialized(debug_strs
): initialized
=0
1980 if (self
.has_cost_
and not self
.cost_
.IsInitialized(debug_strs
)): initialized
= 0
1985 n
+= 1 * len(self
.key_
)
1986 for i
in xrange(len(self
.key_
)): n
+= self
.lengthString(self
.key_
[i
].ByteSize())
1987 if (self
.has_cost_
): n
+= 1 + self
.lengthString(self
.cost_
.ByteSize())
1994 def OutputUnchecked(self
, out
):
1995 for i
in xrange(len(self
.key_
)):
1997 out
.putVarInt32(self
.key_
[i
].ByteSize())
1998 self
.key_
[i
].OutputUnchecked(out
)
1999 if (self
.has_cost_
):
2001 out
.putVarInt32(self
.cost_
.ByteSize())
2002 self
.cost_
.OutputUnchecked(out
)
2004 def TryMerge(self
, d
):
2005 while d
.avail() > 0:
2006 tt
= d
.getVarInt32()
2008 length
= d
.getVarInt32()
2009 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2011 self
.add_key().TryMerge(tmp
)
2014 length
= d
.getVarInt32()
2015 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2017 self
.mutable_cost().TryMerge(tmp
)
2019 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2023 def __str__(self
, prefix
="", printElemNumber
=0):
2028 if printElemNumber
: elm
="(%d)" % cnt
2029 res
+=prefix
+("key%s <\n" % elm
)
2030 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
2034 res
+=prefix
+"cost <\n"
2035 res
+=self
.cost_
.__str
__(prefix
+ " ", printElemNumber
)
2049 ProtocolBuffer
.Encoder
.NUMERIC
,
2050 ProtocolBuffer
.Encoder
.STRING
,
2052 ProtocolBuffer
.Encoder
.STRING
,
2057 _STYLE_CONTENT_TYPE
= """"""
2058 class DeleteRequest(ProtocolBuffer
.ProtocolMessage
):
2059 has_transaction_
= 0
2064 def __init__(self
, contents
=None):
2066 self
.lazy_init_lock_
= thread
.allocate_lock()
2067 if contents
is not None: self
.MergeFromString(contents
)
2069 def key_size(self
): return len(self
.key_
)
2070 def key_list(self
): return self
.key_
2075 def mutable_key(self
, i
):
2083 def clear_key(self
):
2085 def transaction(self
):
2086 if self
.transaction_
is None:
2087 self
.lazy_init_lock_
.acquire()
2089 if self
.transaction_
is None: self
.transaction_
= Transaction()
2091 self
.lazy_init_lock_
.release()
2092 return self
.transaction_
2094 def mutable_transaction(self
): self
.has_transaction_
= 1; return self
.transaction()
2096 def clear_transaction(self
):
2097 if self
.has_transaction_
:
2098 self
.has_transaction_
= 0;
2099 if self
.transaction_
is not None: self
.transaction_
.Clear()
2101 def has_transaction(self
): return self
.has_transaction_
2103 def trusted(self
): return self
.trusted_
2105 def set_trusted(self
, x
):
2106 self
.has_trusted_
= 1
2109 def clear_trusted(self
):
2110 if self
.has_trusted_
:
2111 self
.has_trusted_
= 0
2114 def has_trusted(self
): return self
.has_trusted_
2117 def MergeFrom(self
, x
):
2118 assert x
is not self
2119 for i
in xrange(x
.key_size()): self
.add_key().CopyFrom(x
.key(i
))
2120 if (x
.has_transaction()): self
.mutable_transaction().MergeFrom(x
.transaction())
2121 if (x
.has_trusted()): self
.set_trusted(x
.trusted())
2123 def Equals(self
, x
):
2124 if x
is self
: return 1
2125 if len(self
.key_
) != len(x
.key_
): return 0
2126 for e1
, e2
in zip(self
.key_
, x
.key_
):
2127 if e1
!= e2
: return 0
2128 if self
.has_transaction_
!= x
.has_transaction_
: return 0
2129 if self
.has_transaction_
and self
.transaction_
!= x
.transaction_
: return 0
2130 if self
.has_trusted_
!= x
.has_trusted_
: return 0
2131 if self
.has_trusted_
and self
.trusted_
!= x
.trusted_
: return 0
2134 def IsInitialized(self
, debug_strs
=None):
2137 if not p
.IsInitialized(debug_strs
): initialized
=0
2138 if (self
.has_transaction_
and not self
.transaction_
.IsInitialized(debug_strs
)): initialized
= 0
2143 n
+= 1 * len(self
.key_
)
2144 for i
in xrange(len(self
.key_
)): n
+= self
.lengthString(self
.key_
[i
].ByteSize())
2145 if (self
.has_transaction_
): n
+= 1 + self
.lengthString(self
.transaction_
.ByteSize())
2146 if (self
.has_trusted_
): n
+= 2
2151 self
.clear_transaction()
2152 self
.clear_trusted()
2154 def OutputUnchecked(self
, out
):
2155 if (self
.has_trusted_
):
2157 out
.putBoolean(self
.trusted_
)
2158 if (self
.has_transaction_
):
2160 out
.putVarInt32(self
.transaction_
.ByteSize())
2161 self
.transaction_
.OutputUnchecked(out
)
2162 for i
in xrange(len(self
.key_
)):
2164 out
.putVarInt32(self
.key_
[i
].ByteSize())
2165 self
.key_
[i
].OutputUnchecked(out
)
2167 def TryMerge(self
, d
):
2168 while d
.avail() > 0:
2169 tt
= d
.getVarInt32()
2171 self
.set_trusted(d
.getBoolean())
2174 length
= d
.getVarInt32()
2175 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2177 self
.mutable_transaction().TryMerge(tmp
)
2180 length
= d
.getVarInt32()
2181 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2183 self
.add_key().TryMerge(tmp
)
2185 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2189 def __str__(self
, prefix
="", printElemNumber
=0):
2194 if printElemNumber
: elm
="(%d)" % cnt
2195 res
+=prefix
+("key%s <\n" % elm
)
2196 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
2199 if self
.has_transaction_
:
2200 res
+=prefix
+"transaction <\n"
2201 res
+=self
.transaction_
.__str
__(prefix
+ " ", printElemNumber
)
2203 if self
.has_trusted_
: res
+=prefix
+("trusted: %s\n" % self
.DebugFormatBool(self
.trusted_
))
2221 ProtocolBuffer
.Encoder
.NUMERIC
,
2222 ProtocolBuffer
.Encoder
.MAX_TYPE
,
2224 ProtocolBuffer
.Encoder
.MAX_TYPE
,
2226 ProtocolBuffer
.Encoder
.MAX_TYPE
,
2228 ProtocolBuffer
.Encoder
.NUMERIC
,
2230 ProtocolBuffer
.Encoder
.STRING
,
2232 ProtocolBuffer
.Encoder
.STRING
,
2237 _STYLE_CONTENT_TYPE
= """"""
2238 class DeleteResponse(ProtocolBuffer
.ProtocolMessage
):
2242 def __init__(self
, contents
=None):
2243 self
.lazy_init_lock_
= thread
.allocate_lock()
2244 if contents
is not None: self
.MergeFromString(contents
)
2247 if self
.cost_
is None:
2248 self
.lazy_init_lock_
.acquire()
2250 if self
.cost_
is None: self
.cost_
= Cost()
2252 self
.lazy_init_lock_
.release()
2255 def mutable_cost(self
): self
.has_cost_
= 1; return self
.cost()
2257 def clear_cost(self
):
2260 if self
.cost_
is not None: self
.cost_
.Clear()
2262 def has_cost(self
): return self
.has_cost_
2265 def MergeFrom(self
, x
):
2266 assert x
is not self
2267 if (x
.has_cost()): self
.mutable_cost().MergeFrom(x
.cost())
2269 def Equals(self
, x
):
2270 if x
is self
: return 1
2271 if self
.has_cost_
!= x
.has_cost_
: return 0
2272 if self
.has_cost_
and self
.cost_
!= x
.cost_
: return 0
2275 def IsInitialized(self
, debug_strs
=None):
2277 if (self
.has_cost_
and not self
.cost_
.IsInitialized(debug_strs
)): initialized
= 0
2282 if (self
.has_cost_
): n
+= 1 + self
.lengthString(self
.cost_
.ByteSize())
2288 def OutputUnchecked(self
, out
):
2289 if (self
.has_cost_
):
2291 out
.putVarInt32(self
.cost_
.ByteSize())
2292 self
.cost_
.OutputUnchecked(out
)
2294 def TryMerge(self
, d
):
2295 while d
.avail() > 0:
2296 tt
= d
.getVarInt32()
2298 length
= d
.getVarInt32()
2299 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2301 self
.mutable_cost().TryMerge(tmp
)
2303 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2307 def __str__(self
, prefix
="", printElemNumber
=0):
2310 res
+=prefix
+"cost <\n"
2311 res
+=self
.cost_
.__str
__(prefix
+ " ", printElemNumber
)
2323 ProtocolBuffer
.Encoder
.NUMERIC
,
2324 ProtocolBuffer
.Encoder
.STRING
,
2329 _STYLE_CONTENT_TYPE
= """"""
2330 class NextRequest(ProtocolBuffer
.ProtocolMessage
):
2335 def __init__(self
, contents
=None):
2336 self
.cursor_
= Cursor()
2337 if contents
is not None: self
.MergeFromString(contents
)
2339 def cursor(self
): return self
.cursor_
2341 def mutable_cursor(self
): self
.has_cursor_
= 1; return self
.cursor_
2343 def clear_cursor(self
):self
.has_cursor_
= 0; self
.cursor_
.Clear()
2345 def has_cursor(self
): return self
.has_cursor_
2347 def count(self
): return self
.count_
2349 def set_count(self
, x
):
2353 def clear_count(self
):
2358 def has_count(self
): return self
.has_count_
2361 def MergeFrom(self
, x
):
2362 assert x
is not self
2363 if (x
.has_cursor()): self
.mutable_cursor().MergeFrom(x
.cursor())
2364 if (x
.has_count()): self
.set_count(x
.count())
2366 def Equals(self
, x
):
2367 if x
is self
: return 1
2368 if self
.has_cursor_
!= x
.has_cursor_
: return 0
2369 if self
.has_cursor_
and self
.cursor_
!= x
.cursor_
: return 0
2370 if self
.has_count_
!= x
.has_count_
: return 0
2371 if self
.has_count_
and self
.count_
!= x
.count_
: return 0
2374 def IsInitialized(self
, debug_strs
=None):
2376 if (not self
.has_cursor_
):
2378 if debug_strs
is not None:
2379 debug_strs
.append('Required field: cursor not set.')
2380 elif not self
.cursor_
.IsInitialized(debug_strs
): initialized
= 0
2385 n
+= self
.lengthString(self
.cursor_
.ByteSize())
2386 if (self
.has_count_
): n
+= 1 + self
.lengthVarInt64(self
.count_
)
2393 def OutputUnchecked(self
, out
):
2395 out
.putVarInt32(self
.cursor_
.ByteSize())
2396 self
.cursor_
.OutputUnchecked(out
)
2397 if (self
.has_count_
):
2399 out
.putVarInt32(self
.count_
)
2401 def TryMerge(self
, d
):
2402 while d
.avail() > 0:
2403 tt
= d
.getVarInt32()
2405 length
= d
.getVarInt32()
2406 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2408 self
.mutable_cursor().TryMerge(tmp
)
2411 self
.set_count(d
.getVarInt32())
2413 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2417 def __str__(self
, prefix
="", printElemNumber
=0):
2419 if self
.has_cursor_
:
2420 res
+=prefix
+"cursor <\n"
2421 res
+=self
.cursor_
.__str
__(prefix
+ " ", printElemNumber
)
2423 if self
.has_count_
: res
+=prefix
+("count: %s\n" % self
.DebugFormatInt32(self
.count_
))
2436 ProtocolBuffer
.Encoder
.NUMERIC
,
2437 ProtocolBuffer
.Encoder
.STRING
,
2439 ProtocolBuffer
.Encoder
.NUMERIC
,
2444 _STYLE_CONTENT_TYPE
= """"""
2445 class QueryResult(ProtocolBuffer
.ProtocolMessage
):
2448 has_more_results_
= 0
2453 def __init__(self
, contents
=None):
2455 self
.lazy_init_lock_
= thread
.allocate_lock()
2456 if contents
is not None: self
.MergeFromString(contents
)
2459 if self
.cursor_
is None:
2460 self
.lazy_init_lock_
.acquire()
2462 if self
.cursor_
is None: self
.cursor_
= Cursor()
2464 self
.lazy_init_lock_
.release()
2467 def mutable_cursor(self
): self
.has_cursor_
= 1; return self
.cursor()
2469 def clear_cursor(self
):
2470 if self
.has_cursor_
:
2471 self
.has_cursor_
= 0;
2472 if self
.cursor_
is not None: self
.cursor_
.Clear()
2474 def has_cursor(self
): return self
.has_cursor_
2476 def result_size(self
): return len(self
.result_
)
2477 def result_list(self
): return self
.result_
2479 def result(self
, i
):
2480 return self
.result_
[i
]
2482 def mutable_result(self
, i
):
2483 return self
.result_
[i
]
2485 def add_result(self
):
2487 self
.result_
.append(x
)
2490 def clear_result(self
):
2492 def more_results(self
): return self
.more_results_
2494 def set_more_results(self
, x
):
2495 self
.has_more_results_
= 1
2496 self
.more_results_
= x
2498 def clear_more_results(self
):
2499 if self
.has_more_results_
:
2500 self
.has_more_results_
= 0
2501 self
.more_results_
= 0
2503 def has_more_results(self
): return self
.has_more_results_
2505 def keys_only(self
): return self
.keys_only_
2507 def set_keys_only(self
, x
):
2508 self
.has_keys_only_
= 1
2511 def clear_keys_only(self
):
2512 if self
.has_keys_only_
:
2513 self
.has_keys_only_
= 0
2516 def has_keys_only(self
): return self
.has_keys_only_
2519 def MergeFrom(self
, x
):
2520 assert x
is not self
2521 if (x
.has_cursor()): self
.mutable_cursor().MergeFrom(x
.cursor())
2522 for i
in xrange(x
.result_size()): self
.add_result().CopyFrom(x
.result(i
))
2523 if (x
.has_more_results()): self
.set_more_results(x
.more_results())
2524 if (x
.has_keys_only()): self
.set_keys_only(x
.keys_only())
2526 def Equals(self
, x
):
2527 if x
is self
: return 1
2528 if self
.has_cursor_
!= x
.has_cursor_
: return 0
2529 if self
.has_cursor_
and self
.cursor_
!= x
.cursor_
: return 0
2530 if len(self
.result_
) != len(x
.result_
): return 0
2531 for e1
, e2
in zip(self
.result_
, x
.result_
):
2532 if e1
!= e2
: return 0
2533 if self
.has_more_results_
!= x
.has_more_results_
: return 0
2534 if self
.has_more_results_
and self
.more_results_
!= x
.more_results_
: return 0
2535 if self
.has_keys_only_
!= x
.has_keys_only_
: return 0
2536 if self
.has_keys_only_
and self
.keys_only_
!= x
.keys_only_
: return 0
2539 def IsInitialized(self
, debug_strs
=None):
2541 if (self
.has_cursor_
and not self
.cursor_
.IsInitialized(debug_strs
)): initialized
= 0
2542 for p
in self
.result_
:
2543 if not p
.IsInitialized(debug_strs
): initialized
=0
2544 if (not self
.has_more_results_
):
2546 if debug_strs
is not None:
2547 debug_strs
.append('Required field: more_results not set.')
2552 if (self
.has_cursor_
): n
+= 1 + self
.lengthString(self
.cursor_
.ByteSize())
2553 n
+= 1 * len(self
.result_
)
2554 for i
in xrange(len(self
.result_
)): n
+= self
.lengthString(self
.result_
[i
].ByteSize())
2555 if (self
.has_keys_only_
): n
+= 2
2561 self
.clear_more_results()
2562 self
.clear_keys_only()
2564 def OutputUnchecked(self
, out
):
2565 if (self
.has_cursor_
):
2567 out
.putVarInt32(self
.cursor_
.ByteSize())
2568 self
.cursor_
.OutputUnchecked(out
)
2569 for i
in xrange(len(self
.result_
)):
2571 out
.putVarInt32(self
.result_
[i
].ByteSize())
2572 self
.result_
[i
].OutputUnchecked(out
)
2574 out
.putBoolean(self
.more_results_
)
2575 if (self
.has_keys_only_
):
2577 out
.putBoolean(self
.keys_only_
)
2579 def TryMerge(self
, d
):
2580 while d
.avail() > 0:
2581 tt
= d
.getVarInt32()
2583 length
= d
.getVarInt32()
2584 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2586 self
.mutable_cursor().TryMerge(tmp
)
2589 length
= d
.getVarInt32()
2590 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2592 self
.add_result().TryMerge(tmp
)
2595 self
.set_more_results(d
.getBoolean())
2598 self
.set_keys_only(d
.getBoolean())
2600 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2604 def __str__(self
, prefix
="", printElemNumber
=0):
2606 if self
.has_cursor_
:
2607 res
+=prefix
+"cursor <\n"
2608 res
+=self
.cursor_
.__str
__(prefix
+ " ", printElemNumber
)
2611 for e
in self
.result_
:
2613 if printElemNumber
: elm
="(%d)" % cnt
2614 res
+=prefix
+("result%s <\n" % elm
)
2615 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
2618 if self
.has_more_results_
: res
+=prefix
+("more_results: %s\n" % self
.DebugFormatBool(self
.more_results_
))
2619 if self
.has_keys_only_
: res
+=prefix
+("keys_only: %s\n" % self
.DebugFormatBool(self
.keys_only_
))
2636 ProtocolBuffer
.Encoder
.NUMERIC
,
2637 ProtocolBuffer
.Encoder
.STRING
,
2639 ProtocolBuffer
.Encoder
.STRING
,
2641 ProtocolBuffer
.Encoder
.NUMERIC
,
2643 ProtocolBuffer
.Encoder
.NUMERIC
,
2648 _STYLE_CONTENT_TYPE
= """"""
2649 class Schema(ProtocolBuffer
.ProtocolMessage
):
2651 def __init__(self
, contents
=None):
2653 if contents
is not None: self
.MergeFromString(contents
)
2655 def kind_size(self
): return len(self
.kind_
)
2656 def kind_list(self
): return self
.kind_
2659 return self
.kind_
[i
]
2661 def mutable_kind(self
, i
):
2662 return self
.kind_
[i
]
2666 self
.kind_
.append(x
)
2669 def clear_kind(self
):
2672 def MergeFrom(self
, x
):
2673 assert x
is not self
2674 for i
in xrange(x
.kind_size()): self
.add_kind().CopyFrom(x
.kind(i
))
2676 def Equals(self
, x
):
2677 if x
is self
: return 1
2678 if len(self
.kind_
) != len(x
.kind_
): return 0
2679 for e1
, e2
in zip(self
.kind_
, x
.kind_
):
2680 if e1
!= e2
: return 0
2683 def IsInitialized(self
, debug_strs
=None):
2685 for p
in self
.kind_
:
2686 if not p
.IsInitialized(debug_strs
): initialized
=0
2691 n
+= 1 * len(self
.kind_
)
2692 for i
in xrange(len(self
.kind_
)): n
+= self
.lengthString(self
.kind_
[i
].ByteSize())
2698 def OutputUnchecked(self
, out
):
2699 for i
in xrange(len(self
.kind_
)):
2701 out
.putVarInt32(self
.kind_
[i
].ByteSize())
2702 self
.kind_
[i
].OutputUnchecked(out
)
2704 def TryMerge(self
, d
):
2705 while d
.avail() > 0:
2706 tt
= d
.getVarInt32()
2708 length
= d
.getVarInt32()
2709 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2711 self
.add_kind().TryMerge(tmp
)
2713 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2717 def __str__(self
, prefix
="", printElemNumber
=0):
2720 for e
in self
.kind_
:
2722 if printElemNumber
: elm
="(%d)" % cnt
2723 res
+=prefix
+("kind%s <\n" % elm
)
2724 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
2737 ProtocolBuffer
.Encoder
.NUMERIC
,
2738 ProtocolBuffer
.Encoder
.STRING
,
2743 _STYLE_CONTENT_TYPE
= """"""
2744 class CompositeIndices(ProtocolBuffer
.ProtocolMessage
):
2746 def __init__(self
, contents
=None):
2748 if contents
is not None: self
.MergeFromString(contents
)
2750 def index_size(self
): return len(self
.index_
)
2751 def index_list(self
): return self
.index_
2754 return self
.index_
[i
]
2756 def mutable_index(self
, i
):
2757 return self
.index_
[i
]
2759 def add_index(self
):
2760 x
= CompositeIndex()
2761 self
.index_
.append(x
)
2764 def clear_index(self
):
2767 def MergeFrom(self
, x
):
2768 assert x
is not self
2769 for i
in xrange(x
.index_size()): self
.add_index().CopyFrom(x
.index(i
))
2771 def Equals(self
, x
):
2772 if x
is self
: return 1
2773 if len(self
.index_
) != len(x
.index_
): return 0
2774 for e1
, e2
in zip(self
.index_
, x
.index_
):
2775 if e1
!= e2
: return 0
2778 def IsInitialized(self
, debug_strs
=None):
2780 for p
in self
.index_
:
2781 if not p
.IsInitialized(debug_strs
): initialized
=0
2786 n
+= 1 * len(self
.index_
)
2787 for i
in xrange(len(self
.index_
)): n
+= self
.lengthString(self
.index_
[i
].ByteSize())
2793 def OutputUnchecked(self
, out
):
2794 for i
in xrange(len(self
.index_
)):
2796 out
.putVarInt32(self
.index_
[i
].ByteSize())
2797 self
.index_
[i
].OutputUnchecked(out
)
2799 def TryMerge(self
, d
):
2800 while d
.avail() > 0:
2801 tt
= d
.getVarInt32()
2803 length
= d
.getVarInt32()
2804 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2806 self
.add_index().TryMerge(tmp
)
2808 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2812 def __str__(self
, prefix
="", printElemNumber
=0):
2815 for e
in self
.index_
:
2817 if printElemNumber
: elm
="(%d)" % cnt
2818 res
+=prefix
+("index%s <\n" % elm
)
2819 res
+=e
.__str
__(prefix
+ " ", printElemNumber
)
2832 ProtocolBuffer
.Encoder
.NUMERIC
,
2833 ProtocolBuffer
.Encoder
.STRING
,
2838 _STYLE_CONTENT_TYPE
= """"""
2839 class CommitResponse(ProtocolBuffer
.ProtocolMessage
):
2843 def __init__(self
, contents
=None):
2844 self
.lazy_init_lock_
= thread
.allocate_lock()
2845 if contents
is not None: self
.MergeFromString(contents
)
2848 if self
.cost_
is None:
2849 self
.lazy_init_lock_
.acquire()
2851 if self
.cost_
is None: self
.cost_
= Cost()
2853 self
.lazy_init_lock_
.release()
2856 def mutable_cost(self
): self
.has_cost_
= 1; return self
.cost()
2858 def clear_cost(self
):
2861 if self
.cost_
is not None: self
.cost_
.Clear()
2863 def has_cost(self
): return self
.has_cost_
2866 def MergeFrom(self
, x
):
2867 assert x
is not self
2868 if (x
.has_cost()): self
.mutable_cost().MergeFrom(x
.cost())
2870 def Equals(self
, x
):
2871 if x
is self
: return 1
2872 if self
.has_cost_
!= x
.has_cost_
: return 0
2873 if self
.has_cost_
and self
.cost_
!= x
.cost_
: return 0
2876 def IsInitialized(self
, debug_strs
=None):
2878 if (self
.has_cost_
and not self
.cost_
.IsInitialized(debug_strs
)): initialized
= 0
2883 if (self
.has_cost_
): n
+= 1 + self
.lengthString(self
.cost_
.ByteSize())
2889 def OutputUnchecked(self
, out
):
2890 if (self
.has_cost_
):
2892 out
.putVarInt32(self
.cost_
.ByteSize())
2893 self
.cost_
.OutputUnchecked(out
)
2895 def TryMerge(self
, d
):
2896 while d
.avail() > 0:
2897 tt
= d
.getVarInt32()
2899 length
= d
.getVarInt32()
2900 tmp
= ProtocolBuffer
.Decoder(d
.buffer(), d
.pos(), d
.pos() + length
)
2902 self
.mutable_cost().TryMerge(tmp
)
2904 if (tt
== 0): raise ProtocolBuffer
.ProtocolBufferDecodeError
2908 def __str__(self
, prefix
="", printElemNumber
=0):
2911 res
+=prefix
+"cost <\n"
2912 res
+=self
.cost_
.__str
__(prefix
+ " ", printElemNumber
)
2924 ProtocolBuffer
.Encoder
.NUMERIC
,
2925 ProtocolBuffer
.Encoder
.STRING
,
2930 _STYLE_CONTENT_TYPE
= """"""
2932 __all__
= ['Transaction','Query','Query_Filter','Query_Order','QueryExplanation','Cursor','Error','Cost','GetRequest','GetResponse','GetResponse_Entity','PutRequest','PutResponse','DeleteRequest','DeleteResponse','NextRequest','QueryResult','Schema','CompositeIndices','CommitResponse']