Home > other >  The IP address of the 99.9% accuracy positioning library
The IP address of the 99.9% accuracy positioning library

Time:03-24







The IP address of the accurate rate 99.9% locate library, 0.0 x millisecond query, the database file size is only 1.5 M, Java, PHP, c, python, nodejs, golang, c # query binding and Binary, B tree, memory three query algorithm, mother don't have to worry about me the IP address of the location! http://gitee.com/lionsoul/ip2region
1. 99.9% accuracy, regularly update:
Data aggregation of some well-known IP query to place name provider's data, and these are their official accuracy, the testing is much more accurate than pure what,
Each aggregate data need 1-2 days, will not be updated regularly,
2. The standardized data formats:
Each IP data segments are fixed format: city Id | | | | | area provinces city state ISP
Only data is accurate to the city of China, other countries can only locate to the country, the first option is 0, all already contains all you can look up to the big and small countries, (Id, please ignore the previous city individual project requirements)
3. Small volume:
Database files generated ip2region. Db is only 1.5 M (1.2 version is 3.5 M)
4. The query client support, 0.0 x more millisecond level query
Has integrated the client are: Java, c #, PHP, c, python, nodejs, PHP extensions (support Linux, php5, php7 version has support), golang,
Provides two query algorithm, the response time is as follows:
Client/binary/Memory/b-tree algorithm algorithm:
C #/0. X ms/0. X ms/0. X ms
Java/0. X ms/0. 0.1 x x ms/ms (using RandomAccessFile)
PHP/0. 0.1 x 0.1 x x ms/ms/ms
C/0.0 0.00 x 0.0 x x ms/ms/ms (b-tree algorithm basically stable in 0.02 x milliseconds level)
Python/0. 0.1 x x ms/ms/unknown

Any client b-tree is faster than binary algorithm, of course, the Memory algorithm is the fastest!
Maven warehouse address:


Org. Lionsoul
Ip2region & lt;/artifactId>
1.4 & lt;/version>


Nuget install command

Install - Package IP2Region

5. The test program:
C # :

CD IP2Region_ConsoleTest
Dotnet run
The example result:
Please enter the IP address:
36.149.160.55

Node:
Let ip2region=the require ("./ip2region. Js');
Let dbService=ip2region. Create ('./ip2region. Db ');
DbService. BinarySearchSync (' 101.105.35.57 ')
{city: 0, the region: '| 0 | | | shenzhen guangdong China Dr Peng'}

Java:

CD binding/Java
Ant all
Java - jar ip2region - {version}. Jar./data/ip2region. Db

PHP:

PHP binding/PHP/testSearcher. PHP./data/ip2region db

C:

CD binding/c/
GCC - g - O2 testSearcher. C ip2region. C
./a.out../../data/ip2region. Db

Python:

Python binding/python/testSearcher. Py./data/ip2region db

All can see the following interface:

The initializing b-tree...
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
| ip2region test script |
| the Author: [email protected] |
| Type "quit" to exit the program |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
P2region & gt;> 101.105.35.57
2163 China | | | | | in shenzhen city, guangdong province in southern China in 0.02295 Dr Peng millseconds

Enter the IP address to begin testing, for the first time will be a little slow, behind the run command access binary memory to try other algorithms, it is recommended to use b-tree algorithm, speed and can use the memory algorithm concurrency requirements,
The specific integration refer to different client test source code,
6. How to generate ip2region. Db files
From ip2region version 1.2.2 started inside submitted a dbMaker - {version}. Jar jar file that can be performed on, use it to complete the work:

1, make sure you installed the Java environment (don't play Java between Google find myself, temporary use of a few minutes)
2, CD to the ip2region root directory, then run the following commands:


Java - jar dbMaker - {version}. The jar - SRC text data files - region regional CSV file [- DST generated ip2region. Db file directory]

# text data files: the original text data file path of the db files, own ip2region. Is the db files/data/IP. The merge. TXT generated, you can switch to your own or change/data/IP merge. TXT to regenerate the
# regional CSV file: the purpose of this file is configurable ip2region relationship data storage, the data contains a city_id, the direct use of/data/origin/global_region. CSV file
# ip2region. Db file directory: is an optional parameter, there is no specified will generate a in the current directory./data/ip2region db files


3, get the generated ip2region. Db file cover the original ip2region db files
4, the default ip2region. Db files are generated command:


CD ip2region project root directory
Java - jar dbMaker - 1.2.2. Jar - SRC./data/IP merge. TXT - region./data/global_region CSV

# will see a large output


5, of the structure and principle of the database file please read @ toga blog: "ip2region database file of the structure and principle of the"








CodePudding user response:

Automatic positioning IP
  • Related