From 580d1bb431aad2ce734f5c28980f90dd3902c797 Mon Sep 17 00:00:00 2001 From: lion Date: Fri, 24 Oct 2025 12:47:34 +0800 Subject: [PATCH] update the default xdb path to the latest xdb 3.0 version --- binding/python/ReadMe.md | 14 +++++++------- binding/python/iptest.py | 10 ++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/binding/python/ReadMe.md b/binding/python/ReadMe.md index 837dc4d..71778e6 100644 --- a/binding/python/ReadMe.md +++ b/binding/python/ReadMe.md @@ -9,7 +9,7 @@ from xdbSearcher import XdbSearcher def searchWithFile(): # 1. 创建查询对象 - dbPath = "../../data/ip2region.xdb" + dbPath = "../../data/ip2region_v4.xdb" searcher = XdbSearcher(dbfile=dbPath) # 2. 执行查询 @@ -30,7 +30,7 @@ from xdbSearcher import XdbSearcher def searchWithVectorIndex(): # 1. 预先加载整个 xdb - dbPath = "../../data/ip2region.xdb" + dbPath = "../../data/ip2region_v4.xdb" vi = XdbSearcher.loadVectorIndexFromFile(dbfile=dbPath) # 2. 使用上面的缓存创建查询对象, 同时也要加载 xdb 文件 @@ -47,14 +47,14 @@ def searchWithVectorIndex(): ### 缓存整个 `xdb` 数据 -我们也可以预先加载整个 ip2region.xdb 的数据到内存,然后基于这个数据创建查询对象来实现完全基于文件的查询,类似之前的 memory search。 +我们也可以预先加载整个 xdb 文件的数据到内存,然后基于这个数据创建查询对象来实现完全基于文件的查询,类似之前的 memory search。 ```python from xdbSearcher import XdbSearcher def searchWithContent(): # 1. 预先加载整个 xdb - dbPath = "../../data/ip2region.xdb"; + dbPath = "../../data/ip2region_v4.xdb"; cb = XdbSearcher.loadContentFromFile(dbfile=dbPath) # 2. 仅需要使用上面的全文件缓存创建查询对象, 不需要传源 xdb 文件 @@ -79,9 +79,9 @@ options: --cache-policy string cache policy: file/vectorIndex/content ``` -例如:使用默认的 data/ip2region.xdb 进行查询测试: +例如:使用默认的 data/ip2region_v4.xdb 进行查询测试: ```bash -➜ python git:(python_dev) ✗ python3 ./search_test.py --db=../../data/ip2region.xdb --cache-policy=content +➜ python git:(python_dev) ✗ python3 ./search_test.py --db=../../data/ip2region_v4.xdb --cache-policy=content ip2region xdb searcher test program, cachePolicy: content type 'quit' to exit ip2region>> 1.2.3.4 @@ -106,7 +106,7 @@ options: 例如:通过默认的 data/ip2region.xdb 和 data/ip.merge.txt 来进行 bench 测试: ```bash -➜ python git:(python_dev) ✗ python3 ./bench_test.py --db=../../data/ip2region.xdb --src=../../data/ip.merge.txt --cache-policy=content +➜ python git:(python_dev) ✗ python3 ./bench_test.py --db=../../data/ip2region_v4.xdb --src=../../data/ipv4_source.txt --cache-policy=content Bench finished, [cachePolicy: content, total: 3417955, took: 34.93 s, cost: 0.0094 ms/op] ``` diff --git a/binding/python/iptest.py b/binding/python/iptest.py index 0f8db9f..d11dee3 100644 --- a/binding/python/iptest.py +++ b/binding/python/iptest.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + # Copyright 2022 The Ip2Region Authors. All rights reserved. # Use of this source code is governed by a Apache2.0-style # license that can be found in the LICENSE file. @@ -7,7 +9,7 @@ from xdbSearcher import XdbSearcher def searchWithFile(): # 1. 创建查询对象 - dbPath = "../../data/ip2region.xdb" + dbPath = "../../data/ip2region_v4.xdb" searcher = XdbSearcher(dbfile=dbPath) # 2. 执行查询 @@ -20,7 +22,7 @@ def searchWithFile(): def searchWithVectorIndex(): # 1. 预先加载整个 xdb - dbPath = "../../data/ip2region.xdb" + dbPath = "../../data/ip2region_v4.xdb" vi = XdbSearcher.loadVectorIndexFromFile(dbfile=dbPath) # 2. 使用上面的缓存创建查询对象, 同时也要加载 xdb 文件 @@ -36,7 +38,7 @@ def searchWithVectorIndex(): def searchWithContent(): # 1. 预先加载整个 xdb - dbPath = "../../data/ip2region.xdb"; + dbPath = "../../data/ip2region_v4.xdb"; cb = XdbSearcher.loadContentFromFile(dbfile=dbPath) # 2. 仅需要使用上面的全文件缓存创建查询对象, 不需要传源 xdb 文件 @@ -53,4 +55,4 @@ def searchWithContent(): if __name__ == '__main__': searchWithContent() - + \ No newline at end of file