• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python marshal.packer_for函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pycassa.marshal.packer_for函数的典型用法代码示例。如果您正苦于以下问题:Python packer_for函数的具体用法?Python packer_for怎么用?Python packer_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了packer_for函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _set_default_validation_class

    def _set_default_validation_class(self, t):
        if isinstance(t, types.CassandraType):
            self._default_validation_class = t
            self._default_value_packer = t.pack
            self._default_value_unpacker = t.unpack
            have_counters = isinstance(t, types.CounterColumnType)
        else:
            self._default_validation_class = marshal.extract_type_name(t)
            self._default_value_packer = marshal.packer_for(t)
            self._default_value_unpacker = marshal.unpacker_for(t)
            have_counters = self._default_validation_class == "CounterColumnType"
        
        if not self.super:
            if have_counters:
                def _make_cosc(name, value, timestamp, ttl):
                    return ColumnOrSuperColumn(counter_column=CounterColumn(name, value))
            else:
                def _make_cosc(name, value, timestamp, ttl):
                    return ColumnOrSuperColumn(Column(name, value, timestamp, ttl))
            self._make_cosc = _make_cosc
        else:
            if have_counters:
                def _make_column(name, value, timestamp, ttl):
                    return CounterColumn(name, value)
                self._make_column = _make_column

                def _make_cosc(scol_name, subcols):
                    return ColumnOrSuperColumn(counter_super_column=(SuperColumn(scol_name, subcols)))
            else:
                self._make_column = Column
                def _make_cosc(scol_name, subcols):
                    return ColumnOrSuperColumn(super_column=(SuperColumn(scol_name, subcols)))
            self._make_cosc = _make_cosc
开发者ID:samuraisam,项目名称:pycassa,代码行数:33,代码来源:columnfamily.py


示例2: __init__

 def __init__(self, reversed=False, default=None):
     self.reversed = reversed
     self.default = default
     if not hasattr(self.__class__, 'pack'):
         self.pack = marshal.packer_for(self.__class__.__name__)
     if not hasattr(self.__class__, 'unpack'):
         self.unpack = marshal.unpacker_for(self.__class__.__name__)
开发者ID:pista329,项目名称:cqla,代码行数:7,代码来源:types.py


示例3: __setitem__

 def __setitem__(self, item, value):
     if isinstance(value, types.CassandraType):
         self.type_map[item] = value
         self.packers[item] = value.pack
         self.unpackers[item] = value.unpack
     else:
         self.type_map[item] = marshal.extract_type_name(value)
         self.packers[item] = marshal.packer_for(value)
         self.unpackers[item] = marshal.unpacker_for(value)
开发者ID:samuraisam,项目名称:pycassa,代码行数:9,代码来源:columnfamily.py


示例4: _set_key_validation_class

 def _set_key_validation_class(self, t):
     if isinstance(t, types.CassandraType):
         self._key_validation_class = t
         self._key_packer = t.pack
         self._key_unpacker = t.unpack
     else:
         self._key_validation_class = marshal.extract_type_name(t)
         self._key_packer = marshal.packer_for(t)
         self._key_unpacker = marshal.unpacker_for(t)
开发者ID:samuraisam,项目名称:pycassa,代码行数:9,代码来源:columnfamily.py


示例5: _set_super_column_name_class

 def _set_super_column_name_class(self, t):
     if isinstance(t, types.CassandraType):
         self._super_column_name_class = t
         self._super_name_packer = t.pack
         self._super_name_unpacker = t.unpack
     else:
         self._super_column_name_class = marshal.extract_type_name(t)
         self._super_name_packer = marshal.packer_for(t)
         self._super_name_unpacker = marshal.unpacker_for(t)
开发者ID:samuraisam,项目名称:pycassa,代码行数:9,代码来源:columnfamily.py


示例6: _alter_column_cfdef

    def _alter_column_cfdef(self, cfdef, column, value_type):
        if cfdef.column_type == 'Super':
            packer = marshal.packer_for(cfdef.subcomparator_type)
        else:
            packer = marshal.packer_for(cfdef.comparator_type)

        packed_column = packer(column)

        value_type = self._qualify_type_class(value_type)

        matched = False
        for c in cfdef.column_metadata:
            if c.name == packed_column:
                c.validation_class = value_type
                matched = True
                break
        if not matched:
            cfdef.column_metadata.append(ColumnDef(packed_column, value_type, None, None))
        
        return cfdef
开发者ID:bshanks,项目名称:pycassa,代码行数:20,代码来源:system_manager.py


