求解解决方法

WBOY
Release: 2016-06-13 13:33:23
Original
1051 people have browsed it

求解
你的需求这样是解决不了的

要分开处理。。。。。

比如,可将ip按第一位,写到255个文件里面,,,也可以将ip转换成数字,这样处理后续可以少用点内存

分别在255个文件里面,找出前1000名。。。因为每组至多包含2^24个不同的数【暂时不考虑ipv6】,这个内存可接受的
这样用一个数组遍历,复杂度O(n),即可找出前1000

最后维护一个1000的有序数组,往里面插入数据即可,超过1000,弹出最小的那个 
=====
能给出例子代码吗?

------解决方案--------------------
一次读取100W条数据,内存肯定吃不消,再来几个并发,那就更不得了了,还是分段读取,按2楼说的那样,把内容放到N个文件中,读取频率最高的,这样不至于一次打开一个上T的文件

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!