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

Python solr.pooled_connection函数代码示例

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

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



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

示例1: delete

def delete(track_ids, do_commit=True, local=False):
    # delete one or more track_ids from the fp flat.
    if not isinstance(track_ids, list):
        track_ids = [track_ids]

    # delete a code from FP flat
    if local:
        return local_delete(track_ids)

    with solr.pooled_connection(_fp_solr) as host:
        for t in track_ids:
            host.delete_query("track_id:%s*" % t)

    try:
        get_tyrant_lock().acquire()
        delete_list = map(lambda track_id: map(lambda i: "%s-%s" % (track_id, i),range(20)), track_ids)
        delete_list = sum(delete_list,[])
        get_tyrant().multi_del(delete_list)
    except KeyError:
        pass
    finally:
        get_tyrant_lock().release()

    if do_commit:
        commit()
开发者ID:jun06t,项目名称:echoprint-server,代码行数:25,代码来源:fp.py


示例2: ingest

def ingest(fingerprint_list, do_commit=True, local=False):
    """ Ingest some fingerprints into the fingerprint database.
        The fingerprints should be of the form
          {"track_id": id, "fp": fp, "artist": artist, "release": release, "track": track, "length": length, "codever": "codever"}
        or a list of the same. All parameters except length must be strings. Length is an integer.
        artist, release and track are not required but highly recommended.
        length is the length of the track being ingested in seconds.
        if track_id is empty, one will be generated.
    """
    if not isinstance(fingerprint_list, list):
        fingerprint_list = [fingerprint_list]
        
    docs = []
    codes = []
    for fprint in fingerprint_list:
        if not ("track_id" in fprint and "fp" in fprint and "length" in fprint and "codever" in fprint):
            raise Exception("Missing required fingerprint parameters (track_id, fp, length, codever")
        split_prints = split_codes(fprint)
        docs.extend(split_prints)
        codes.extend(((c["track_id"].encode("utf-8"), c["fp"].encode("utf-8")) for c in split_prints))

    if local:
        return local_ingest(docs, codes)

    with solr.pooled_connection(_fp_solr) as host:
        host.add_many(docs)

    get_tyrant().multi_set(codes)

    if do_commit:
        commit()
开发者ID:anniec,项目名称:echoprint-server,代码行数:31,代码来源:fp.py


示例3: check_for_fields

def check_for_fields():
    with solr.pooled_connection(fp._fp_solr) as host:
        results = host.query("-source:[* TO *]", rows=1, score=False)
        if len(results) > 0:
            print >>sys.stderr, "Missing 'source' field on at least one doc. Run util/upgrade_server.py"
            sys.exit(1)
        results = host.query("-import_date:[* TO *]", rows=1, score=False)
        if len(results) > 0:
            print >>sys.stderr, "Missing 'import_date' field on at least one doc. Run util/upgrade_server.py"
            sys.exit(1)        
开发者ID:0verflo,项目名称:echoprint-server,代码行数:10,代码来源:slave_dump.py


示例4: ingest

def ingest(fingerprint_list, do_commit=True, local=False, split=True):
    """ Ingest some fingerprints into the fingerprint database.
        The fingerprints should be of the form
          {"track_id": id,
          "fp": fp string,
          "artist": artist,
          "release": release,
          "track": track,
          "length": length,
          "codever": "codever",
          "source": source,
          "import_date":import date}
        or a list of the same. All parameters except length must be strings. Length is an integer.
        artist, release and track are not required but highly recommended.
        The import date should be formatted as an ISO 8601 date (yyyy-mm-ddThh:mm:ssZ) and should
        be the UTC time that the the import was performed. If the date is missing, the time the
        script was started will be used.
        length is the length of the track being ingested in seconds.
        if track_id is empty, one will be generated.
    """
    if not isinstance(fingerprint_list, list):
        fingerprint_list = [fingerprint_list]

    docs = []
    codes = []
    if split:
        for fprint in fingerprint_list:
            if not ("track_id" in fprint and "fp" in fprint and "length" in fprint and "codever" in fprint):
                raise Exception("Missing required fingerprint parameters (track_id, fp, length, codever")
            if "import_date" not in fprint:
                fprint["import_date"] = IMPORTDATE
            if "source" not in fprint:
                fprint["source"] = "local"
            split_prints = split_codes(fprint)
            docs.extend(split_prints)
            codes.extend(((c["track_id"].encode("utf-8"), c["fp"].encode("utf-8")) for c in split_prints))
    else:
        docs.extend(fingerprint_list)
        codes.extend(((c["track_id"].encode("utf-8"), c["fp"].encode("utf-8")) for c in fingerprint_list))

    if local:
        return local_ingest(docs, codes)

    try:
        get_tyrant_lock().acquire()
        get_tyrant().multi_set(codes)
    finally:
        get_tyrant_lock().release()

    with solr.pooled_connection(_fp_solr) as host:
        host.add_many(docs)

    if do_commit:
        commit()
