def test_max_uuid(self): u = util.max_uuid_from_time(0) # cassandra does a signed comparison of the remaining bytes # the first non-time byte has the variant in it # This byte is always negative, but should be the smallest negative # number with high-order bits '10' self.assertEqual(marshal.int8_unpack(u.bytes[8:9]), -65) for i in range(9, 16): self.assertEqual(marshal.int8_unpack(u.bytes[i:i + 1]), 127)
def deserialize(cls, byts, protocol_version): # <type>[<time0><precision0>[<time1><precision1>]] type_ = int8_unpack(byts[0:1]) if type_ in (BoundKind.to_int(BoundKind.BOTH_OPEN_RANGE), BoundKind.to_int(BoundKind.SINGLE_DATE_OPEN)): time0 = precision0 = None else: time0 = int64_unpack(byts[1:9]) precision0 = int8_unpack(byts[9:10]) if type_ == BoundKind.to_int(BoundKind.CLOSED_RANGE): time1 = int64_unpack(byts[10:18]) precision1 = int8_unpack(byts[18:19]) else: time1 = precision1 = None if time0 is not None: date_range_bound0 = util.DateRangeBound( time0, cls._decode_precision(precision0) ) if time1 is not None: date_range_bound1 = util.DateRangeBound( time1, cls._decode_precision(precision1) ) if type_ == BoundKind.to_int(BoundKind.SINGLE_DATE): return util.DateRange(value=date_range_bound0) if type_ == BoundKind.to_int(BoundKind.CLOSED_RANGE): return util.DateRange(lower_bound=date_range_bound0, upper_bound=date_range_bound1) if type_ == BoundKind.to_int(BoundKind.OPEN_RANGE_HIGH): return util.DateRange(lower_bound=date_range_bound0, upper_bound=util.OPEN_BOUND) if type_ == BoundKind.to_int(BoundKind.OPEN_RANGE_LOW): return util.DateRange(lower_bound=util.OPEN_BOUND, upper_bound=date_range_bound0) if type_ == BoundKind.to_int(BoundKind.BOTH_OPEN_RANGE): return util.DateRange(lower_bound=util.OPEN_BOUND, upper_bound=util.OPEN_BOUND) if type_ == BoundKind.to_int(BoundKind.SINGLE_DATE_OPEN): return util.DateRange(value=util.OPEN_BOUND) raise ValueError('Could not deserialize %r' % (byts,))
def read_byte(f): return int8_unpack(f.read(1))
def deserialize(byts, protocol_version): return int8_unpack(byts)
def test_min_uuid(self): u = util.min_uuid_from_time(0) # cassandra does a signed comparison of the remaining bytes for i in range(8, 16): self.assertEqual(marshal.int8_unpack(u.bytes[i:i + 1]), -128)