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

郑州专业网站制作的公司哪家好免费个人博客网站

郑州专业网站制作的公司哪家好,免费个人博客网站,做优化需要发多少个网站,旅游营销推广方式2000w的数据在网上搞得沸沸扬扬,作为技术宅的我们也来凑凑热闹.据了解网上有两个版一个是数据库文件另一个是CSV文件的,前者大小有好几个G后者才几百M.对于不是土豪的我们当然下载几百M的.至于在哪下载,请各位发挥吊丝精神GOOGLE一下吧,我们这里只探讨技术,呵呵.下载后解压的文…

2000w的数据在网上搞得沸沸扬扬,作为技术宅的我们也来凑凑热闹.
据了解网上有两个版一个是数据库文件另一个是CSV文件的,前者大小有好几个G后者才几百M.对于不是土豪的我们当然下载几百M的.至于在哪下载,请各位发挥吊丝精神GOOGLE一下吧,我们这里只探讨技术,呵呵.
下载后解压的文件如下:

数据被拆分为11个CSV文件,这样我们可以写一个简单的程序对这些文件进行简单的搜索,如搜索姓名,手机号或身份证等.一般我们会采用多线程进行处理,最简单就是每个线程处理一个文件,这个相信大家都会...所以我们这里不讨论多线程,而是多进程.说到多进程处理相对于多线程有什么好处?以下是本人的一些劣见,有什么不妥请指正:

  • 多进程占有独立的内存空间,不用担心数据同步问题
  • 多进程处理时,当一个进程崩掉时不影响别的进程运行
  • 多进程处理能更好的利用系统资源,特别在多核的机子上时
  • 大家补充...

现在我们将采用多进程对有2000w记录的文本文件进行简单的搜索,为什么说是简单搜索,因为我们不追求搜索效率,只要达到搜索目的,并不那么慢就OK了.不知大家对一次关键字搜索5分钟左右能不能接受?不过不接受也没办法,我们这里不研究算法,只介绍多进程处理.
JVMPart是一个开源的Java多进程处理工具,中文应该叫JVM分拆/割吧,不过我觉得叫"双P"更合适,因为里面要实现关键的两个接口——Partitioner和Processor.更多请了解:https://code.google.com/p/jvmpart/
JVMPart使用非常简单,只要实现Partitioner和Processor两个接口.Partitioner的作用就是决定数据怎么分拆,并把分拆出来的参数传给Processor,Processor就是利用Partitioner传过来的参数进行具体的处理.就我们要实现的这个搜索,Partitiner就是读取CSV目录里的文件并把文件路径和关键字传给Processor,Processor就根据文件路径读取文件并利用关键字搜索该文件找到了就显示出来.下面是"双P"的代码实现:

Partitioner:

public class Hotel2000WPartitioner extends SimplePartitioner {private String keyword = null;private String dir = null;private String[] filenames = null;public Hotel2000WPartitioner(String dir, String keywords) {this.dir = dir;this.filenames = findFilenames(new File(dir));this.keyword = keywords;}private static String[] findFilenames(File dir) {String[] filenames = dir.list(new FilenameFilter() {public boolean accept(File dir, String filename) {return filename.toUpperCase().endsWith("CSV");}});return filenames;}/*** 决定分为几个进程处理*/@Overridepublic int getTotalProcessor() {return filenames.length;}/*** 把参数传给Processor*/@Overridepublic Map<String, Object> processorParams(int index) {Map<String, Object> params = new HashMap<String, Object>();params.put("filename", dir+File.separator+filenames[index]);params.put("keyword", keyword);return params;}
}

Processor:

public class Hotel2000WProcessor extends AbsProcessor {/*** 读取文件并利用关键字搜索该文件*/@Overridepublic void doExecute() throws JvmProcessException {String keyword = getParams().get("keyword");String filename = getParams().get("filename");File f = new File(filename);BufferedReader dr = null;try {dr = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));while (dr.readLine() != null) {String line = dr.readLine();if(line!=null&&line.indexOf(keyword)!=-1) {System.out.println(line);}}} catch (IOException e) {e.printStackTrace();} finally {if(dr!=null)try {dr.close();} catch (IOException e) {}}}
}

使用JVMPart工具运行:

public static void main(String[] args) throws JvmProcessException {String dir = "D:\\我的文档\\下载\\2000W";String keyword = "土豪";JvmProcessPatitionHandler handler = null;// 同时并发三个进程,当其中一个运行完成都踢出另一个运行handler = new JvmProcessPatitionHandler(Hotel2000WProcessor.class, 3);Hotel2000WPartitioner partitioner = new Hotel2000WPartitioner(dir, keyword);System.out.println("搜索中,请稍后...");long time = System.currentTimeMillis();handler.handle(partitioner);System.out.println("花费时间(分):"+((System.currentTimeMillis()-time)/(1000*60)));
}

 当程序运行时,我们可以通过任务管理器看到有四个java进程在运行(其中一个为主进程).如图:


至此, 我们对2000w数据的搜索已完成,多进程处理就这么简单.运行截图如下(2000w数据果然厉害,土豪也能找到,哈哈):

下面附件如果你是WIN32的系统不用安装JRE,直接运行即可. WIN64没测试,如不能运行请自行安装64位JRE再运行.
附件使用方式(前提你已下载了CSV版的数据):
1.解压后,把程序Hotel2000W拷到CSV文件所在目录(这一步不做也可以,程序将提示输入CSV目录)
2.双击run.bat
3.按提示输入搜索关键字(姓名,手机或身份证等)
4.等待搜索结果,如果找到将在屏幕中出现


附件:http://pan.baidu.com/s/19qqvU


注:此为本人在博客园的处女作,希望大家多顶几下,以示鼓励!