开发者ID:jun06t,项目名称:echoprint-server,代码行数:54,代码来源:fp.py


示例5: query_fp

 def query_fp(self, code_string, rows=15, get_data=False):
     try:
         # query the fp flat
         if get_data:
             fields = "track_id,artist,release,track,length"
         else:
             fields = "track_id"
         with solr.pooled_connection(self._fp_solr) as host:
             resp = host.query(code_string, qt="/hashq", rows=rows, fields=fields)
         return resp
     except solr.SolrException:
         return None
开发者ID:Dav1dde,项目名称:emfas,代码行数:12,代码来源:fp.py


示例6: erase_database

    def erase_database(self, really_delete=False):
        """ This method will delete your ENTIRE database. Only use it if you
            know what you're doing.
        """
        if not really_delete:
            raise Exception("Won't delete unless you pass in really_delete=True")

        with solr.pooled_connection(self._fp_solr) as host:
            host.delete_query("*:*")
            host.commit()

        self.tyrant.multi_del(self.tyrant.keys())
开发者ID:Dav1dde,项目名称:emfas,代码行数:12,代码来源:fp.py


示例7: metadata_for_track_id

    def metadata_for_track_id(self, track_id, append_end=True):
        if not track_id or not len(track_id):
            return {}
        # Assume track_ids have 1 - and it's at the end of the id.
        if append_end:
            track_id = "%s-0" % track_id

        with solr.pooled_connection(self._fp_solr) as host:
            response = host.query("track_id:%s" % track_id)

        if len(response.results):
            return response.results[0]
        return {}
开发者ID:Dav1dde,项目名称:emfas,代码行数:13,代码来源:fp.py


示例8: main

def main():
    print "setting source to '%s', import date to %s" % (SOURCE, IMPORTDATE)
    with solr.pooled_connection(fp._fp_solr) as host:
        # Find rows where source field doesn't exist
        results = host.query("-source:[* TO *]", rows=ROWS_PER_QUERY, score=False)
        resultlen = len(results)
        while resultlen > 0:
            print "got",resultlen,"results"
            processed = process_results(results.results)
            host.add_many(processed)
            host.commit()
            results = host.query("-source:[* TO *]", rows=ROWS_PER_QUERY, score=False)
            resultlen = len(results)
        print "done"
开发者ID:andrei4002,项目名称:echoprint-server,代码行数:14,代码来源:upgrade_server.py


示例9: query_fp

def query_fp(code_string, rows=15, local=False, get_data=False):
    if local:
        return local_query_fp(code_string, rows, get_data=get_data)

    try:
        # query the fp flat
        if get_data:
            fields = "track_id,artist,release,track,length,youtube,characters"
        else:
            fields = "track_id"
        with solr.pooled_connection(_fp_solr) as host:
            resp = host.query(code_string, qt="/hashq", rows=rows, fields=fields)
        return resp
    except solr.SolrException:
        return None
开发者ID:simno,项目名称:echoprint-server,代码行数:15,代码来源:fp.py


示例10: delete

    def delete(self, track_ids, do_commit=True):
        # delete one or more track_ids from the fp flat.
        if not isinstance(track_ids, list):
            track_ids = [track_ids]

        with solr.pooled_connection(self._fp_solr) as host:
            for t in track_ids:
                host.delete_query("track_id:%s*" % t)

        try:
            self.tyrant.multi_del(track_ids)
        except KeyError:
            pass

        if do_commit:
            self.commit()
