コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
    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, ))
コード例 #4
0
ファイル: cqltypes.py プロジェクト: JeremyOT/python-driver
 def deserialize(byts):
     return bool(int8_unpack(byts))
コード例 #5
0
ファイル: protocol.py プロジェクト: CunjunWang/project-mnist
def read_byte(f):
    return int8_unpack(f.read(1))
コード例 #6
0
 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)
コード例 #7
0
 def deserialize(byts):
     return bool(int8_unpack(byts))
コード例 #8
0
ファイル: decoder.py プロジェクト: JeremyOT/python-driver
def read_byte(f):
    return int8_unpack(f.read(1))
コード例 #9
0
ファイル: cqltypes.py プロジェクト: sakura-sky/python-driver
 def deserialize(byts, protocol_version):
     return bool(int8_unpack(byts))
コード例 #10
0
ファイル: cqltypes.py プロジェクト: ShayanIshaq/Repo_test
 def deserialize(byts, protocol_version):
     return int8_unpack(byts)
コード例 #11
0
 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)