当前位置: 首页>>代码示例>>Python>>正文


Python xapian.sortable_unserialise函数代码示例

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


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

示例1: _decode_simple_value

def _decode_simple_value(field_cls, data):
    """Used to decode values in stored fields.
    """
    # Overload the Integer type, cf _encode_simple_value
    if issubclass(field_cls, Integer):
        return int(sortable_unserialise(data))
    elif issubclass(field_cls, Decimal):
        return decimal(sortable_unserialise(data))
    # A common field or a new field
    return field_cls.decode(data)
开发者ID:hforge,项目名称:itools,代码行数:10,代码来源:catalog.py

示例2: two_range

    def two_range(self, field, purpose, q):
        """Check the result of a range search which should return 2 items.

        """
        r = [x for x in q.search(0, 10)]
        self.assertEqual(len(r), 2)
        val = xapian.sortable_unserialise(r[0].get_value("foo", "collsort"))
        self.assertTrue(3 <= val)
        self.assertTrue(val <= 4)
        val = xapian.sortable_unserialise(r[1].get_value("foo", "collsort"))
        self.assertTrue(4 <= val)
        self.assertTrue(val <= 5)
开发者ID:varunarya10,项目名称:xappy,代码行数:12,代码来源:range_accel.py

示例3: group_poi

def group_poi(request):
    response = {}
    try:
        response['status'] = 'OK'
        group_type = request.GET.get('gt', 'city_code')
        if group_type == 'admin_code':
            admin_code_spy = xapian.ValueCountMatchSpy(1)
        elif group_type == 'prov_code':
            admin_code_spy = xapian.ValueCountMatchSpy(4)
        else:
            admin_code_spy = xapian.ValueCountMatchSpy(5)
        with contextlib.closing(get_xapian_conn()) as xapian_database:
            poi_query_parser = get_poi_query_parser()
            poi_query_parser.set_database(xapian_database)
            make_group_matches(
                request, poi_query_parser, admin_code_spy, xapian_database)
            group_result = {}
            for value in admin_code_spy.values():
                code = int(xapian.sortable_unserialise(value.term))
                group_result[code] = value.termfreq
            response['results'] = group_result
    except BaseException as e:
        logger.exception(e)
        response['results'] = []
        response['size'] = 0
        response['status'] = 'ERROR_PARAMETERS'
    return json.dumps(response, ensure_ascii=False, encoding='utf-8')
开发者ID:daigong,项目名称:ubuntu-deb-workspace,代码行数:27,代码来源:location.py

示例4: _remove_cached_items

    def _remove_cached_items(self, docid=None, xapid=None):
        """Remove from the cache any items for the specified document.

        The document may be specified by xappy docid, or by xapian document id.

        """
        if self.cache_manager is None:
            raise errors.IndexerError("CacheManager has been applied to this "
                                      "index, but is not currently set.")

        doc, xapid = self._get_xapdoc(docid, xapid)
        if doc is None:
            return

        #print "Removing docid=%d" % xapid
        # FIXME: this will only remove the hits from the set cache
        # manager, if we have multiple applied caches, the others won't be
        # updated.  This means that currently, if multiple caches are applied
        # and document removals happen, some of the caches will get out of
        # date; multiple caches are therefore not really suitable for use in
        # production systems - they are however useful for experimenting with
        # different caching algorithms.
        for value in doc.values():
            base_slot = self._cache_manager_slot_start
            upper_slot = self._cache_manager_slot_start + self.cache_manager.num_cached_queries()
            if not (base_slot <= value.num < upper_slot):
                continue
            rank = int(self._cache_manager_max_hits -
                       xapian.sortable_unserialise(value.value))
            self.cache_manager.remove_hits(
                value.num - self._cache_manager_slot_start,
                ((rank, xapid),))
开发者ID:rboulton,项目名称:xappy,代码行数:32,代码来源:indexerconnection.py

示例5: get_popcon

 def get_popcon(self, doc):
     """ Return a popcon value from a xapian document """
     popcon_raw = doc.get_value(XapianValues.POPCON)
     if popcon_raw:
         popcon = xapian.sortable_unserialise(popcon_raw)
     else:
         popcon = 0
     return popcon
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:8,代码来源:database.py

示例6: single_range

    def single_range(self, field, purpose, q):
        """Check the result of a range search which should return 1 item.

        """
        r = [x for x in q.search(0, 10)]
        self.assertEqual(len(r), 1)
        val = xapian.sortable_unserialise(r[0].get_value(field, purpose))
        self.assertTrue(3 <= val)
        self.assertTrue(val <= 4.01)
开发者ID:varunarya10,项目名称:xappy,代码行数:9,代码来源:range_accel.py

示例7: deconvert

 def deconvert(self, data):
     if data is None:
         return data
     if self.ftype == PyFieldMeta.TYPE_LONG:
         data = data or long(0)
         return long(data)
     elif self.ftype == PyFieldMeta.TYPE_FLOAT:
         return xapian.sortable_unserialise(data)
     else:
         return data.decode('utf-8')
开发者ID:tianshu-secret,项目名称:xapian,代码行数:10,代码来源:PyFieldScheme.py