开发者ID:Dav1dde,项目名称:emfas,代码行数:16,代码来源:fp.py


示例11: metadata_for_track_id

def metadata_for_track_id(track_id, local=False):
    if not track_id or not len(track_id):
        return {}
    # Assume track_ids have 1 - and it's at the end of the id.
    if "-" not in track_id:
        track_id = "%s-0" % track_id
        
    if local:
        return _fake_solr["metadata"][track_id]
        
    with solr.pooled_connection(_fp_solr) as host:
        response = host.query("track_id:%s" % track_id)

    if len(response.results):
        return response.results[0]
    else:
        return {}
开发者ID:CuiBono,项目名称:cuibono_webservice,代码行数:17,代码来源:fp-cuibono.py


示例12: erase_database

def erase_database(really_delete=False, local=False):
    """ This method will delete your ENTIRE database. Only use it if you
        know what you're doing.
    """
    if not really_delete:
        raise Exception("Won't delete unless you pass in really_delete=True")

    if local:
        return local_erase_database()

    with solr.pooled_connection(_fp_solr) as host:
        host.delete_query("*:*")
        host.commit()

    tyrant = get_tyrant()
    get_tyrant_lock().acquire()
    tyrant.multi_del(tyrant.keys())
    get_tyrant_lock().release()
开发者ID:andrei4002,项目名称:echoprint-server,代码行数:18,代码来源:fp.py


示例13: delete

def delete(track_ids, do_commit=True, local=False):
    # delete one or more track_ids from the fp flat. 
    if not isinstance(track_ids, list):
        track_ids = [track_ids]

    # delete a code from FP flat
    if local:
        return local_delete(track_ids)

    with solr.pooled_connection(_fp_solr) as host:
        for t in track_ids:
            host.delete_query("track_id:%s*" % t)
    
    try:
        get_tyrant().multi_del(track_ids)
    except KeyError:
        pass
    
    if do_commit:
        commit()
开发者ID:CuiBono,项目名称:cuibono_webservice,代码行数:20,代码来源:fp-cuibono.py


示例14: dump

def dump(start=0):
    try:
#        lastdump = tyrant["lastdump"]
	 lastdump = "*"
    except KeyError:
        lastdump = "*"

    filecount = 1
    itemcount = 1
    filename = FILENAME_TEMPLATE % (now, filecount)
    writer = csv.writer(open(filename, "w"))
    with solr.pooled_connection(fp._fp_solr) as host:
        items_to_dump = host.query("import_date:[%s TO %s]" % (lastdump, now), rows=10000, start=start)
        print "going to dump %s entries" % items_to_dump.results.numFound
        resultlen = len(items_to_dump)
        while resultlen > 0:
            print "writing %d results from start=%s" % (resultlen, items_to_dump.results.start)
            for r in items_to_dump.results:
                row = [r["track_id"],
                       r["codever"],
                       tyrant[str(r["track_id"])],
                       r["length"],
                       r.get("artist", ""),
                       r.get("release", ""),
                       r.get("track", "")
                      ]
                writer.writerow(row)
            itemcount += resultlen
            if itemcount > ITEMS_PER_FILE:
                filecount += 1
                filename = FILENAME_TEMPLATE % (now, filecount)
                print "Making new file, %s" % filename
                writer = csv.writer(open(filename, "w"))
                itemcount = resultlen
            items_to_dump = items_to_dump.next_batch()
            resultlen = len(items_to_dump)

    # Write the final completion time
    tyrant["lastdump"] = now
开发者ID:ClipInteractive,项目名称:echoprint-server,代码行数:39,代码来源:master_dump.py


示例15: commit

def commit(local=False):
    with solr.pooled_connection(_fp_solr) as host:
        host.commit()
开发者ID:CuiBono,项目名称:cuibono_webservice,代码行数:3,代码来源:fp-cuibono.py


示例16: commit

 def commit(self):
     with solr.pooled_connection(self._fp_solr) as host:
         host.commit()
开发者ID:Dav1dde,项目名称:emfas,代码行数:3,代码来源:fp.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python solr.SolrConnection类代码示例发布时间:2022-05-27
下一篇:
Python descriptor.SoloCommandDescriptor类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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