当前位置: 首页 > news >正文

南山做网站的公司电子元器件网站建设

南山做网站的公司,电子元器件网站建设,泉州专业网站制作定制,电商网站的建设与维护文章目录 Pre效果实现git clone编译测试程序将ip2region.xdb放到指定目录使用改进最终效果 Pre OpenSource - Ip2region 离线IP地址定位库和IP定位数据管理框架 Ip2region - xdb java 查询客户端实现 效果 最终效果 实现 git clone git clone https://github.com/lionsou… 文章目录 Pre效果实现git clone编译测试程序将ip2region.xdb放到指定目录使用改进最终效果 Pre OpenSource - Ip2region 离线IP地址定位库和IP定位数据管理框架 Ip2region - xdb java 查询客户端实现 效果 最终效果 实现 git clone git clone https://github.com/lionsoul2014/ip2region.git编译测试程序 cd binding/java/ mvn compile package然后会在当前目录的 target 目录下得到一个 ip2region-{version}.jar 的打包文件。 将ip2region.xdb放到指定目录 使用 改进 // 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. // Author Lion chenxin619315gmail.com // Date 2022/06/23package org.lionsoul.ip2region;import org.lionsoul.ip2region.xdb.Searcher;import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.util.Scanner; import java.util.concurrent.TimeUnit;public class SearchTest {public static void printHelp(String[] args) {System.out.print(ip2region xdb searcher\n);System.out.print(java -jar ip2region-{version}.jar [command] [command options]\n);System.out.print(Command: \n);System.out.print( search search input test\n);System.out.print( bench search bench test\n);}public static Searcher createSearcher(String dbPath, String cachePolicy) throws IOException {if (file.equals(cachePolicy)) {return Searcher.newWithFileOnly(dbPath);} else if (vectorIndex.equals(cachePolicy)) {byte[] vIndex Searcher.loadVectorIndexFromFile(dbPath);return Searcher.newWithVectorIndex(dbPath, vIndex);} else if (content.equals(cachePolicy)) {byte[] cBuff Searcher.loadContentFromFile(dbPath);return Searcher.newWithBuffer(cBuff);} else {throw new IOException(invalid cache policy cachePolicy , options: file/vectorIndex/content);}}public static void searchTest(String[] args) throws IOException {String dbPath , cachePolicy vectorIndex;for (final String r : args) {if (r.length() 5) {continue;}if (r.indexOf(--) ! 0) {continue;}int sIdx r.indexOf();if (sIdx 0) {System.out.printf(missing for args pair %s\n, r);return;}String key r.substring(2, sIdx);String val r.substring(sIdx 1);// System.out.printf(key%s, val%s\n, key, val);if (db.equals(key)) {dbPath val;} else if (cache-policy.equals(key)) {cachePolicy val;} else {System.out.printf(undefined option %s\n, r);return;}}if (dbPath.length() 1) {System.out.print(java -jar ip2region-{version}.jar search [command options]\n);System.out.print(options:\n);System.out.print( --db string ip2region binary xdb file path\n);System.out.print( --cache-policy string cache policy: file/vectorIndex/content\n);return;}Searcher searcher createSearcher(dbPath, cachePolicy);Scanner scanner new Scanner(System.in);String line scanner.nextLine();try {String region searcher.search(line.trim());System.out.printf(ip: %s , region: %s\n, line, region);} catch (Exception e) {System.out.printf({err: %s, ioCount: %d}\n, e, searcher.getIOCount());}searcher.close();}public static void benchTest(String[] args) throws IOException {String dbPath , srcPath , cachePolicy vectorIndex;for (final String r : args) {if (r.length() 5) {continue;}if (r.indexOf(--) ! 0) {continue;}int sIdx r.indexOf();if (sIdx 0) {System.out.printf(missing for args pair %s\n, r);return;}String key r.substring(2, sIdx);String val r.substring(sIdx 1);if (db.equals(key)) {dbPath val;} else if (src.equals(key)) {srcPath val;} else if (cache-policy.equals(key)) {cachePolicy val;} else {System.out.printf(undefined option %s\n, r);return;}}if (dbPath.length() 1 || srcPath.length() 1) {System.out.print(java -jar ip2region-{version}.jar bench [command options]\n);System.out.print(options:\n);System.out.print( --db string ip2region binary xdb file path\n);System.out.print( --src string source ip text file path\n);System.out.print( --cache-policy string cache policy: file/vectorIndex/content\n);return;}Searcher searcher createSearcher(dbPath, cachePolicy);long count 0, costs 0, tStart System.nanoTime();String line;final Charset charset Charset.forName(utf-8);final FileInputStream fis new FileInputStream(srcPath);final BufferedReader reader new BufferedReader(new InputStreamReader(fis, charset));while ((line reader.readLine()) ! null) {String l line.trim();String[] ps l.split(\\|, 3);if (ps.length ! 3) {System.out.printf(invalid ip segment %s\n, l);return;}long sip;try {sip Searcher.checkIP(ps[0]);} catch (Exception e) {System.out.printf(check start ip %s: %s\n, ps[0], e);return;}long eip;try {eip Searcher.checkIP(ps[1]);} catch (Exception e) {System.out.printf(check end ip %s: %s\n, ps[1], e);return;}if (sip eip) {System.out.printf(start ip(%s) should not be greater than end ip(%s)\n, ps[0], ps[1]);return;}long mip (sip eip) 1;for (final long ip : new long[]{sip, (sip mip) 1, mip, (mip eip) 1, eip}) {long sTime System.nanoTime();String region searcher.search(ip);costs System.nanoTime() - sTime;// check the region infoif (!ps[2].equals(region)) {System.out.printf(failed search(%s) with (%s ! %s)\n, Searcher.long2ip(ip), region, ps[2]);return;}count;}}reader.close();searcher.close();long took System.nanoTime() - tStart;System.out.printf(Bench finished, {cachePolicy: %s, total: %d, took: %ds, cost: %d μs/op}\n,cachePolicy, count, TimeUnit.NANOSECONDS.toSeconds(took),count 0 ? 0 : TimeUnit.NANOSECONDS.toMicros(costs / count));}public static void main(String[] args) {if (args.length 1) {printHelp(args);return;}if (search.equals(args[0])) {try {searchTest(args);} catch (IOException e) {System.out.printf(failed running search test: %s\n, e);}} else if (bench.equals(args[0])) {try {benchTest(args);} catch (IOException e) {System.out.printf(failed running bench test: %s\n, e);}} else {printHelp(args);}}} 重新编译 执行 最终效果 这样就可以愉快的在脚本中调用了 当然了启动java进程的过程相对还是比较耗时的这里仅提供一种思路
http://www.hkea.cn/news/14261443/