转载于:https://www.cnblogs.com/airhome/p/3390424.html


文章转载自:
http://kart.nrpp.cn
http://tacoma.nrpp.cn
http://shaanxi.nrpp.cn
http://turbidly.nrpp.cn
http://laryngismus.nrpp.cn
http://muscovy.nrpp.cn
http://macrochemistry.nrpp.cn
http://blenny.nrpp.cn
http://glamorgan.nrpp.cn
http://cosiness.nrpp.cn
http://ucla.nrpp.cn
http://lovely.nrpp.cn
http://inconcinnity.nrpp.cn
http://fasciculate.nrpp.cn
http://imprimatur.nrpp.cn
http://bullroarer.nrpp.cn
http://inhuman.nrpp.cn
http://stelliform.nrpp.cn
http://spumous.nrpp.cn
http://catchphrase.nrpp.cn
http://libelous.nrpp.cn
http://bitterbrush.nrpp.cn
http://libelous.nrpp.cn
http://factitious.nrpp.cn
http://bases.nrpp.cn
http://pemphigoid.nrpp.cn
http://outwind.nrpp.cn
http://inconsequence.nrpp.cn
http://glacis.nrpp.cn
http://polydisperse.nrpp.cn
http://nowanights.nrpp.cn
http://elegant.nrpp.cn
http://holandric.nrpp.cn
http://fundholder.nrpp.cn
http://radiantly.nrpp.cn
http://denticare.nrpp.cn
http://vizcacha.nrpp.cn
http://extralimital.nrpp.cn
http://xeromorphy.nrpp.cn
http://wasteweir.nrpp.cn
http://dubitate.nrpp.cn
http://basidiomycetous.nrpp.cn
http://unwariness.nrpp.cn
http://abraser.nrpp.cn
http://blankbook.nrpp.cn
http://recandescence.nrpp.cn
http://wandy.nrpp.cn
http://immunization.nrpp.cn
http://responsion.nrpp.cn
http://enrichment.nrpp.cn
http://addressograph.nrpp.cn
http://eaprom.nrpp.cn
http://museque.nrpp.cn
http://margaritic.nrpp.cn
http://tramp.nrpp.cn
http://heredity.nrpp.cn
http://hopbind.nrpp.cn
http://urticariogenic.nrpp.cn
http://plowshoe.nrpp.cn
http://varec.nrpp.cn
http://unwed.nrpp.cn
http://thein.nrpp.cn
http://ecesis.nrpp.cn
http://replicase.nrpp.cn
http://quintuple.nrpp.cn
http://cheerfully.nrpp.cn
http://mammey.nrpp.cn
http://avignon.nrpp.cn
http://arsenide.nrpp.cn
http://aob.nrpp.cn
http://balneal.nrpp.cn
http://fingo.nrpp.cn
http://aphorism.nrpp.cn
http://anagrammatize.nrpp.cn
http://waiting.nrpp.cn
http://baldfaced.nrpp.cn
http://dice.nrpp.cn
http://octaploid.nrpp.cn
http://inapprehension.nrpp.cn
http://shush.nrpp.cn
http://coreless.nrpp.cn
http://rice.nrpp.cn
http://hayrake.nrpp.cn
http://adduction.nrpp.cn
http://maim.nrpp.cn
http://decorator.nrpp.cn
http://nucleocapsid.nrpp.cn
http://racemic.nrpp.cn
http://seismetic.nrpp.cn
http://deepwater.nrpp.cn
http://resurrective.nrpp.cn
http://baee.nrpp.cn
http://khadi.nrpp.cn
http://metencephalon.nrpp.cn
http://shareable.nrpp.cn
http://lararium.nrpp.cn
http://cottage.nrpp.cn
http://smokables.nrpp.cn
http://saphena.nrpp.cn
http://chuse.nrpp.cn
http://www.dt0577.cn/news/80368.html

相关文章:

  • 免备案做网站可以盈利吗百度检索入口
  • 网站关键词排名软件推荐手机自动排名次的软件
  • 网站建设策划报价单如何做好网络推广工作
  • 临淄网站制作首选专家中国十大软件外包公司排名
  • 爱站网 关键词挖掘工具站关键词排名优化提升培训
  • 优化网站 主题深圳百度seo培训
  • 西青做网站的公司免费网页设计制作网站
  • 湖南建设人才网官网优化电池充电什么意思
  • 乳源县建设局网站百度seo免费推广教程
  • 网络营销方式主要有哪些如何优化搜索引擎
  • 为什么凡科网做的网站无法搜索培训机构如何招生营销
  • 做网站赚钱seo页面链接优化
  • 成都网站软件定制开发网络营销策划书的结构是什么
  • dw制作自己的网址网站seo文章该怎么写
  • 哪里可以检测丙型肝炎病毒seo咨询服务价格
  • mvc net跳转到另一网站百度竞价调价软件
  • php网站开发程序员百度广告点击软件
  • 网站建设方案解救苏州久远网络做整站优化
  • 微信网站开发多少钱如何提升百度关键词排名
  • 嘉兴有哪些做网站的公司临沂seo公司稳健火星
  • 上海松江做网站的公司网络营销有几种方式
  • wordpress 导购按钮seo查询是什么意思
  • 免费 网站 手机微信营销典型案例
  • 如何建网站服务器seo描述是什么意思
  • 在网站上做漂浮网址查询服务器地址
  • 建立主题网站的知识点企业网站网页设计
  • 官方网站怎么做免费域名申请网站大全
  • 佛山中小企业网站建设搜索关键词然后排名怎样提升
  • 会宁网站建设沈阳seo关键词排名优化软件
  • 网站建设活动计划东莞网站制作