{"id":34577161,"url":"https://github.com/erning/subset","last_synced_at":"2026-05-27T15:33:13.532Z","repository":{"id":137992486,"uuid":"2212040","full_name":"erning/subset","owner":"erning","description":null,"archived":false,"fork":false,"pushed_at":"2014-07-06T00:43:14.000Z","size":5826,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-11T05:29:41.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-15T20:30:28.000Z","updated_at":"2023-03-12T15:06:29.489Z","dependencies_parsed_at":null,"dependency_job_id":"00528518-dcc2-4a6a-a55d-e0dce1341804","html_url":"https://github.com/erning/subset","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/erning/subset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erning%2Fsubset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erning%2Fsubset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erning%2Fsubset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erning%2Fsubset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erning","download_url":"https://codeload.github.com/erning/subset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erning%2Fsubset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33573251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-24T09:56:17.431Z","updated_at":"2026-05-27T15:33:13.527Z","avatar_url":"https://github.com/erning.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Build Status](https://travis-ci.org/erning/subset.png)](https://travis-ci.org/erning/subset)\n\n## Quick Start\n\n```text\n$ git clone git://github.com/erning/subset.git\n$ cd subset\n$ script/bootstrap\n```\n\n### Run it\n```text\n$ .bootstrap/ve subset 'age\u003e21' 'age\u003e20'\n\n\"age\u003e21\" is subset of \"age\u003e20\"\n\"age\u003e20\" is NOT subset of \"age\u003e21\"\n```\n\n### Tests\n```\n$ .bootstrap/ve python tests.py\n\n..........\n----------------------------------------------------------------------\nRan 10 tests in 0.044s\n\nOK\n```\n\n## 原始问题\n\n请写一个算法，判断一个查询表达式是不是另外一个查询表达式的子集。\n\n稍微加一点解释\n\n就拿SQL语句为例，如果查询A是\n\n    age \u003e 21\n\n查询B是\n\n    age \u003e 20\n\n我们知道，A所代表的集合是B所代表的集合的子集。凡是满足A的条件的记录，也一定满足B的条件。我需要一个算法，在给出任意两个表达式以后，判断一个是不是另外一个的子集。\n\n    if($queryA-\u003eisSubSet($queryB)) { echo(“A is subset of B”);}\n    \n为了简单起见，只需要实现最简单的AND, OR逻辑操作，大于，等于，小于三种比较操作就好。最好用PHP，其他语言，比如Java也没问题。\n\n这有什么用呢？\n\n这是个我们不到10人的技术团队日常典型需要解决的问题。给个例子：百姓网为了应付更大的搜索数据量，把搜索分布在多个城市的多台服务器上。系统管理员可以根据数据的使用频度等规律，配置几个不同的数据库（MySQL的，和Solr的）。这样，当有一个新的广告出来后，子集算法根据搜索库的配置查询就可以决定，它更新到哪一个或多个库里面。\n\n查询的时候，如果确认给定的查询条件是以前配置的一个库的子集，就可以只从那个库里查询了。这可以让我们轻松地配置几十个搜索库，而不用改一行代码。\n\nhttp://blog.baixing.com/?p=9\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferning%2Fsubset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferning%2Fsubset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferning%2Fsubset/lists"}