相关文章:

  • mysol做的选课网站网站建设及上线流程
  • 做网站效果电商网站开发多少钱
  • 深圳专门做兼职的网站编程网站项目做哪个比较好
  • 网站开发技术服务费合同范本WordPress百度快照图片
  • 简单网站建设课程网站域解析查询
  • 具有品牌的网站建设好用的免费网站
  • 平阳手机网站制作专业影视广告制作公司
  • 网站建设需要下载哪些软件网站代码调试
  • 怎样建立静态网站网站建设合同 技术合同
  • 网站和域名区别wordpress音乐播放器刷新
  • 网站专题页面设计欣赏做地暖工程的网站
  • 怎样在建立公司网站万网手机网站
  • 小型企业网站建设旅游景点网论文wordpress主机记录
  • 网站关键词排名外包网站云解析域名解析
  • 有一个做搞笑英语视频网站三站合一网站营销
  • 北京做网站男生工资网站建设的描述
  • 网站开发模板免费下载域名多少钱一年
  • 电子商务网站推广计划访问网站需要账号密码
  • 深圳网站建设php推广策略有哪些方法
  • dede新手做网站多久网站建设公司公司我我提供一个平台
  • phpmysql网站开发实例装修公司工装公司
  • 怎么用APdiv做网站导航栏网页平台制作
  • 电子商务安全问题 网站权限WordPress 云 memcache
  • 做php门户网站那个系统好图书馆网站建设公司
  • .net开发网站怎么样无锡网站制作
  • 建立自己网站免费八大营销模式有哪几种
  • 网站建设用什么视频播放器wordpress后台经常504
  • 兴县做网站的公司wordpress首页显示一张图片
  • iis发布网站无法访问知名的企业网站建设
  • 濮阳网站制作网站创建方案论文