Ejemplo n.º 1
0
 def serialize(val, protocol_version):
     try:
         days = val.days_from_epoch
     except AttributeError:
         if isinstance(val, six.integer_types):
             # the DB wants offset int values, but util.Date init takes days from epoch
             # here we assume int values are offset, as they would appear in CQL
             # short circuit to avoid subtracting just to add offset
             return uint32_pack(val)
         days = util.Date(val).days_from_epoch
     return uint32_pack(days + SimpleDateType.EPOCH_OFFSET_DAYS)
Ejemplo n.º 2
0
 def serialize(val, protocol_version):
     try:
         days = val.days_from_epoch
     except AttributeError:
         if isinstance(val, six.integer_types):
             # the DB wants offset int values, but util.Date init takes days from epoch
             # here we assume int values are offset, as they would appear in CQL
             # short circuit to avoid subtracting just to add offset
             return uint32_pack(val)
         days = util.Date(val).days_from_epoch
     return uint32_pack(days + SimpleDateType.EPOCH_OFFSET_DAYS)
Ejemplo n.º 3
0
 def serialize(val, protocol_version):
     # Values of the 'date'` type are encoded as 32-bit unsigned integers
     # representing a number of days with epoch (January 1st, 1970) at the center of the
     # range (2^31).
     try:
         days = val.days_from_epoch
     except AttributeError:
         days = util.Date(val).days_from_epoch
     return uint32_pack(days + 2 ** 31)
Ejemplo n.º 4
0
 def serialize(val, protocol_version):
     # Values of the 'date'` type are encoded as 32-bit unsigned integers
     # representing a number of days with epoch (January 1st, 1970) at the center of the
     # range (2^31).
     try:
         days = val.days_from_epoch
     except AttributeError:
         days = util.Date(val).days_from_epoch
     return uint32_pack(days + 2**31)
Ejemplo n.º 5
0
def write_uint(f, i):
    f.write(uint32_pack(i))
Ejemplo n.º 6
0
 def make_msg(self, header, body=""):
     return header + uint32_pack(len(body)) + body
 def make_msg(self, header, body=six.binary_type()):
     return header + uint32_pack(len(body)) + body
Ejemplo n.º 8
0
 def make_msg(self, header, body=""):
     return header + uint32_pack(len(body)) + body
Ejemplo n.º 9
0
 def serialize(val, protocol_version):
     try:
         days = val.days_from_epoch
     except AttributeError:
         days = util.Date(val).days_from_epoch
     return uint32_pack(days + SimpleDateType.EPOCH_OFFSET_DAYS)
Ejemplo n.º 10
0
 def serialize(val, protocol_version):
     try:
         days = val.days_from_epoch
     except AttributeError:
         days = util.Date(val).days_from_epoch
     return uint32_pack(days + SimpleDateType.EPOCH_OFFSET_DAYS)
Ejemplo n.º 11
0
def write_uint(f, i):
    f.write(uint32_pack(i))
Ejemplo n.º 12
0
 def make_msg(self, header, body=binary_type()):
     return header + uint32_pack(len(body)) + body