示例8: remove_cached_items

 def remove_cached_items(self, iconn, doc, xapid):
     #print "Removing docid=%d" % xapid
     for value in doc.values():
         base_slot = cache_manager_slot_start(iconn, self.id)
         upper_slot = base_slot + self.num_cached_queries()
         if not (base_slot <= value.num < upper_slot):
             continue
         rank = int(CACHE_MANAGER_MAX_HITS -
                    xapian.sortable_unserialise(value.value))
         self.remove_hits(
             value.num - base_slot,
             ((rank, xapid),))
开发者ID:mydeco-dev-team,项目名称:xappy,代码行数:12,代码来源:xapian_manager.py

示例9: extract

    def extract(self, document):
        if self.number:
            value = document.get_value(self.number)

            content_type = self._get_content_type(value)

            if self._is_float_or_interger(content_type):
                value = xapian.sortable_unserialise(value)

            return value

        return None
开发者ID:Bombe,项目名称:demozoo,代码行数:12,代码来源:indexer.py

示例10: display_differences

    def display_differences(self, ids1, ids2, name1, name2):
        ids1_unique = ids1 - ids2
        ids2_unique = ids2 - ids1
        if ids1_unique or ids2_unique:
            print "results for %s and %s differ" % (name1, name2)
        if ids1_unique:
            print "ids only in %s: " % name1, ids1_unique
        if ids2_unique:
            print "ids only in %s: " % name2, ids2_unique

        for i in ids1 ^ ids2:
            d = self.sconn.get_document(i)
            print "value: ", xapian.sortable_unserialise(d.get_value('price', 'collsort'))
            print "termlist: ", map (lambda t: t.term, d._doc.termlist())
开发者ID:PaulRudin,项目名称:xappy,代码行数:14,代码来源:range_speed.py

示例11: doc2dict

def doc2dict(doc):
    od = OrderedDict()

    url = doc.get_value(VALUE_URL)
    od['url'] = url

    title = doc.get_value(VALUE_TITLE)
    if title:
        od['title'] = title.decode('UTF-8')

    tags = doc.get_value(VALUE_TAGS)
    od['tags'] = tags.decode('UTF-8').split(u'\x1f') if tags else []

    created = xapian.sortable_unserialise(doc.get_value(VALUE_CREATED))
    od['created'] = arrow.get(created)

    archived_val = doc.get_value(VALUE_ARCHIVED)
    if archived_val:
        archived = xapian.sortable_unserialise(archived_val)
        od['archived'] = arrow.get(archived)

    od['notes'] = doc.get_data().decode('UTF-8')

    return od
开发者ID:ttaylordev,项目名称:z,代码行数:24,代码来源:jot.py

示例12: _generate_records

    def _generate_records(self, mset, select=set(["*"])):
        """
        仅返回item_id,item_type,外部再从memcached、db中读取详细数据
        """
        for m in mset:
            result = {"_did" : m.docid, "_score" : m.percent, "_rank" : m.rank, "_collapse_count" : m.collapse_count, "_weight" : m.weight}
            result['item_id'] = int(xapian.sortable_unserialise(m.document.get_value(DOC_ITEM_ID))) #int
            result['item_type'] = m.document.get_value(DOC_ITEM_TYPE)  #string
            
            if select:
                doc = m.document
                data_str = doc.get_data()
                if len(data_str):
                    data_dict = cPickle.loads(data_str)
                    for key, value in data_dict.items():
                        if key in select or "*" in select:
                            result[key] = value

            yield result
开发者ID:yamingd,项目名称:play,代码行数:19,代码来源:xaql.py

示例13: size

    def size(self):
        """Return the size of the application without dependencies

        Note that this will return the download size if the app is
        not installed and the installed size if it is installed.
        """
        if self._pkg:
            if not self._pkg.installed:
                if self._app.archive_suite:
                    ver = self._get_version_for_archive_suite(self._pkg, self._app.archive_suite)
                    if ver:
                        return ver.size
                return self._pkg.candidate.size
            else:
                return self._pkg.installed.size
        elif self._doc:
            size = self._doc.get_value(XapianValues.DOWNLOAD_SIZE)
            if size:
                return xapian.sortable_unserialise(self._doc.get_value(XapianValues.DOWNLOAD_SIZE))
开发者ID:pombredanne,项目名称:shop,代码行数:19,代码来源:application.py

示例14: _remove_cached_items

    def _remove_cached_items(self, docid=None, xapid=None):
        """Remove from the cache any items for the specified document.

        The document may be specified by xappy docid, or by xapian document id.

        """
        if self.cache_manager is None:
            raise errors.IndexerError("CacheManager has been applied to this "
                                      "index, but is not currently set.")

        doc, xapid = self._get_xapdoc(docid, xapid)
        if doc is None:
            return

        #print "Removing docid=%d" % xapid
        for value in doc.values():
            if value.num < self._cache_manager_slot_start:
                continue
            rank = int(self._cache_manager_max_hits -
                       xapian.sortable_unserialise(value.value))
            self.cache_manager.remove_hits(
                value.num - self._cache_manager_slot_start,
                ((rank, xapid),))
开发者ID:PaulRudin,项目名称:xappy,代码行数:23,代码来源:indexerconnection.py

示例15: get_weight

 def get_weight(self, doc):
     val = doc.get_value(self.field, self.purpose)
     val = xapian.sortable_unserialise(val)
     if val > self.maxval:
         return self.maxval
     return val
开发者ID:PaulRudin,项目名称:xappy,代码行数:6,代码来源:weight_external.py


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