推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
mengzhuo
V2EX  ›  Python

存不存这样的数据结构?能按多个属性值进行搜索?

  •  
  •   mengzhuo · Jun 16, 2014 · 4501 views
    This topic created in 4353 days ago, the information mentioned may be changed or developed.
    比如有类似下列的数据

    {service: {version:1, methods:[a,b,c]}}

    使其可以按多(或一)个属性值进行搜索该类数据,特别是methods也可以按单个或多个搜索
    例如:
    version=1&methods=a


    我想过

    1. hash整个搜索条件(service+version+methods),但是觉得实在是太弱智了,而且没办法做多种条件搜索....

    2. 也想过多个hash组做搜索service/version/methods都做索引,这样确实可以多种条件搜索了,但是要维护对多组索引做原子操作,而且写的时候还得锁定,要不然数据读出来时就是脏的...

    所以在这里求各位大大指导,跪谢
    Supplement 1  ·  Jun 17, 2014
    最后用了树+多索引的方案,虽然update,delete的时候得锁着……
    7 replies    2014-06-18 07:24:24 +08:00
    hourui
        1
    hourui  
       Jun 16, 2014
    mongodb
    billlee
        2
    billlee  
       Jun 17, 2014
    你需要一个现成的数据库
    mengzhuo
        3
    mengzhuo  
    OP
       Jun 17, 2014
    @billlee
    @hourui

    我知道数据库,但是不想在这么简单的程序里整个数据库的依赖出来。
    kurtis
        4
    kurtis  
       Jun 17, 2014
    underscore
    mengzhuo
        5
    mengzhuo  
    OP
       Jun 17, 2014
    @kurtis

    不是JS
    是Python啊……我明明发在Python下的
    pandada8
        6
    pandada8  
       Jun 17, 2014
    sqlite
    marklrh
        7
    marklrh  
       Jun 18, 2014 via iPhone
    B+ tree啊...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4231 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 00:12 · PVG 08:12 · LAX 17:12 · JFK 20:12
    ♥ Do have faith in what you're doing.