示例7: alter_column

    def alter_column(self, keyspace, column_family, column, value_type):
        """
        Sets a data type for the value of a specific column.

        `value_type` is a string that determines what type the column value will be.
        By default, :const:`LONG_TYPE`, :const:`INT_TYPE`,
        :const:`ASCII_TYPE`, :const:`UTF8_TYPE`, :const:`TIME_UUID_TYPE`,
        :const:`LEXICAL_UUID_TYPE` and :const:`BYTES_TYPE` are provided.  Custom
        types may be used as well by providing the class name; if the custom
        comparator class is not in ``org.apache.cassandra.db.marshal``, the fully
        qualified class name must be given.

        For super column families, this sets the subcolumn value type for
        any subcolumn named `column`, regardless of the super column name.

        """

        self._conn.set_keyspace(keyspace)
        cfdef = self.get_keyspace_column_families(keyspace)[column_family]

        if cfdef.column_type == 'Super':
            packer = marshal.packer_for(cfdef.subcomparator_type)
        else:
            packer = marshal.packer_for(cfdef.comparator_type)

        packed_column = packer(column)

        value_type = self._qualify_type_class(value_type)

        matched = False
        for c in cfdef.column_metadata:
            if c.name == packed_column:
                c.validation_class = value_type
                matched = True
                break
        if not matched:
            cfdef.column_metadata.append(ColumnDef(packed_column, value_type, None, None))
        self._system_update_column_family(cfdef)
开发者ID:truesef-dev,项目名称:pycassa,代码行数:38,代码来源:system_manager.py


示例8: create_index

    def create_index(self, keyspace, column_family, column, value_type,
                     index_type=KEYS_INDEX, index_name=None):
        """
        Creates an index on a column.

        This allows efficient for index usage via
        :meth:`~pycassa.columnfamily.ColumnFamily.get_indexed_slices()`

        `column` specifies what column to index, and `value_type` is a string
        that describes that column's value's data type; see
        :meth:`alter_column()` for a full description of `value_type`.

        `index_type` determines how the index will be stored internally. Currently,
        :const:`KEYS_INDEX` is the only option.  `index_name` is an optional name
        for the index.

        Example Usage:

        .. code-block:: python

            >>> from pycassa.system_manager import *
            >>> sys = SystemManager('192.168.2.10:9160')
            >>> sys.create_index('Keyspace1', 'Standard1', 'birthdate', LONG_TYPE, index_name='bday_index')
            >>> sys.close

        """

        self._conn.set_keyspace(keyspace)
        cfdef = self.get_keyspace_column_families(keyspace)[column_family]

        packer = marshal.packer_for(cfdef.comparator_type)
        packed_column = packer(column)

        value_type = self._qualify_type_class(value_type)

        coldef = ColumnDef(packed_column, value_type, index_type, index_name)

        for c in cfdef.column_metadata:
            if c.name == packed_column:
                cfdef.column_metadata.remove(c)
                break
        cfdef.column_metadata.append(coldef)
        self._system_update_column_family(cfdef)
开发者ID:bshanks,项目名称:pycassa,代码行数:43,代码来源:system_manager.py


示例9: __init__

    def __init__(self, reversed=False, default=None):
        """
        A data type that Cassandra is aware of and knows
        how to validate and sort.

        If `reversed` is true and this is used as a column comparator,
        the columns will be sorted in reverse order.

        This is also used to specify fields to be persisted when
        a class is used with :class:`~.ColumnFamilyMap`.

        The `default` parameter only applies to use of this
        with ColumnFamilyMap, where `default` is used if a row
        does not contain a column corresponding to this item.

        .. versionadded:: 1.2.0

        """
        self.reversed = reversed
        self.default = default
        self.pack = marshal.packer_for(self.__class__.__name__)
        self.unpack = marshal.unpacker_for(self.__class__.__name__)
开发者ID:DataDog,项目名称:pycassa,代码行数:22,代码来源:types.py


示例10: __init__

 def __init__(self, reversed=False, default=None):
     self.reversed = reversed
     self.default = default
     self.pack = marshal.packer_for(self.__class__.__name__)
     self.unpack = marshal.unpacker_for(self.__class__.__name__)
开发者ID:bwhite,项目名称:pycassa,代码行数:5,代码来源:types.py


示例11: __init__

 def __init__(self, *args, **kwargs):
     super(PickleType, self).__init__(*args, **kwargs)
     self.pack_bytes = marshal.packer_for('BytesType')
     self.unpack_bytes = marshal.unpacker_for('BytesType')
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:4,代码来源:pickle.py


示例12: __init__

 def __init__(self, *args, **kwargs):
     super(MicrosecondTimestampType, self).__init__(*args, **kwargs)
     self.pack_integer = marshal.packer_for('IntegerType')
     self.unpack_integer = marshal.unpacker_for('IntegerType')
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:4,代码来源:microsecond_timestamp.py


示例13: __init__

 def __init__(self, *args, **kwargs):
     super(RealType, self).__init__(*args, **kwargs)
     self.pack_ascii = marshal.packer_for('AsciiType')
     self.unpack_ascii = marshal.unpacker_for('AsciiType')
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:4,代码来源:real.py



注:本文中的pycassa.marshal.packer_for函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python marshal.unpacker_for函数代码示例发布时间:2022-05-25
下一篇:
Python marshal.extract_type_name函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap