Git Product home page Git Product logo

chinamobilephoneregion's Introduction

ChinaMobilePhoneRegion

Build Status

高性能**手机号码归属地查询库,内置43万个号码段,文件压缩后只有1MB。

提供内存及IO加载方式查询,建议装载到内存上查询性能更高。

Packages & Status

Package NuGet
ChinaMobilePhoneRegion NuGet package

Performance

I7-6700K 32G DDR4

单条查询0.0042ms,以下为20 million调用性能:

Kind Total Time Per Second
1 thread 7815.7194ms 250m+
4 threads 2356.6162ms 840m+
parallel 2111.2532ms 940m+

Usage

建议采取内置数据源方式使用:

var searcher = MobilePhoneFactory.GetSearcher();

if(searcher.TryGet("13702331111", out MobilePhone info))
{
    Console.WriteLine(info);
}

OR

//查询结果
var result = searcher.Search(1370233);

if(result.Success)
{
    //成功后使用行政编码获取相应信息
    var adCode = ChinaAdCode.Get(result.AdCode);
}

数据源或者ISearcher对象建议定义为全局单例来使用

内存数据源:

//将数据加载到内存中进行搜索,服务器级别的硬件能达到千万级每秒查询
var dataSource = new MemoryDataSource(filename);

var searcher = MobilePhoneFactory.GetSearcher(dataSource);

if(searcher.TryGet("13702331111", out MobilePhone info))
{
    Console.WriteLine(info);
}

dataSource.Dispose();

IO数据源:

//使用IO方式进行搜索
var dataSource = new StreamDataSource(filename);

var searcher = MobilePhoneFactory.GetSearcher(dataSource);

if(searcher.TryGet("13702331111", out MobilePhone info))
{
    Console.WriteLine(info);
}

dataSource.Dispose();

手机归属存储的数据内容是行政区域编码,其中内置了**行政区域信息查询库,完整使用请查看测试用例:

var info = ChinaAdCode.Get(440402);

var info = ChinaAdCode.Search("广东省");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.