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

QQ可以在网站做临时会话么网站设计费用明细

QQ可以在网站做临时会话么,网站设计费用明细,公司找人做网站,小程序编程文章目录 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 <chenxin619315@gmail.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.ds6.com.cn/news/90025.html

相关文章:

  • 中国建筑网官网电工证证件查询武汉排名seo公司
  • 微信网站建设公司如何开发一个网站
  • 做网站网站内容seo
  • 东莞响应式网站制作网址查询ip地址
  • 唐山建设公司网站出售友情链接是什么意思
  • 做网站赚钱容易吗网站站长seo推广
  • 做网站连带责任windows优化大师是官方的吗
  • 中企动力网站后台 好用吗推广百度百科
  • 广州网站定制服务seo顾问阿亮
  • wordpress 发布文章工具优化seo
  • 无锡做企业网站的公司淘宝指数网站
  • 深圳市万齐创想科技有限公司武汉网络seo公司
  • 北京科技网站建设市场调研的方法
  • 申请做网站编辑组长的工作设想新郑网络推广公司
  • 网站初期seo怎么做网络营销师证书
  • 怎样做水果外卖加盟网站西安网站建设排名
  • 哈尔滨做网站哪家好强电商代运营公司
  • 西安企业网站制作公司二级域名注册
  • wordpress投票插件网站推广优化流程
  • 网页设计登录界面模板单页面seo搜索引擎优化
  • 朔州市网站建设重庆关键词优化软件
  • 网站产品图片尺寸软件开发自学步骤
  • 网站编辑做啥都广州seo公司官网
  • 个人可以做网站吗百度推广营销页
  • 品牌网站大全站外推广方式有哪些
  • 网站备案许可证号外贸建站公司
  • wordpress中插入表格seo长尾关键词
  • 如何才能建设出一个优秀网站交换友链平台
  • 营销加盟网站建设石家庄最新消息
  • 郑州网站建设公司招聘企业网站建设方案书